Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/spark_api/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ def put(path, body = nil, options={})
request(:put, path, body, options)
end

# Perform an HTTP PATCH request
#
# * path - Path of an api resource, excluding version and endpoint (domain) information
# * body - Hash for patch body data
# * options - Resource request options as specified being supported via and api resource
# :returns:
# Hash of the json results as documented in the api.
# :raises:
# SparkApi::ClientError or subclass if the request failed.
def patch(path, body = nil, options={})
request(:patch, path, body, options)
end

# Perform an HTTP DELETE request
#
# * path - Path of an api resource, excluding version and endpoint (domain) information
Expand Down
10 changes: 9 additions & 1 deletion spec/unit/spark_api/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,11 @@
}
stub.put('/v1/arraydata?ApiSig=SignedToken&AuthToken=1234', '{"D":["A","B","C"]}') {[200, {}, '{"D": {
"Success": true}}']}
stub.patch('/v1/contacts/1000?ApiSig=SignedToken&AuthToken=1234', '{"D":{"Contacts":[{"DisplayName":"WLMCEWENS Contact","PrimaryEmail":"wlmcewen789@fbsdata.com"}]}}') { [200, {}, '{"D": {
"Success": true}}']
}
stub.delete('/v1/contacts/1000?ApiSig=SignedToken&AuthToken=1234') { [200, {}, '{"D": {
"Success": true}}']
"Success": true}}']
}
# Other MISC requests
stub.post('/v1/stringdata?ApiSig=SignedToken&AuthToken=1234', 'I am a lonely String!') { [200, {}, '{"D": {
Expand Down Expand Up @@ -214,6 +217,11 @@ def version()
expect(subject.put('/contacts/1000', data).size).to be(0)
# No validation here, if no error is raised, everything is hunky dory
end
it "should patch to a service" do
data = {"Contacts" => [{"DisplayName"=>"WLMCEWENS Contact","PrimaryEmail"=>"wlmcewen789@fbsdata.com"}]}
expect(subject.patch('/contacts/1000', data).size).to be(0)
# No validation here, if no error is raised, everything is hunky dory
end
it "should delete from a service" do
# This is a hypothetical unsupported service action at this time
expect(subject.delete('/contacts/1000').size).to be(0)
Expand Down
Loading