Class: Plaid::Transfer::Ledger::Client
- Inherits:
-
Object
- Object
- Plaid::Transfer::Ledger::Client
- Defined in:
- lib/plaid/transfer/ledger/client.rb
Instance Method Summary collapse
-
#deposit(request_options: {}, **params) ⇒ Plaid::Types::TransferLedgerDepositResponse
Use the
/transfer/ledger/depositendpoint to deposit funds into Plaid Ledger. -
#distribute(request_options: {}, **params) ⇒ Plaid::Types::TransferLedgerDistributeResponse
Use the
/transfer/ledger/distributeendpoint to move available balance between ledgers, if you have multiple. -
#get(request_options: {}, **params) ⇒ Plaid::Types::TransferLedgerGetResponse
Use the
/transfer/ledger/getendpoint to view a balance on the ledger held with Plaid. - #initialize(client:) ⇒ void constructor
-
#list_events(request_options: {}, **params) ⇒ Plaid::Internal::OffsetItemIterator
Use the
/transfer/ledger/event/listendpoint to get a list of ledger events for a specific ledger based on specified filter criteria. -
#withdraw(request_options: {}, **params) ⇒ Plaid::Types::TransferLedgerWithdrawResponse
Use the
/transfer/ledger/withdrawendpoint to withdraw funds from a Plaid Ledger balance.
Constructor Details
#initialize(client:) ⇒ void
10 11 12 |
# File 'lib/plaid/transfer/ledger/client.rb', line 10 def initialize(client:) @client = client end |
Instance Method Details
#deposit(request_options: {}, **params) ⇒ Plaid::Types::TransferLedgerDepositResponse
Use the /transfer/ledger/deposit endpoint to deposit funds into Plaid Ledger.
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 |
# File 'lib/plaid/transfer/ledger/client.rb', line 139 def deposit(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/ledger/deposit", body: Plaid::Transfer::Ledger::Types::TransferLedgerDepositRequest.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::TransferLedgerDepositResponse.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 |
#distribute(request_options: {}, **params) ⇒ Plaid::Types::TransferLedgerDistributeResponse
Use the /transfer/ledger/distribute endpoint to move available balance between ledgers, if you have
multiple. If you're a platform, you can move funds between one of your ledgers and one of your customer's
ledgers.
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/ledger/client.rb', line 85 def distribute(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/ledger/distribute", body: Plaid::Transfer::Ledger::Types::TransferLedgerDistributeRequest.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::TransferLedgerDistributeResponse.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::TransferLedgerGetResponse
Use the /transfer/ledger/get endpoint to view a balance on the ledger held with Plaid.
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 62 |
# File 'lib/plaid/transfer/ledger/client.rb', line 28 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/ledger/get", body: Plaid::Transfer::Ledger::Types::TransferLedgerGetRequest.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::TransferLedgerGetResponse.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_events(request_options: {}, **params) ⇒ Plaid::Internal::OffsetItemIterator
Use the /transfer/ledger/event/list endpoint to get a list of ledger events for a specific ledger based on
specified filter criteria.
Returns a Plaid::Internal::OffsetItemIterator that yields each Plaid::Types::TransferLedgerEvent in the
ledger_events field of every page, requesting pages as they are needed. Call pages on it to get each page
as a Plaid::Types::TransferLedgerEventListResponse, 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.
251 252 253 254 255 256 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 292 293 294 |
# File 'lib/plaid/transfer/ledger/client.rb', line 251 def list_events(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) Plaid::Internal::OffsetItemIterator.new( initial_page: params[:offset], item_field: :ledger_events, has_next_field: nil, step: true ) do |next_page| params[:offset] = next_page request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "transfer/ledger/event/list", body: Plaid::Transfer::Ledger::Types::TransferLedgerEventListRequest.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::TransferLedgerEventListResponse.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 |
#withdraw(request_options: {}, **params) ⇒ Plaid::Types::TransferLedgerWithdrawResponse
Use the /transfer/ledger/withdraw endpoint to withdraw funds from a Plaid Ledger balance.
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/transfer/ledger/client.rb', line 193 def withdraw(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/ledger/withdraw", body: Plaid::Transfer::Ledger::Types::TransferLedgerWithdrawRequest.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::TransferLedgerWithdrawResponse.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 |