diff --git a/CHANGELOG.md b/CHANGELOG.md index c87d606..df0e038 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ ## [Unreleased] -## [1.3.0] - 2024-10-30 +## [2.0.0] - 2024-11-12 + +- Remove support for instance usage of Incognia::Api +- Remove invalid feedback types +- Remove support for sending feedback timestamp + +## [1.3.0] - 2024-11-12 - Add support for general configuration and use Incognia::Api as a static class diff --git a/Gemfile.lock b/Gemfile.lock index 5304589..c694dd8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - incognia_api (1.3.0) + incognia_api (2.0.0) faraday (~> 1.10) faraday_middleware (~> 1.2) diff --git a/README.md b/README.md index 0fc4420..877d6d2 100644 --- a/README.md +++ b/README.md @@ -198,7 +198,7 @@ assessment = Incognia::Api.register_payment( This method registers a feedback event for the given identifiers (optional arguments), returning true when success. -The `timestamp` argument should be a _Time_, _DateTime_ or an _Integer_ being the timestamp in milliseconds. +The `occurred_at` argument should be a _Time_, _DateTime_ or an date in **RFC 3339** format. The `expires_at` argument should be a _Time_, _DateTime_ or an date in **RFC 3339** format. diff --git a/lib/incognia_api/api.rb b/lib/incognia_api/api.rb index 788c8bf..eaf127e 100644 --- a/lib/incognia_api/api.rb +++ b/lib/incognia_api/api.rb @@ -40,16 +40,11 @@ def register_login(account_id:, request_token: nil, **opts) LoginAssessment.from_hash(response.body) if response.success? end - def register_feedback(event:, occurred_at: nil, expires_at: nil, timestamp: nil, **ids) - if !timestamp.nil? - warn("Deprecation warning: use occurred_at instead of timestamp") - end - - timestamp = timestamp.strftime('%s%L') if timestamp.respond_to? :strftime + def register_feedback(event:, occurred_at: nil, expires_at: nil, **ids) occurred_at = occurred_at.to_datetime.rfc3339 if occurred_at.respond_to? :to_datetime expires_at = expires_at.to_datetime.rfc3339 if expires_at.respond_to? :to_datetime - params = { event: event, timestamp: timestamp&.to_i, occurred_at: occurred_at, expires_at: expires_at }.compact + params = { event: event, occurred_at: occurred_at, expires_at: expires_at }.compact params.merge!(ids) response = connection.request( diff --git a/lib/incognia_api/version.rb b/lib/incognia_api/version.rb index 10a0763..cb8578e 100644 --- a/lib/incognia_api/version.rb +++ b/lib/incognia_api/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Incognia - VERSION = "1.3.0" + VERSION = "2.0.0" end diff --git a/spec/incognia_spec.rb b/spec/incognia_spec.rb index 8f3815b..8dcb626 100644 --- a/spec/incognia_spec.rb +++ b/spec/incognia_spec.rb @@ -370,8 +370,8 @@ module Incognia describe ".register_feedback" do let(:event) { Incognia::Constants::FeedbackEvent.constants.sample.to_s } - let(:timestamp) { 1655749693000 } - let(:expires_at) { '2024-03-13T10:12:01Z' } + let(:occurred_at) { '2024-03-13T10:12:01Z' } + let(:expires_at) { '2024-03-13T10:12:02Z' } before do allow(described_class).to receive(:warn) @@ -383,86 +383,46 @@ module Incognia it "when successful returns true" do stub_register_feedback_request - feedback_registered = described_class.register_feedback(event: event, timestamp: timestamp) + feedback_registered = described_class.register_feedback(event: event) expect(feedback_registered).to be(true) end - it "warns about the deprecation of timestamp" do - stub_register_feedback_request - - expect(described_class).to receive(:warn).with("Deprecation warning: use occurred_at instead of timestamp") - - described_class.register_feedback(event: event, timestamp: timestamp) - end - context "HTTP request" do - it "hits the endpoint with event, timestamp and expires_at" do + it "hits the endpoint with event, occurred_at and expires_at" do stub = stub_register_feedback_request stub.with( - body: { event: event, timestamp: timestamp, expires_at: expires_at }, + body: { event: event, occurred_at: occurred_at, expires_at: expires_at }, headers: { 'Content-Type' => 'application/json', 'Authorization' => /Bearer.*/ } ) - described_class.register_feedback(event: event, timestamp: timestamp, expires_at: expires_at) + described_class.register_feedback(event: event, occurred_at: occurred_at, expires_at: expires_at) expect(stub).to have_been_made.once end - context "when receiving timestamp as a Time" do - let(:timestamp) { Time.now } - - it "hits the endpoint with timestamp in milliseconds" do - stub = stub_register_feedback_request.with( - body: { event: event, timestamp: timestamp.strftime('%s%L').to_i }, - headers: { - 'Content-Type' => 'application/json', 'Authorization' => /Bearer.*/ - } - ) - - described_class.register_feedback(event: event, timestamp: timestamp) - - expect(stub).to have_been_made.once - end - end - - context "when receiving timestamp as a DateTime" do - let(:timestamp) { DateTime.now } - - it "hits the endpoint with timestamp in milliseconds" do - stub = stub_register_feedback_request.with( - body: { event: event, timestamp: timestamp.strftime('%s%L').to_i }, - headers: { - 'Content-Type' => 'application/json', 'Authorization' => /Bearer.*/ - } - ) - - described_class.register_feedback(event: event, timestamp: timestamp) - - expect(stub).to have_been_made.once - end - end + context "when receiving occurred_at as a Time" do + let(:occurred_at) { Time.now } - context "when not receiving timestamp" do - it "hits the endpoint without timestamp" do + it "hits the endpoint with expires_at in RFC3339" do stub = stub_register_feedback_request.with( - body: { event: event }, + body: { event: event, occurred_at: occurred_at.to_datetime.rfc3339 }, headers: { 'Content-Type' => 'application/json', 'Authorization' => /Bearer.*/ } ) - described_class.register_feedback(event: event) + described_class.register_feedback(event: event, occurred_at: occurred_at) expect(stub).to have_been_made.once end end - context "when receiving occurred_at as a Time" do - let(:occurred_at) { Time.now } + context "when receiving occurred_at as a DateTime" do + let(:occurred_at) { DateTime.now } - it "hits the endpoint with expires_at in RFC3339" do + it "hits the endpoint with occurred_at in RFC3339" do stub = stub_register_feedback_request.with( body: { event: event, occurred_at: occurred_at.to_datetime.rfc3339 }, headers: { @@ -476,18 +436,16 @@ module Incognia end end - context "when receiving occurred_at as a DateTime" do - let(:occurred_at) { DateTime.now } - - it "hits the endpoint with occurred_at in RFC3339" do + context "when not receiving occurred_at" do + it "hits the endpoint without occurred_at" do stub = stub_register_feedback_request.with( - body: { event: event, occurred_at: occurred_at.to_datetime.rfc3339 }, + body: { event: event }, headers: { 'Content-Type' => 'application/json', 'Authorization' => /Bearer.*/ } ) - described_class.register_feedback(event: event, occurred_at: occurred_at) + described_class.register_feedback(event: event) expect(stub).to have_been_made.once end @@ -548,13 +506,13 @@ module Incognia it "hits the endpoint with #{id_name}" do stub = stub_register_feedback_request.with( - body: { event: event, timestamp: timestamp, expires_at: expires_at, id_name => id }, + body: { event: event, occurred_at: occurred_at, expires_at: expires_at, id_name => id }, headers: { 'Content-Type' => 'application/json', 'Authorization' => /Bearer.*/ } ) - described_class.register_feedback(event: event, timestamp: timestamp, expires_at: expires_at, id_name => id) + described_class.register_feedback(event: event, occurred_at: occurred_at, expires_at: expires_at, id_name => id) expect(stub).to have_been_made.once end