Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ The Transfer object is created via the TransferWise website. You can go there an
# TransferWise Borderless Account
A Borderless Account is a "virtual" bank account that you can control via the TransferWise API, to send funds to external bank accounts (across borders), as well as download statements and view the current balance.


## Fund your transfer from your borderless account available balance.

```ruby
transfer = TransferWise::Transfer.fund(transfer.id, { type: 'BALANCE' })
```

## Borderless Accounts
https://api-docs.transferwise.com/v1/borderless-account/search-account-by-user-profile

Expand Down
5 changes: 4 additions & 1 deletion lib/transfer_wise/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ def self.handle_error(e, request_opts)

def self.handle_api_error(resp)
error_obj = parse(resp).with_indifferent_access
error_message = error_obj['error'].presence || error_obj['errors'].map{|e| e["message"]}.join(', ')
error_message = error_obj['error'].presence ||
error_obj['errors']&.map{|e| e["message"]}&.join(', ') ||
error_obj['errorCode'].presence

if TransferWise::STATUS_CLASS_MAPPING.include?(resp.code)
raise "TransferWise::#{TransferWise::STATUS_CLASS_MAPPING[resp.code]}".constantize.new(error_params(error_message, resp, error_obj))
else
Expand Down
6 changes: 5 additions & 1 deletion lib/transfer_wise/transfer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module TransferWise
class Transfer < APIResource
def self.fund(resource_id, params, opts = {})
response = TransferWise::Request.request(:post, "#{resource_url(resource_id)}/payments", params, opts)
convert_to_transfer_wise_object(response)
end
end
end
end
4 changes: 2 additions & 2 deletions lib/transfer_wise/transfer_wise_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module TransferWise
STATUS_CLASS_MAPPING = {
400 => "InvalidRequestError",
404 => "InvalidRequestError",
401 => "AuthenticationError"
401 => "AuthenticationError",
409 => "InvalidRequestError"
}

class TransferWiseError < StandardError
Expand Down Expand Up @@ -35,5 +36,4 @@ class InvalidRequestError < TransferWiseError

class ParseError < TransferWiseError
end

end