plaid 3.0.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,60 @@
1
+ module Plaid
2
+ # Public: Class used to call the Balance product.
3
+ class Balance
4
+ def initialize(client)
5
+ @client = client
6
+ end
7
+
8
+ # Public: Get information about all available balances.
9
+ #
10
+ # Does a POST /accounts/balance/get call to get real-time balance information for all
11
+ # accounts associated with the access_token's item
12
+ #
13
+ # access_token - access_token who's item to fetch balances for
14
+ # account_ids - Specific account ids to fetch balances for (optional)
15
+ # options - Additional options to be merged into API request
16
+ #
17
+ # Returns a parsed JSON of balance response
18
+ def get(access_token, account_ids: nil, options: nil)
19
+ options_payload = {}
20
+ options_payload[:account_ids] = account_ids unless account_ids.nil?
21
+ options_payload = options_payload.merge(options) unless options.nil?
22
+
23
+ payload = { access_token: access_token,
24
+ options: options_payload }
25
+ @client.post_with_auth('accounts/balance/get', payload)
26
+ end
27
+ end
28
+
29
+ # Public: Class used to call the Accounts product.
30
+ class Accounts
31
+ # Public: Memoized class instance to make requests from Plaid::Balance
32
+ def balance
33
+ @balance ||= Plaid::Balance.new(@client)
34
+ end
35
+
36
+ def initialize(client)
37
+ @client = client
38
+ end
39
+
40
+ # Public: Get information about all available accounts.
41
+ #
42
+ # Does a POST /accounts/get call to retrieve high level account information
43
+ # associated with an access_token's item
44
+ #
45
+ # access_token - access_token who's item to fetch accounts for
46
+ # account_ids - Specific account ids to fetch accounts for (optional)
47
+ # options - Additional options to be merged into API request
48
+ #
49
+ # Returns a parsed JSON of account information
50
+ def get(access_token, account_ids: nil, options: nil)
51
+ options_payload = {}
52
+ options_payload[:account_ids] = account_ids unless account_ids.nil?
53
+ options_payload = options_payload.merge(options) unless options.nil?
54
+
55
+ payload = { access_token: access_token,
56
+ options: options_payload }
57
+ @client.post_with_auth('accounts/get', payload)
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,29 @@
1
+ module Plaid
2
+ # Public: Class used to call the Auth product.
3
+ class Auth
4
+ def initialize(client)
5
+ @client = client
6
+ end
7
+
8
+ # Public: Get information about account and routing numbers for checking
9
+ # and savings accounts
10
+ #
11
+ # Does a POST /auth/get call which returns high level account information along with
12
+ # account and routing numbers for checking and savings accounts
13
+ #
14
+ # access_token - access_token who's item to fetch Auth for
15
+ # account_ids - Specific account ids to fetch numbers for (optional)
16
+ # options - Additional options to merge into API request
17
+ #
18
+ # Returns a parsed JSON of Auth information
19
+ def get(access_token, account_ids: nil, options: nil)
20
+ options_payload = {}
21
+ options_payload[:account_ids] = account_ids unless account_ids.nil?
22
+ options_payload = options_payload.merge(options) unless options.nil?
23
+
24
+ payload = { access_token: access_token,
25
+ options: options_payload }
26
+ @client.post_with_auth('auth/get', payload)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,18 @@
1
+ module Plaid
2
+ # Public: Class used to call the Categories product.
3
+ class Categories
4
+ def initialize(client)
5
+ @client = client
6
+ end
7
+
8
+ # Public: Get information about all Plaid categories
9
+ #
10
+ # Does a POST /categories/get call to retrieve a list of all categories.
11
+ #
12
+ # Returns a parsed JSON of a list of categories
13
+ def get
14
+ payload = {}
15
+ @client.post('categories/get', payload)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ module Plaid
2
+ # Public: Class used to call the CreditDetails product.
3
+ class CreditDetails
4
+ def initialize(client)
5
+ @client = client
6
+ end
7
+
8
+ # Public: Get information about all available credit_details
9
+ #
10
+ # Does a POST /credit_details/get call which fetches credit details associated with
11
+ # and access_token's item
12
+ #
13
+ # access_token - access_token who's item to fetch credit_details for
14
+ #
15
+ # Returns a parsed JSON of credit_details information
16
+ def get(access_token)
17
+ payload = { access_token: access_token }
18
+ @client.post_with_auth('credit_details/get', payload)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ module Plaid
2
+ # Public: Class used to call the Identity product.
3
+ class Identity
4
+ def initialize(client)
5
+ @client = client
6
+ end
7
+
8
+ # Public: Get Identity information
9
+ #
10
+ # Does a POST /identity/get call to retrieve all info for a given access_token's item
11
+ #
12
+ # access_token - access_token who's item to fetch Identity data for
13
+ #
14
+ # Returns a parsed JSON of Identity information
15
+ def get(access_token)
16
+ payload = { access_token: access_token }
17
+ @client.post_with_auth('identity/get', payload)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module Plaid
2
+ # Public: Class used to call the Income product.
3
+ class Income
4
+ def initialize(client)
5
+ @client = client
6
+ end
7
+
8
+ # Public: Get information about user incomes
9
+ #
10
+ # Does a POST /income/get call which returns income info for an access_tokeni's item
11
+ #
12
+ # access_token - access_token who's item to fetch income for
13
+ #
14
+ # Returns a parsed JSON of income information
15
+ def get(access_token)
16
+ payload = { access_token: access_token }
17
+ @client.post_with_auth('income/get', payload)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,51 @@
1
+ module Plaid
2
+ # Public: Class used to call the Institutions product.
3
+ class Institutions
4
+ def initialize(client)
5
+ @client = client
6
+ end
7
+
8
+ # Public: Get information about Plaid institutions
9
+ #
10
+ # Does a POST /institutions/get call pulls a list of supported Plaid institutions
11
+ # with the information for each institution
12
+ #
13
+ # count - Amount of institutions to pull
14
+ # offset - Offset to start pulling institutions
15
+ #
16
+ # Returns a parsed JSON of listed institution information
17
+ def get(count:, offset:)
18
+ payload = { count: count,
19
+ offset: offset }
20
+ @client.post_with_auth('institutions/get', payload)
21
+ end
22
+
23
+ # Public: Get information about a Plaid institution by ID
24
+ #
25
+ # Does a POST /institutions/get_by_id call which allows you to pull
26
+ # information for an institution by ID
27
+ #
28
+ # institution_id - Specific institution id to fetch information for
29
+ #
30
+ # Returns a parsed JSON of institution info for your institution id
31
+ def get_by_id(institution_id)
32
+ payload = { institution_id: institution_id }
33
+ @client.post_with_public_key('institutions/get_by_id', payload)
34
+ end
35
+
36
+ # Public: Get information about all available institutions matching your query
37
+ #
38
+ # Does a POST /institutions/search call which allows you to pull a list of institutions
39
+ # using a query parameter
40
+ #
41
+ # query - Search query to attempt to match institutions to
42
+ # producs - Product supported filter (optional)
43
+ #
44
+ # Returns a parsed JSON listing institution information
45
+ def search(query, products = nil)
46
+ payload = { query: query,
47
+ products: products }
48
+ @client.post_with_public_key('institutions/search', payload)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,230 @@
1
+ module Plaid
2
+ # Public: Class used to call the AccessToken sub-product.
3
+ class AccessToken
4
+ def initialize(client)
5
+ @client = client
6
+ end
7
+
8
+ # Public: Rotate your access_token, keeping it attached to the item
9
+ #
10
+ # Does a POST /item/access_token/invalidate call which will give you a new access_token
11
+ # allowing you to rotate access_tokens
12
+ #
13
+ # access_token - access_token to invalidate and rotate
14
+ #
15
+ # Returns a parsed JSON with the new access_token and request id
16
+ def invalidate(access_token)
17
+ payload = { access_token: access_token }
18
+ @client.post_with_auth('item/access_token/invalidate', payload)
19
+ end
20
+
21
+ # Public: Generate a new API access_token for a legacy access_token
22
+ #
23
+ # Does a POST /item/access_token/update_version call which will give you
24
+ # an access_token for the new API.
25
+ #
26
+ # access_token_v1 - legacy access_token
27
+ #
28
+ # Returns a parsed JSON with the new access_token and request id
29
+ def update_version(access_token_v1)
30
+ payload = { access_token_v1: access_token_v1 }
31
+ @client.post_with_auth('item/access_token/update_version', payload)
32
+ end
33
+ end
34
+
35
+ # Public: Class used to call the Credentials sub-product.
36
+ class Credentials
37
+ def initialize(client)
38
+ @client = client
39
+ end
40
+
41
+ # Public: Update credentials for an access_token.
42
+ #
43
+ # Does a POST /item/credentials/update call which is used to update credentials
44
+ # if the credentials become no longer valid
45
+ #
46
+ # access_token - access_token who's item to update credentials for
47
+ # credentials - New credentials
48
+ #
49
+ # Returns a parsed JSON of either an ItemStatus or MFA response
50
+ def update(access_token, credentials)
51
+ payload = { access_token: access_token,
52
+ credentials: credentials }
53
+ @client.post_with_auth('item/credentials/update', payload)
54
+ end
55
+ end
56
+
57
+ # Public: Class used to call the PublicToken sub-product
58
+ class PublicToken
59
+ def initialize(client)
60
+ @client = client
61
+ end
62
+
63
+ # Public: Creates a public token from an access_token.
64
+ #
65
+ # Does a POST /item/public_token/create call which can be used to initialize Link
66
+ # in update mode
67
+ #
68
+ # access_token - access_token to create a public token for
69
+ #
70
+ # Returns a parsed JSON containing a public token and token info
71
+ def create(access_token)
72
+ payload = { access_token: access_token }
73
+ @client.post_with_auth('item/public_token/create', payload)
74
+ end
75
+
76
+ # Public: Exchange a public token for an access_token
77
+ #
78
+ # Does a POST /item/public_token/exchange call helps you exchange a public token
79
+ # (possibly from Plaid Link) for an access_token you can use in the rest of your app
80
+ #
81
+ # public_token - Public token to get an access_token from
82
+ #
83
+ # Returns a parsed JSON with an access_token and request id
84
+ def exchange(public_token)
85
+ payload = { public_token: public_token }
86
+ @client.post_with_auth('item/public_token/exchange', payload)
87
+ end
88
+ end
89
+
90
+ # Public: Class used to call the Webhook sub-product
91
+ class Webhook
92
+ def initialize(client)
93
+ @client = client
94
+ end
95
+
96
+ # Public: Update webhook for an access_token
97
+ #
98
+ # Does a POST /item/webhook/update call which is used to update webhook
99
+ # for a particular access_token, webhooks are used to be notified when
100
+ # transactions for an item are updated and ready
101
+ #
102
+ # access_token - access_token who's item to update webhood for
103
+ # webhook - a new webhook link
104
+ #
105
+ # Returns a parsed JSON of either an ItemStatus or MFA response
106
+ def update(access_token, webhook)
107
+ payload = { access_token: access_token,
108
+ webhook: webhook }
109
+ @client.post_with_auth('item/webhook/update', payload)
110
+ end
111
+ end
112
+
113
+ # Public: Class used to call the Item product.
114
+ class Item
115
+ # Public: Memoized class instance to make requests from Plaid::AccessToken
116
+ def access_token
117
+ @access_token ||= Plaid::AccessToken.new(@client)
118
+ end
119
+
120
+ # Public: Memoized class instance to make requests from Plaid::Credentials
121
+ def credentials
122
+ @credentials ||= Plaid::Credentials.new(@client)
123
+ end
124
+
125
+ # Public: Memoized class instance to make requests from Plaid::PublicToken
126
+ def public_token
127
+ @public_token ||= Plaid::PublicToken.new(@client)
128
+ end
129
+
130
+ # Public: Memoized class instance to make requests from Plaid::Webhook
131
+ def webhook
132
+ @webhook ||= Plaid::Webhook.new(@client)
133
+ end
134
+
135
+ def initialize(client)
136
+ @client = client
137
+ end
138
+
139
+ # Public: Creates an item.
140
+ #
141
+ # Does a POST /item/create call which attemps to create a new item for you
142
+ # possibly returning a success, error, or multi-factor authentication response
143
+ #
144
+ # credentials - Institution credentials to create item with
145
+ # institution_id - Institution ID to create item with
146
+ # initial_products - Initial products to create the item with i.e. ['transactions']
147
+ # transactions_start_date - date at which to begin the item's initial transaction pull
148
+ # (optional)
149
+ # transactions_end_date - date at which to end the item's initial transaction pull
150
+ # (optional)
151
+ # transactions_await_results - if true, the initial transaction pull will be performed
152
+ # synchronously (optional)
153
+ # webhook - webhook to associate with the item (optional)
154
+ # options - Additional options to merge into API request
155
+ #
156
+ # Returns a parsed JSON of item info including access_token and ItemStatus or
157
+ # MFA response or error
158
+ def create(credentials:,
159
+ institution_id:,
160
+ initial_products:,
161
+ transactions_start_date: nil,
162
+ transactions_end_date: nil,
163
+ transactions_await_results: nil,
164
+ webhook: nil,
165
+ options: nil)
166
+
167
+ transactions_options = {}
168
+ unless transactions_start_date.nil?
169
+ transactions_options[:start_date] = Plaid.convert_to_date_string(transactions_start_date)
170
+ end
171
+ unless transactions_end_date.nil?
172
+ transactions_options[:end_date] = Plaid.convert_to_date_string(transactions_end_date)
173
+ end
174
+ unless transactions_await_results.nil?
175
+ transactions_options[:await_results] = transactions_await_results
176
+ end
177
+
178
+ options_payload = {}
179
+ options_payload[:transactions] = transactions_options if transactions_options != {}
180
+ options_payload[:webhook] = webhook unless webhook.nil?
181
+ options_payload = options_payload.merge(options) unless options.nil?
182
+
183
+ payload = { credentials: credentials,
184
+ institution_id: institution_id,
185
+ initial_products: initial_products,
186
+ options: options_payload }
187
+ @client.post_with_auth('item/create', payload)
188
+ end
189
+
190
+ # Public: Submit an MFA step.
191
+ #
192
+ # Does a POST /item/mfa call which gives you the ability to response to an MFA
193
+ #
194
+ # access_token - To submit MFA step for
195
+ # mfa_type - The MFA type indicated in the MFA response
196
+ # responses - List of answers/responses to MFA
197
+ #
198
+ # Returns a parsed JSON of ItemStatus or another MFA step
199
+ def mfa(access_token, mfa_type, responses)
200
+ payload = { access_token: access_token,
201
+ mfa_type: mfa_type,
202
+ responses: responses }
203
+ @client.post_with_auth('item/mfa', payload)
204
+ end
205
+
206
+ # Public: Get information about an item
207
+ #
208
+ # Does a POST /item/get call which returns information about an item or ItemStatus
209
+ #
210
+ # access_token - access_token who's item to fetch status for
211
+ #
212
+ # Returns a parsed JSON of item information
213
+ def get(access_token)
214
+ payload = { access_token: access_token }
215
+ @client.post_with_auth('item/get', payload)
216
+ end
217
+
218
+ # Public: Deletes an item
219
+ #
220
+ # Does a POST /item/delete call which is used to delete an item
221
+ #
222
+ # access_token - access_token who's item to delete
223
+ #
224
+ # Returns a parsed JSON of delete result
225
+ def delete(access_token)
226
+ payload = { access_token: access_token }
227
+ @client.post_with_auth('item/delete', payload)
228
+ end
229
+ end
230
+ end