diff --git a/CHANGELOG b/CHANGELOG index 8449cc9..e298ced 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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+ diff --git a/VERSION b/VERSION index 227cea2..38f77a6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.0 +2.0.1 diff --git a/lib/spark_api/request.rb b/lib/spark_api/request.rb index f4363a5..bb16cc0 100644 --- a/lib/spark_api/request.rb +++ b/lib/spark_api/request.rb @@ -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 diff --git a/spark_api.gemspec b/spark_api.gemspec index b701564..e98c271 100644 --- a/spark_api.gemspec +++ b/spark_api.gemspec @@ -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' diff --git a/spec/unit/spark_api/request_spec.rb b/spec/unit/spark_api/request_spec.rb index ebac4b1..3634888 100644 --- a/spec/unit/spark_api/request_spec.rb +++ b/spec/unit/spark_api/request_spec.rb @@ -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": { @@ -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)