Class: Incognia::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/incognia_api/api.rb

Class Method Summary collapse

Class Method Details

.connectionObject



81
82
83
# File 'lib/incognia_api/api.rb', line 81

def connection
  Client.instance
end

.register_feedback(event:, occurred_at: nil, expires_at: nil, person_id: nil, **ids) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/incognia_api/api.rb', line 45

def register_feedback(event:, occurred_at: nil, expires_at: nil, person_id: 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, occurred_at: occurred_at, expires_at: expires_at }.compact
  params.merge!(person_id: person_id.to_hash) if person_id
  params.merge!(ids)

  response = connection.request(
    :post,
    '/api/v2/feedbacks',
    params
  )

  response.success?
end

.register_login(account_id:, request_token: nil, location: nil, person_id: nil, **opts) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/incognia_api/api.rb', line 26

def (account_id:, request_token: nil, location: nil, person_id: nil, **opts)
  params = {
    type: :login,
    account_id: ,
    request_token: request_token
  }.compact
  params.merge!(location: location.to_hash) if location
  params.merge!(person_id: person_id.to_hash) if person_id
  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, location: nil, person_id: nil, **opts) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/incognia_api/api.rb', line 62

def register_payment(account_id:, request_token: nil, location: nil, person_id: nil, **opts)
  params = {
    type: :payment,
    account_id: ,
    request_token: request_token
  }.compact
  params.merge!(location: location.to_hash) if location
  params.merge!(person_id: person_id.to_hash) if person_id
  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, person_id: nil, **opts) ⇒ Object

business layer: uses the Client.instance to build domain objects raises missing parameters errors



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/incognia_api/api.rb', line 11

def (request_token: nil, address: nil, person_id: nil, **opts)
  params = { request_token: request_token }.compact
  params.merge!(opts)
  params.merge!(address.to_hash) if address
  params.merge!(person_id: person_id.to_hash) if person_id

  response = connection.request(
    :post,
    'v2/onboarding/signups',
    params
  )

  SignupAssessment.from_hash(response.body) if response.success?
end