Skip to content

Commit f8b16cd

Browse files
authored
Merge pull request #163 from sparkapi/MWEB-2470
MWEB-2470
2 parents d1554b3 + ddd4713 commit f8b16cd

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
v1.4.31
2+
- Updated requests to allow arrays as a body
3+
14
v1.4.30
25
- added `script/reso_middleware_example.rb`
36

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.30
1+
1.4.31

lib/spark_api/request.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def request(method, path, body, options)
107107
end
108108

109109
def process_request_body(body)
110-
if body.is_a?(Hash)
110+
if body.is_a?(Hash) || body.is_a?(Array)
111111
body.empty? ? nil : {"D" => body }.to_json
112112
else
113113
body

spec/unit/spark_api/request_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
stub.put('/v1/contacts/1000?ApiSig=SignedToken&AuthToken=1234', '{"D":{"Contacts":[{"DisplayName":"WLMCEWENS Contact","PrimaryEmail":"wlmcewen789@fbsdata.com"}]}}') { [200, {}, '{"D": {
119119
"Success": true}}']
120120
}
121+
stub.put('/v1/arraydata?ApiSig=SignedToken&AuthToken=1234', '{"D":["A","B","C"]}') {[200, {}, '{"D": {
122+
"Success": true}}']}
121123
stub.delete('/v1/contacts/1000?ApiSig=SignedToken&AuthToken=1234') { [200, {}, '{"D": {
122124
"Success": true}}']
123125
}
@@ -223,6 +225,10 @@ def version()
223225
subject.post('/stringdata', 'I am a lonely String!').success?.should == true
224226
end
225227

228+
it "should support arrays in the body" do
229+
subject.put('/arraydata', ["A","B","C"]).success?.should == true
230+
end
231+
226232
it "should allow response object to be returned instead of body" do
227233
r = subject.get('/system', { full_response: true })
228234

0 commit comments

Comments
 (0)