lib/incognia_api/api.rb in incognia_api-1.3.0 vs lib/incognia_api/api.rb in incognia_api-2.0.0

- old
+ new

@@ -3,31 +3,14 @@ require "logger" require 'faraday_middleware' module Incognia class Api - # business layer: uses the Client.instance to build domain objects - # raises missing parameters errors - - def initialize(client_id:, client_secret:) - Incognia.configure(client_id: client_id, client_secret: client_secret) - - warn("Deprecation warning: The Incognia::Api instance will be removed. " + - "Please set up with `Incognia.configure` and use class methods instead.") - end - - def register_signup(**args); self.class.register_signup(**args) end - def register_login(**args); self.class.register_login(**args) end - def register_feedback(**args); self.class.register_feedback(**args) end - def register_payment(**args); self.class.register_payment(**args) end - def connection - warn("Deprecation warning: #connection and .connection are deprecated and will be private.") - - self.class.connection - end - class << self + # business layer: uses the Client.instance to build domain objects + # raises missing parameters errors + def register_signup(request_token: nil, address: nil, **opts) params = { request_token: request_token }.compact params.merge!(opts) params.merge!(address&.to_hash) if address @@ -55,19 +38,14 @@ ) 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( :post, '/api/v2/feedbacks',