Skip to content
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v2.0.1
- Add PATCH support

v2.0.0
- Drop support for ruby 2.7
- Add support for ruby 3.2+
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
2.0.1
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
1 change: 1 addition & 0 deletions spark_api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rake'
s.add_development_dependency 'rspec'
s.add_development_dependency 'webmock'
s.add_development_dependency 'multi_json', '~> 1.15.0'
s.add_development_dependency 'rexml' #needed for ruby 3
s.add_development_dependency 'typhoeus'
s.add_development_dependency 'ci_reporter_rspec'
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