Class: Plaid::Transfer::Intent::Client
- Inherits:
-
Object
- Object
- Plaid::Transfer::Intent::Client
- Defined in:
- lib/plaid/transfer/intent/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Plaid::Types::TransferIntentCreateResponse
Use the
/transfer/intent/createendpoint to generate a transfer intent object and invoke the Transfer UI. -
#get(request_options: {}, **params) ⇒ Plaid::Types::TransferIntentGetResponse
Use the
/transfer/intent/getendpoint to retrieve more information about a transfer intent. - #initialize(client:) ⇒ void constructor
Constructor Details
#initialize(client:) ⇒ void
10 11 12 |
# File 'lib/plaid/transfer/intent/client.rb', line 10 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Plaid::Types::TransferIntentCreateResponse
Use the /transfer/intent/create endpoint to generate a transfer intent object and invoke the Transfer UI.
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 68 69 |
# File 'lib/plaid/transfer/intent/client.rb', line 35 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: "transfer/intent/create", body: Plaid::Transfer::Intent::Types::TransferIntentCreateRequest.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::TransferIntentCreateResponse.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::TransferIntentGetResponse
Use the /transfer/intent/get endpoint to retrieve more information about a transfer intent.
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 112 113 114 115 116 117 118 119 |
# File 'lib/plaid/transfer/intent/client.rb', line 85 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: "transfer/intent/get", body: Plaid::Transfer::Intent::Types::TransferIntentGetRequest.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::TransferIntentGetResponse.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 |