Class: Plaid::Wallet::Client
- Inherits:
-
Object
- Object
- Plaid::Wallet::Client
- Defined in:
- lib/plaid/wallet/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Plaid::Types::WalletCreateResponse
Create an e-wallet.
-
#execute_transaction(request_options: {}, **params) ⇒ Plaid::Types::WalletTransactionExecuteResponse
Execute a transaction using the specified e-wallet.
-
#get(request_options: {}, **params) ⇒ Plaid::Types::WalletGetResponse
Fetch an e-wallet.
-
#get_transaction(request_options: {}, **params) ⇒ Plaid::Types::WalletTransactionGetResponse
Fetch a specific e-wallet transaction.
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Plaid::Internal::CursorItemIterator
This endpoint lists all e-wallets in descending order of creation.
-
#list_transactions(request_options: {}, **params) ⇒ Plaid::Internal::CursorItemIterator
This endpoint lists the latest transactions of the specified e-wallet.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/plaid/wallet/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Plaid::Types::WalletCreateResponse
Create an e-wallet. The response is the newly created e-wallet object.
27 28 29 30 31 32 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 |
# File 'lib/plaid/wallet/client.rb', line 27 def create(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "wallet/create", body: Plaid::Wallet::Types::WalletCreateRequest.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::WalletCreateResponse.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 |
#execute_transaction(request_options: {}, **params) ⇒ Plaid::Types::WalletTransactionExecuteResponse
Execute a transaction using the specified e-wallet. Specify the e-wallet to debit from, the counterparty to credit to, the idempotency key to prevent duplicate transactions, the amount and reference for the transaction. Transactions will settle in seconds to several days, depending on the underlying payment rail.
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/plaid/wallet/client.rb', line 207 def execute_transaction(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "wallet/transaction/execute", body: Plaid::Wallet::Types::WalletTransactionExecuteRequest.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::WalletTransactionExecuteResponse.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(request_options: {}, **params) ⇒ Plaid::Types::WalletGetResponse
Fetch an e-wallet. The response includes the current balance.
77 78 79 80 81 82 83 84 85 86 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 |
# File 'lib/plaid/wallet/client.rb', line 77 def get(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "wallet/get", body: Plaid::Wallet::Types::WalletGetRequest.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::WalletGetResponse.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_transaction(request_options: {}, **params) ⇒ Plaid::Types::WalletTransactionGetResponse
Fetch a specific e-wallet transaction
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/plaid/wallet/client.rb', line 257 def get_transaction(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "wallet/transaction/get", body: Plaid::Wallet::Types::WalletTransactionGetRequest.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::WalletTransactionGetResponse.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 |
#list(request_options: {}, **params) ⇒ Plaid::Internal::CursorItemIterator
This endpoint lists all e-wallets in descending order of creation.
Returns a Plaid::Internal::CursorItemIterator that yields each Plaid::Types::Wallet in the wallets field
of every page, requesting pages as they are needed. Call pages on it to get each page as a
Plaid::Types::WalletListResponse, 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.
134 135 136 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 172 173 174 175 176 |
# File 'lib/plaid/wallet/client.rb', line 134 def list(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) Plaid::Internal::CursorItemIterator.new( cursor_field: :next_cursor, item_field: :wallets, initial_cursor: params[:cursor] ) do |next_cursor| params[:cursor] = next_cursor request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "wallet/list", body: Plaid::Wallet::Types::WalletListRequest.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::WalletListResponse.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 |
#list_transactions(request_options: {}, **params) ⇒ Plaid::Internal::CursorItemIterator
This endpoint lists the latest transactions of the specified e-wallet. Transactions are returned in descending
order by the created_at time.
Returns a Plaid::Internal::CursorItemIterator that yields each Plaid::Types::WalletTransaction 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::WalletTransactionListResponse, 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.
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# File 'lib/plaid/wallet/client.rb', line 315 def list_transactions(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) Plaid::Internal::CursorItemIterator.new( cursor_field: :next_cursor, item_field: :transactions, initial_cursor: params[:cursor] ) do |next_cursor| params[:cursor] = next_cursor request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "wallet/transaction/list", body: Plaid::Wallet::Types::WalletTransactionListRequest.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::WalletTransactionListResponse.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 |