Class: Plaid::Processor::Client
- Inherits:
-
Object
- Object
- Plaid::Processor::Client
- Defined in:
- lib/plaid/processor/client.rb
Instance Method Summary collapse
-
#create_apex_processor_token(request_options: {}, **params) ⇒ Plaid::Types::ProcessorTokenCreateResponse
Used to create a token suitable for sending to Apex to enable Plaid-Apex integrations.
-
#create_bank_transfer(request_options: {}, **params) ⇒ Plaid::Types::ProcessorBankTransferCreateResponse
Use the
/processor/bank_transfer/createendpoint to initiate a new bank transfer as a processor. -
#create_stripe_bank_account_token(request_options: {}, **params) ⇒ Plaid::Types::ProcessorStripeBankAccountTokenCreateResponse
Used to create a token suitable for sending to Stripe to enable Plaid-Stripe integrations.
-
#create_token(request_options: {}, **params) ⇒ Plaid::Types::ProcessorTokenCreateResponse
Used to create a token suitable for sending to one of Plaid's partners to enable integrations.
-
#get_account(request_options: {}, **params) ⇒ Plaid::Types::ProcessorAccountGetResponse
This endpoint returns the account associated with a given processor token.
-
#get_auth(request_options: {}, **params) ⇒ Plaid::Types::ProcessorAuthGetResponse
The
/processor/auth/getendpoint returns the bank account and bank identification number (such as the routing number, for US accounts), for a checking, savings, or cash management account that''s associated with a givenprocessor_token. -
#get_balance(request_options: {}, **params) ⇒ Plaid::Types::ProcessorBalanceGetResponse
The
/processor/balance/getendpoint returns the real-time balance for the account associated with the processor token. -
#get_identity(request_options: {}, **params) ⇒ Plaid::Types::ProcessorIdentityGetResponse
The
/processor/identity/getendpoint allows you to retrieve various account holder information on file with the financial institution, including names, emails, phone numbers, and addresses. -
#get_investment_auth(request_options: {}, **params) ⇒ Plaid::Types::ProcessorInvestmentsAuthGetResponse
The
/processor/investments/auth/getendpoint allows you to retrieve information about the account authorized by a processor token, including account numbers, account owners, holdings, and data provenance information. -
#get_investment_holdings(request_options: {}, **params) ⇒ Plaid::Types::ProcessorInvestmentsHoldingsGetResponse
This endpoint returns the stock position data of the account associated with a given processor token.
-
#get_investment_transactions(request_options: {}, **params) ⇒ Plaid::Internal::OffsetItemIterator
The
/processor/investments/transactions/getendpoint allows developers to retrieve up to 24 months of user-authorized transaction data for the investment account associated with the processor token. -
#get_liabilities(request_options: {}, **params) ⇒ Plaid::Types::ProcessorLiabilitiesGetResponse
The
/processor/liabilities/getendpoint returns various details about a loan or credit account. -
#get_recurring_transactions(request_options: {}, **params) ⇒ Plaid::Types::ProcessorTransactionsRecurringGetResponse
The
/processor/transactions/recurring/getendpoint allows developers to receive a summary of the recurring outflow and inflow streams (expenses and deposits) from a user's checking, savings or credit card accounts. -
#get_token_permissions(request_options: {}, **params) ⇒ Plaid::Types::ProcessorTokenPermissionsGetResponse
Used to get a processor token's product permissions.
-
#get_transactions(request_options: {}, **params) ⇒ Plaid::Internal::OffsetItemIterator
The
/processor/transactions/getendpoint allows developers to receive user-authorized transaction data for credit, depository, and loan-type accounts (coverage may be limited). - #initialize(client:) ⇒ void constructor
-
#match_identity(request_options: {}, **params) ⇒ Plaid::Types::ProcessorIdentityMatchResponse
The
/processor/identity/matchendpoint generates a match score, which indicates how well the provided identity data matches the identity information on file with the account holder's financial institution. -
#refresh_transactions(request_options: {}, **params) ⇒ Plaid::Types::ProcessorTransactionsRefreshResponse
/processor/transactions/refreshis an optional endpoint for users of the Transactions product. -
#set_token_permissions(request_options: {}, **params) ⇒ Plaid::Types::ProcessorTokenPermissionsSetResponse
Used to control a processor's access to products on the given processor token.
- #signal ⇒ Plaid::Signal::Client
-
#sync_transactions(request_options: {}, **params) ⇒ Plaid::Types::ProcessorTransactionsSyncResponse
The
/processor/transactions/syncendpoint retrieves transactions associated with an Item and can fetch updates using a cursor to track which updates have already been seen. -
#update_token_webhook(request_options: {}, **params) ⇒ Plaid::Types::ProcessorTokenWebhookUpdateResponse
This endpoint allows you, the processor, to update the webhook URL associated with a processor token.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/plaid/processor/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#create_apex_processor_token(request_options: {}, **params) ⇒ Plaid::Types::ProcessorTokenCreateResponse
Used to create a token suitable for sending to Apex to enable Plaid-Apex integrations.
1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 |
# File 'lib/plaid/processor/client.rb', line 1234 def create_apex_processor_token(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/apex/processor_token/create", body: Plaid::Processor::Types::ProcessorApexProcessorTokenCreateRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorTokenCreateResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#create_bank_transfer(request_options: {}, **params) ⇒ Plaid::Types::ProcessorBankTransferCreateResponse
Use the /processor/bank_transfer/create endpoint to initiate a new bank transfer as a processor
679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 |
# File 'lib/plaid/processor/client.rb', line 679 def create_bank_transfer(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/bank_transfer/create", body: Plaid::Processor::Types::ProcessorBankTransferCreateRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorBankTransferCreateResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#create_stripe_bank_account_token(request_options: {}, **params) ⇒ Plaid::Types::ProcessorStripeBankAccountTokenCreateResponse
Used to create a token suitable for sending to Stripe to enable Plaid-Stripe integrations. For a detailed guide on integrating Stripe, see Add Stripe to your app.
Note that the Stripe bank account token is a one-time use token. To store bank account information for later
use, you can use a Stripe customer object and create an associated bank account from the token, or you can use a
Stripe Custom account and create an associated external bank account from the token. This bank account
information should work indefinitely, unless the user's bank account information changes or they revoke Plaid's
permissions to access their account. Stripe bank account information cannot be modified once the bank account
token has been created. If you ever need to change the bank account details used by Stripe for a specific
customer, have the user go through Link again and create a new bank account token from the new access_token.
To revoke a bank account token, the entire underlying access token must be revoked using /item/remove.
1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 |
# File 'lib/plaid/processor/client.rb', line 1181 def create_stripe_bank_account_token(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/stripe/bank_account_token/create", body: Plaid::Processor::Types::ProcessorStripeBankAccountTokenCreateRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorStripeBankAccountTokenCreateResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#create_token(request_options: {}, **params) ⇒ Plaid::Types::ProcessorTokenCreateResponse
Used to create a token suitable for sending to one of Plaid's partners to enable integrations. To create a
Stripe bank account token (btok_...), use /processor/stripe/bank_account_token/create. If using multiple
processors, multiple different processor tokens can be created for a single access token. Once created, a
processor token for a given Item can be modified by calling /processor/token/permissions/set. To revoke the
processor's access, the entire Item must be deleted by calling /item/remove.
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 |
# File 'lib/plaid/processor/client.rb', line 955 def create_token(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/token/create", body: Plaid::Processor::Types::ProcessorTokenCreateRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorTokenCreateResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#get_account(request_options: {}, **params) ⇒ Plaid::Types::ProcessorAccountGetResponse
This endpoint returns the account associated with a given processor token.
This endpoint retrieves cached information, rather than extracting fresh information from the institution. As a
result, the account balance returned may not be up-to-date; for real-time balance information, use
/processor/balance/get instead. Note that some information is nullable.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/plaid/processor/client.rb', line 87 def get_account(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/account/get", body: Plaid::Processor::Types::ProcessorAccountGetRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorAccountGetResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#get_auth(request_options: {}, **params) ⇒ Plaid::Types::ProcessorAuthGetResponse
The /processor/auth/get endpoint returns the bank account and bank identification number (such as the routing
number, for US accounts), for a checking, savings, or cash management account that''s associated with a given
processor_token. The endpoint also returns high-level account data and balances when available.
Versioning note: API versions 2019-05-29 and earlier use a different schema for the numbers object returned by
this endpoint. For details, see Plaid API
versioning.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/plaid/processor/client.rb', line 33 def get_auth(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/auth/get", body: Plaid::Processor::Types::ProcessorAuthGetRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorAuthGetResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#get_balance(request_options: {}, **params) ⇒ Plaid::Types::ProcessorBalanceGetResponse
The /processor/balance/get endpoint returns the real-time balance for the account associated with the
processor token. While other endpoints may return a balance object, only /processor/balance/get forces the
available and current balance fields to be refreshed rather than cached.
897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 |
# File 'lib/plaid/processor/client.rb', line 897 def get_balance(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/balance/get", body: Plaid::Processor::Types::ProcessorBalanceGetRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorBalanceGetResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#get_identity(request_options: {}, **params) ⇒ Plaid::Types::ProcessorIdentityGetResponse
The /processor/identity/get endpoint allows you to retrieve various account holder information on file with
the financial institution, including names, emails, phone numbers, and addresses.
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 |
# File 'lib/plaid/processor/client.rb', line 791 def get_identity(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/identity/get", body: Plaid::Processor::Types::ProcessorIdentityGetRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorIdentityGetResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#get_investment_auth(request_options: {}, **params) ⇒ Plaid::Types::ProcessorInvestmentsAuthGetResponse
The /processor/investments/auth/get endpoint allows you to retrieve information about the account
authorized by a processor token, including account numbers, account owners, holdings, and data provenance
information.
To receive Investments Auth webhooks for a processor token, set its webhook URL via the
/processor/token/webhook/update
endpoint.
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/plaid/processor/client.rb', line 193 def get_investment_auth(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/investments/auth/get", body: Plaid::Processor::Types::ProcessorInvestmentsAuthGetRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorInvestmentsAuthGetResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#get_investment_holdings(request_options: {}, **params) ⇒ Plaid::Types::ProcessorInvestmentsHoldingsGetResponse
This endpoint returns the stock position data of the account associated with a given processor token.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/plaid/processor/client.rb', line 137 def get_investment_holdings(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/investments/holdings/get", body: Plaid::Processor::Types::ProcessorInvestmentsHoldingsGetRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorInvestmentsHoldingsGetResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#get_investment_transactions(request_options: {}, **params) ⇒ Plaid::Internal::OffsetItemIterator
The /processor/investments/transactions/get endpoint allows developers to retrieve up to 24 months of
user-authorized transaction data for the investment account associated with the processor token.
Transactions are returned in reverse-chronological order, and the sequence of transaction ordering is stable and will not shift.
Due to the potentially large number of investment transactions associated with the account, results are
paginated. Manipulate the count and offset parameters in conjunction with the total_investment_transactions
response body field to fetch all available investment transactions.
Note that Investments does not have a webhook to indicate when initial transaction data has loaded (unless you
use the async_update option). Instead, if transactions data is not ready when
/processor/investments/transactions/get is first called, Plaid will wait for the data. For this reason,
calling /processor/investments/transactions/get immediately after Link may take up to one to two minutes to
return.
Data returned by the asynchronous investments extraction flow (when async_update is set to true) may not be
immediately available to /processor/investments/transactions/get. To be alerted when the data is ready to be
fetched, listen for the HISTORICAL_UPDATE webhook. If no investments history is ready when
/processor/investments/transactions/get is called, it will return a PRODUCT_NOT_READY error.
To receive Investments Transactions webhooks for a processor token, set its webhook URL via the
/processor/token/webhook/update
endpoint.
Returns a Plaid::Internal::OffsetItemIterator that yields each Plaid::Types::InvestmentTransaction in the
investment_transactions field of every page, requesting pages as they are needed. Call pages on it to get
each page as a Plaid::Types::ProcessorInvestmentsTransactionsGetResponse, including its other fields.
No request is sent by this call. The first page is requested when you start iterating (or call
load_first_page), so an API error is raised by the loop (or by load_first_page), not by this call.
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/plaid/processor/client.rb', line 277 def get_investment_transactions(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) Plaid::Internal::OffsetItemIterator.new( initial_page: Plaid::Internal::Types::Utils.normalize_keys(params[:options].to_h)[:offset], item_field: :investment_transactions, has_next_field: nil, step: true ) do |next_page| params[:options] = Plaid::Internal::Types::Utils.normalize_keys(params[:options].to_h).merge(offset: next_page) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/investments/transactions/get", body: Plaid::Processor::Types::ProcessorInvestmentsTransactionsGetRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin parsed_response = (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorInvestmentsTransactionsGetResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end [parsed_response, response] else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end end |
#get_liabilities(request_options: {}, **params) ⇒ Plaid::Types::ProcessorLiabilitiesGetResponse
The /processor/liabilities/get endpoint returns various details about a loan or credit account. Liabilities
data is available primarily for US financial institutions, with some limited coverage of Canadian institutions.
Currently supported account types are account type credit with account subtype credit card or paypal, and
account type loan with account subtype student or mortgage.
The types of information returned by Liabilities can include balances and due dates, loan terms, and account
details such as original loan amount and guarantor. Data is refreshed approximately once per day; the latest
data can be retrieved by calling /processor/liabilities/get.
Note: This request may take some time to complete if liabilities was not specified as an initial product when
creating the processor token. This is because Plaid must communicate directly with the institution to retrieve
the additional data.
740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 |
# File 'lib/plaid/processor/client.rb', line 740 def get_liabilities(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/liabilities/get", body: Plaid::Processor::Types::ProcessorLiabilitiesGetRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorLiabilitiesGetResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#get_recurring_transactions(request_options: {}, **params) ⇒ Plaid::Types::ProcessorTransactionsRecurringGetResponse
The /processor/transactions/recurring/get endpoint allows developers to receive a summary of the recurring
outflow and inflow streams (expenses and deposits) from a user's checking, savings or credit card accounts.
Additionally, Plaid provides key insights about each recurring stream including the category, merchant, last
amount, and more. Developers can use these insights to build tools and experiences that help their users better
manage cash flow, monitor subscriptions, reduce spend, and stay on track with bill payments.
This endpoint is offered as an add-on to Transactions. To request access to this endpoint, submit a product access request or contact your Plaid account manager.
This endpoint can only be called on a processor token that has already been initialized with Transactions
(either during Link, by specifying it in /link/token/create; or after Link, by calling
/processor/transactions/get or /processor/transactions/sync). Once all historical transactions have been
fetched, call /processor/transactions/recurring/get to receive the Recurring Transactions streams and
subscribe to the
RECURRING_TRANSACTIONS_UPDATE
webhook. To know when historical transactions have been fetched, if you are using /processor/transactions/sync
listen for the
SYNC_UPDATES_AVAILABLE
webhook and check that the historical_update_complete field in the payload is true. If using
/processor/transactions/get, listen for the
HISTORICAL_UPDATE webhook.
After the initial call, you can call the /processor/transactions/recurring/get endpoint at any point in the
future to retrieve the latest summary of recurring streams. Listen to the
RECURRING_TRANSACTIONS_UPDATE
webhook to be notified when new updates are available.
To receive Transactions webhooks for a processor token, set its webhook URL via the
/processor/token/webhook/update
endpoint.
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 |
# File 'lib/plaid/processor/client.rb', line 618 def get_recurring_transactions(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/transactions/recurring/get", body: Plaid::Processor::Types::ProcessorTransactionsRecurringGetRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorTransactionsRecurringGetResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#get_token_permissions(request_options: {}, **params) ⇒ Plaid::Types::ProcessorTokenPermissionsGetResponse
Used to get a processor token's product permissions. The products field will be an empty list if the processor
can access all available products.
1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 |
# File 'lib/plaid/processor/client.rb', line 1062 def (request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/token/permissions/get", body: Plaid::Processor::Types::ProcessorTokenPermissionsGetRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorTokenPermissionsGetResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#get_transactions(request_options: {}, **params) ⇒ Plaid::Internal::OffsetItemIterator
The /processor/transactions/get endpoint allows developers to receive user-authorized transaction data for
credit, depository, and loan-type accounts (coverage may be limited). Transaction data is standardized across
financial institutions, and in many cases transactions are linked to a clean name, entity type, location, and
category. Similarly, account data is standardized and returned with a clean name, number, balance, and other
meta information where available.
Transactions are returned in reverse-chronological order, and the sequence of transaction ordering is stable and
will not shift. Transactions are not immutable and can also be removed altogether by the institution; a removed
transaction will no longer appear in /processor/transactions/get. For more details, see Pending and posted
transactions.
Due to the potentially large number of transactions associated with a processor token, results are paginated.
Manipulate the count and offset parameters in conjunction with the total_transactions response body field
to fetch all available transactions.
Data returned by /processor/transactions/get will be the data available for the processor token as of the most
recent successful check for new transactions. Plaid typically checks for new data multiple times a day, but
these checks may occur less frequently, such as once a day, depending on the institution. To force Plaid to
check for new transactions, you can use the /processor/transactions/refresh endpoint.
Note that data may not be immediately available to /processor/transactions/get. Plaid will begin to prepare
transactions data upon Item link, if Link was initialized with transactions, or upon the first call to
/processor/transactions/get, if it wasn't. If no transaction history is ready when
/processor/transactions/get is called, it will return a PRODUCT_NOT_READY error.
To receive Transactions webhooks for a processor token, set its webhook URL via the
/processor/token/webhook/update
endpoint.
Returns a Plaid::Internal::OffsetItemIterator that yields each Plaid::Types::Transaction in the
transactions field of every page, requesting pages as they are needed. Call pages on it to get each page as
a Plaid::Types::ProcessorTransactionsGetResponse, including its other fields.
No request is sent by this call. The first page is requested when you start iterating (or call
load_first_page), so an API error is raised by the loop (or by load_first_page), not by this call.
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
# File 'lib/plaid/processor/client.rb', line 374 def get_transactions(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) Plaid::Internal::OffsetItemIterator.new( initial_page: Plaid::Internal::Types::Utils.normalize_keys(params[:options].to_h)[:offset], item_field: :transactions, has_next_field: nil, step: true ) do |next_page| params[:options] = Plaid::Internal::Types::Utils.normalize_keys(params[:options].to_h).merge(offset: next_page) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/transactions/get", body: Plaid::Processor::Types::ProcessorTransactionsGetRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin parsed_response = (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorTransactionsGetResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end [parsed_response, response] else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end end |
#match_identity(request_options: {}, **params) ⇒ Plaid::Types::ProcessorIdentityMatchResponse
The /processor/identity/match endpoint generates a match score, which indicates how well the provided identity
data matches the identity information on file with the account holder's financial institution.
Fields within the balances object will always be null when retrieved by /processor/identity/match. Instead,
use the /processor/balance/get endpoint to retrieve balance data.
845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 |
# File 'lib/plaid/processor/client.rb', line 845 def match_identity(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/identity/match", body: Plaid::Processor::Types::ProcessorIdentityMatchRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorIdentityMatchResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#refresh_transactions(request_options: {}, **params) ⇒ Plaid::Types::ProcessorTransactionsRefreshResponse
/processor/transactions/refresh is an optional endpoint for users of the Transactions product. It initiates an
on-demand extraction to fetch the newest transactions for a processor token. This on-demand extraction takes
place in addition to the periodic extractions that automatically occur one or more times per day for any
Transactions-enabled processor token. If changes to transactions are discovered after calling
/processor/transactions/refresh, Plaid will fire a webhook: for /processor/transactions/sync users,
SYNC_UPDATES_AVAILABLE will be
fired if there are any transactions updated, added, or removed. For users of both /processor/transactions/sync
and /processor/transactions/get,
TRANSACTIONS_REMOVED will be fired
if any removed transactions are detected, and
DEFAULT_UPDATE will be fired if any new
transactions are detected. New transactions can be fetched by calling /processor/transactions/get or
/processor/transactions/sync. Note that the /processor/transactions/refresh endpoint is not supported for
Capital One (ins_128026) non-depository accounts and will result in a PRODUCTS_NOT_SUPPORTED error if called
on an Item that contains only non-depository accounts from that institution.
As this endpoint triggers a synchronous request for fresh data, latency may be higher than for other Plaid endpoints (typically less than 10 seconds, but occasionally up to 30 seconds or more); if you encounter errors, you may find it necessary to adjust your timeout period when making requests.
/processor/transactions/refresh is offered as an add-on to Transactions and has a separate fee
model. To request access to this endpoint, submit
a product access request or contact your Plaid account manager.
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 |
# File 'lib/plaid/processor/client.rb', line 539 def refresh_transactions(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/transactions/refresh", body: Plaid::Processor::Types::ProcessorTransactionsRefreshRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorTransactionsRefreshResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#set_token_permissions(request_options: {}, **params) ⇒ Plaid::Types::ProcessorTokenPermissionsSetResponse
Used to control a processor's access to products on the given processor token. By default, a processor will have access to all available products on the corresponding item. To restrict access to a particular set of products, call this endpoint with the desired products. To restore access to all available products, call this endpoint with an empty list. This endpoint can be called multiple times as your needs and your processor's needs change.
1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 |
# File 'lib/plaid/processor/client.rb', line 1011 def (request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/token/permissions/set", body: Plaid::Processor::Types::ProcessorTokenPermissionsSetRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorTokenPermissionsSetResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#signal ⇒ Plaid::Signal::Client
1271 1272 1273 |
# File 'lib/plaid/processor/client.rb', line 1271 def signal @signal ||= Plaid::Processor::Signal::Client.new(client: @client) end |
#sync_transactions(request_options: {}, **params) ⇒ Plaid::Types::ProcessorTransactionsSyncResponse
The /processor/transactions/sync endpoint retrieves transactions associated with an Item and can fetch updates
using a cursor to track which updates have already been seen.
For important instructions on integrating with /processor/transactions/sync, see the Transactions integration
overview. If you are migrating from an existing
integration using /processor/transactions/get, see the Transactions Sync migration
guide.
This endpoint supports credit, depository, and loan-type accounts. For investments accounts, use
/processor/investments/transactions/get instead.
When retrieving paginated updates, track both the next_cursor from the latest response and the original cursor
from the first call in which has_more was true; if a call to /processor/transactions/sync fails when
retrieving a paginated update (e.g. due to the
TRANSACTIONS_SYNC_MUTATION_DURING_PAGINATION
error), the entire pagination request loop must be restarted beginning with the cursor for the first page of the
update, rather than retrying only the single request that failed.
If transactions data is not yet available for the Item, which can happen if the Item was not initialized with
transactions during the /link/token/create call or if /processor/transactions/sync was called within a few
seconds of Item creation, /processor/transactions/sync will return empty transactions arrays.
Plaid typically checks for new transactions data between one and four times per day, depending on the
institution. To find out when transactions were last updated for an Item, use the Item
Debugger or call /item/get; the
item.status.transactions.last_successful_update field will show the timestamp of the most recent successful
update. To force Plaid to check for new transactions, use the /processor/transactions/refresh endpoint.
To be alerted when new transactions are available, listen for the
SYNC_UPDATES_AVAILABLE webhook.
To receive Transactions webhooks for a processor token, set its webhook URL via the
/processor/token/webhook/update
endpoint.
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 |
# File 'lib/plaid/processor/client.rb', line 467 def sync_transactions(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/transactions/sync", body: Plaid::Processor::Types::ProcessorTransactionsSyncRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorTransactionsSyncResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#update_token_webhook(request_options: {}, **params) ⇒ Plaid::Types::ProcessorTokenWebhookUpdateResponse
This endpoint allows you, the processor, to update the webhook URL associated with a processor token. This
request triggers a WEBHOOK_UPDATE_ACKNOWLEDGED webhook to the newly specified webhook URL.
1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 |
# File 'lib/plaid/processor/client.rb', line 1116 def update_token_webhook(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "processor/token/webhook/update", body: Plaid::Processor::Types::ProcessorTokenWebhookUpdateRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::ProcessorTokenWebhookUpdateResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |