diff --git a/HISTORY b/HISTORY index ee2679b..1ffc45a 100644 --- a/HISTORY +++ b/HISTORY @@ -1,3 +1,6 @@ +=== 4.5.0 2024-05-16 +- Support for warnings in Events API + === 4.4.0 2023-10-05 - Score percentiles in Score API diff --git a/README.md b/README.md index e1aca84..274ffa1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ # sift-ruby -[![CircleCI](https://circleci.com/gh/SiftScience/sift-ruby.svg?style=svg)](https://circleci.com/gh/SiftScience/sift-ruby) The official Ruby bindings for the latest version (v205) of the [Sift API](https://sift.com/developers/docs/java/apis-overview). @@ -39,8 +38,22 @@ client = Sift::Client.new(api_key: '', account_id: ' 1, + :items => [{ + :message => 'Invalid currency' + }] + } + end + def percentile_response_json { :user_id => 'billy_jones_301', @@ -689,4 +698,25 @@ def fully_qualified_api_endpoint expect(response.body["scores"]["payment_abuse"]["score"]).to eq(0.78) end + it "Successfully submits a v205 event with WARNINGS" do + response_json = + { :status => 0, :error_message => "OK", :warnings => warnings} + stub_request(:post, "https://api.siftscience.com/v205/events?fields=WARNINGS"). + with { | request| + parsed_body = JSON.parse(request.body) + expect(parsed_body).to include("$api_key" => "overridden") + }.to_return(:status => 200, :body => MultiJson.dump(response_json), :headers => {}) + + api_key = "foobar" + event = "$transaction" + properties = valid_transaction_properties + + response = Sift::Client.new(:api_key => api_key, :version => "205") + .track(event, properties, :api_key => "overridden",:warnings => "true") + expect(response.ok?).to eq(true) + expect(response.api_status).to eq(0) + expect(response.api_error_message).to eq("OK") + expect(response.body["warnings"]["count"]).to eq(1) + expect(response.body["warnings"]["items"][0]["message"]).to eq("Invalid currency") + end end diff --git a/test_integration_app/events_api/test_events_api.rb b/test_integration_app/events_api/test_events_api.rb index c0759ac..299b39d 100644 --- a/test_integration_app/events_api/test_events_api.rb +++ b/test_integration_app/events_api/test_events_api.rb @@ -122,7 +122,7 @@ def transaction() } } - return @@client.track("$transaction", properties) + return @@client.track("$transaction", properties, :warnings => 'true') end def create_order()