Class: Incognia::Api
- Inherits:
-
Object
- Object
- Incognia::Api
- Defined in:
- lib/incognia_api/api.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
business layer: uses the Client to build domain objects raises missing parameters errors.
Instance Method Summary collapse
-
#initialize(client_id:, client_secret:) ⇒ Api
constructor
A new instance of Api.
- #register_feedback(event:, occurred_at: nil, expires_at: nil, timestamp: nil, **ids) ⇒ Object
- #register_login(account_id:, request_token: nil, **opts) ⇒ Object
- #register_payment(account_id:, request_token: nil, **opts) ⇒ Object
- #register_signup(request_token: nil, address: nil, **opts) ⇒ Object
Constructor Details
Instance Attribute Details
#connection ⇒ Object
business layer: uses the Client to build domain objects raises missing parameters errors
10 11 12 |
# File 'lib/incognia_api/api.rb', line 10 def connection @connection end |
Instance Method Details
#register_feedback(event:, occurred_at: nil, expires_at: nil, timestamp: nil, **ids) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/incognia_api/api.rb', line 49 def register_feedback(event:, occurred_at: nil, expires_at: nil, timestamp: nil, **ids) if !.nil? warn("Deprecation warning: use occurred_at instead of timestamp") end = .strftime('%s%L') if .respond_to? :strftime 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: &.to_i, occurred_at: occurred_at, expires_at: expires_at }.compact params.merge!(ids) response = connection.request( :post, '/api/v2/feedbacks', params ) response.success? end |
#register_login(account_id:, request_token: nil, **opts) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/incognia_api/api.rb', line 32 def register_login(account_id:, request_token: nil, **opts) params = { type: :login, account_id: account_id, request_token: request_token }.compact params.merge!(opts) response = connection.request( :post, 'v2/authentication/transactions', params ) LoginAssessment.from_hash(response.body) if response.success? end |
#register_payment(account_id:, request_token: nil, **opts) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/incognia_api/api.rb', line 70 def register_payment(account_id:, request_token: nil, **opts) params = { type: :payment, account_id: account_id, request_token: request_token }.compact params.merge!(opts) response = connection.request( :post, 'v2/authentication/transactions', params ) PaymentAssessment.from_hash(response.body) if response.success? end |
#register_signup(request_token: nil, address: nil, **opts) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/incognia_api/api.rb', line 18 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 response = connection.request( :post, 'v2/onboarding/signups', params ) SignupAssessment.from_hash(response.body) if response.success? end |