From 0f959bc2509f5d6a0ca8842fffd8c393e7c92718 Mon Sep 17 00:00:00 2001 From: Thiago Cardoso Date: Wed, 24 Jul 2024 11:20:31 -0300 Subject: [PATCH 1/4] feat!: remove timestamp from register_feedback --- CHANGELOG.md | 4 +++ Gemfile.lock | 2 +- lib/incognia_api/api.rb | 9 ++--- lib/incognia_api/version.rb | 2 +- spec/incognia_spec.rb | 65 +++++-------------------------------- 5 files changed, 16 insertions(+), 66 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fe632a..ab5ead9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## [Unreleased] +## [2.0.0] - 2024-07-24 + +- Remove support to passing timestamp on #register_feedback + ## [1.1.0] - 2024-07-24 - Add support to passing request_token and occurred_at to #register_feedback diff --git a/Gemfile.lock b/Gemfile.lock index 2b3346c..c694dd8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - incognia_api (1.1.0) + incognia_api (2.0.0) faraday (~> 1.10) faraday_middleware (~> 1.2) diff --git a/lib/incognia_api/api.rb b/lib/incognia_api/api.rb index 0aea807..b440ea7 100644 --- a/lib/incognia_api/api.rb +++ b/lib/incognia_api/api.rb @@ -46,16 +46,11 @@ def register_login(installation_id:, account_id:, **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 93de543..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.1.0" + VERSION = "2.0.0" end diff --git a/spec/incognia_spec.rb b/spec/incognia_spec.rb index 8517b48..a83ac9d 100644 --- a/spec/incognia_spec.rb +++ b/spec/incognia_spec.rb @@ -320,82 +320,33 @@ 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 { stub_token_request } it "when successful returns true" do stub_register_feedback_request - feedback_registered = api.register_feedback(event: event, timestamp: timestamp) + feedback_registered = api.register_feedback(event: event) expect(feedback_registered).to be(true) 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.*/ } ) - api.register_feedback(event: event, timestamp: timestamp, expires_at: expires_at) + api.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.*/ - } - ) - - api.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.*/ - } - ) - - api.register_feedback(event: event, timestamp: timestamp) - - expect(stub).to have_been_made.once - end - end - - context "when not receiving timestamp" do - it "hits the endpoint without timestamp" do - stub = stub_register_feedback_request.with( - body: { event: event }, - headers: { - 'Content-Type' => 'application/json', 'Authorization' => /Bearer.*/ - } - ) - - api.register_feedback(event: event) - - expect(stub).to have_been_made.once - end - end - context "when receiving occurred_at as a Time" do let(:occurred_at) { Time.now } @@ -485,13 +436,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.*/ } ) - api.register_feedback(event: event, timestamp: timestamp, expires_at: expires_at, id_name => id) + api.register_feedback(event: event, occurred_at: occurred_at, expires_at: expires_at, id_name => id) expect(stub).to have_been_made.once end From b0e6f9f8558189a8b9dc5a17655c97ca68845949 Mon Sep 17 00:00:00 2001 From: Ottony Costa Date: Tue, 12 Nov 2024 16:56:02 -0300 Subject: [PATCH 2/4] Test feedback without occurred_at --- spec/incognia_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/incognia_spec.rb b/spec/incognia_spec.rb index 92b1034..8dcb626 100644 --- a/spec/incognia_spec.rb +++ b/spec/incognia_spec.rb @@ -436,6 +436,21 @@ module Incognia end end + context "when not receiving occurred_at" do + it "hits the endpoint without occurred_at" do + stub = stub_register_feedback_request.with( + body: { event: event }, + headers: { + 'Content-Type' => 'application/json', 'Authorization' => /Bearer.*/ + } + ) + + described_class.register_feedback(event: event) + + expect(stub).to have_been_made.once + end + end + context "when receiving expires_at as a Time" do let(:expires_at) { Time.now } From 360b3c473636b60cb071b7b7d5276ef19582ee5a Mon Sep 17 00:00:00 2001 From: Ottony Costa Date: Tue, 12 Nov 2024 17:18:25 -0300 Subject: [PATCH 3/4] Update CHANGELOG and bump version to 2.0.0 --- CHANGELOG.md | 8 +++++++- Gemfile.lock | 2 +- lib/incognia_api/version.rb | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) 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/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 From 0d16c5f04229e9e064d1e6a0bb281b2bf584816f Mon Sep 17 00:00:00 2001 From: Ottony Costa Date: Tue, 12 Nov 2024 18:36:23 -0300 Subject: [PATCH 4/4] Update README removing feedback timestamp --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.