Skip to content

Commit 7a6b3db

Browse files
Merge pull request #124 from sparkapi/API-4301
API-4301 Access to 'D'
2 parents e9c2653 + 3dec111 commit 7a6b3db

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
v1.4.7
2+
- store 'D' attribute in responses
3+
14
v1.4.6
25
- Added Idx model
36

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.6
1+
1.4.7

lib/spark_api/response.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module SparkApi
22
# API Response interface
33
module Response
4-
ATTRIBUTES = [:code, :message, :results, :success, :pagination, :details]
4+
ATTRIBUTES = [:code, :message, :results, :success, :pagination, :details, :d]
55
attr_accessor *ATTRIBUTES
66
def success?
77
@success
@@ -13,16 +13,16 @@ class ApiResponse < ::Array
1313
include SparkApi::Response
1414
def initialize(d)
1515
begin
16-
hash = d["D"]
17-
if hash.nil? || hash.empty?
16+
self.d = d["D"]
17+
if self.d.nil? || self.d.empty?
1818
raise InvalidResponse, "The server response could not be understood"
1919
end
20-
self.message = hash["Message"]
21-
self.code = hash["Code"]
22-
self.results = Array(hash["Results"])
23-
self.success = hash["Success"]
24-
self.pagination = hash["Pagination"]
25-
self.details = hash["Details"] || []
20+
self.message = self.d["Message"]
21+
self.code = self.d["Code"]
22+
self.results = Array(self.d["Results"])
23+
self.success = self.d["Success"]
24+
self.pagination = self.d["Pagination"]
25+
self.details = self.d["Details"] || []
2626
super(results)
2727
rescue Exception => e
2828
SparkApi.logger.error "Unable to understand the response! #{d}"

0 commit comments

Comments
 (0)