Class: PersonaApi::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/persona_api/client.rb

Constant Summary collapse

BASE_URL =
'https://withpersona.com/api/v1/'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, adapter: Faraday.default_adapter) ⇒ Client

Returns a new instance of Client.



10
11
12
13
# File 'lib/persona_api/client.rb', line 10

def initialize(api_key:, adapter: Faraday.default_adapter)
  @api_key = api_key
  @adapter = adapter
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



8
9
10
# File 'lib/persona_api/client.rb', line 8

def adapter
  @adapter
end

#api_keyObject (readonly)

Returns the value of attribute api_key.



8
9
10
# File 'lib/persona_api/client.rb', line 8

def api_key
  @api_key
end

Instance Method Details

#accountsObject



15
16
17
# File 'lib/persona_api/client.rb', line 15

def accounts
  AccountsResource.new(self)
end

#api_logsObject



19
20
21
# File 'lib/persona_api/client.rb', line 19

def api_logs
  ApiLogsResource.new(self)
end

#casesObject



23
24
25
# File 'lib/persona_api/client.rb', line 23

def cases
  CasesResource.new(self)
end

#connectionObject



91
92
93
94
95
96
97
98
99
100
# File 'lib/persona_api/client.rb', line 91

def connection
  @connection ||= Faraday.new do |connection|
    connection.url_prefix = BASE_URL
    connection.request :authorization, :Bearer, api_key
    connection.headers['Key-Inflection'] = "snake"
    connection.request :json
    connection.response :json, content_type: "application/json"
    connection.adapter adapter
  end
end

#database_verificationsObject



27
28
29
# File 'lib/persona_api/client.rb', line 27

def database_verifications
  DatabaseVerificationsResource.new(self)
end

#documentsObject



31
32
33
# File 'lib/persona_api/client.rb', line 31

def documents
  DocumentsResource.new(self)
end

#eventsObject



35
36
37
# File 'lib/persona_api/client.rb', line 35

def events
  EventsResource.new(self)
end

#filesObject



39
40
41
# File 'lib/persona_api/client.rb', line 39

def files
  FilesResource.new(self)
end

#government_id_verificationsObject



43
44
45
# File 'lib/persona_api/client.rb', line 43

def government_id_verifications
  GovernmentIdVerificationsResource.new(self)
end

#inquiriesObject



47
48
49
# File 'lib/persona_api/client.rb', line 47

def inquiries
  InquiriesResource.new(self)
end

#list_itemsObject



55
56
57
# File 'lib/persona_api/client.rb', line 55

def list_items
  ListItemsResource.new(self)
end

#listsObject



51
52
53
# File 'lib/persona_api/client.rb', line 51

def lists
  ListsResource.new(self)
end

#phone_carrier_verificationsObject



59
60
61
# File 'lib/persona_api/client.rb', line 59

def phone_carrier_verifications
  PhoneCarrierVerificationsResource.new(self)
end

#phone_number_verificationsObject



63
64
65
# File 'lib/persona_api/client.rb', line 63

def phone_number_verifications
  PhoneNumberVerificationsResource.new(self)
end

#reportsObject



67
68
69
# File 'lib/persona_api/client.rb', line 67

def reports
  ReportsResource.new(self)
end

#selfie_verificationsObject



71
72
73
# File 'lib/persona_api/client.rb', line 71

def selfie_verifications
  SelfieVerificationsResource.new(self)
end

#tin_database_verificationsObject



75
76
77
# File 'lib/persona_api/client.rb', line 75

def tin_database_verifications
  TinDatabaseVerificationsResource.new(self)
end

#transactionsObject



79
80
81
# File 'lib/persona_api/client.rb', line 79

def transactions
  TransactionsResource.new(self)
end

#user_audit_logsObject



83
84
85
# File 'lib/persona_api/client.rb', line 83

def user_audit_logs
  UserAuditLogsResource.new(self)
end

#verificationsObject



87
88
89
# File 'lib/persona_api/client.rb', line 87

def verifications
  VerificationsResource.new(self)
end