Class: BloomRemit2::Remittance
- Inherits:
-
Object
- Object
- BloomRemit2::Remittance
- Defined in:
- lib/bloom_remit2/remittance.rb
Instance Attribute Summary collapse
-
#account_name ⇒ Object
readonly
Returns the value of attribute account_name.
-
#account_number ⇒ Object
readonly
Returns the value of attribute account_number.
-
#client_external_id ⇒ Object
readonly
Returns the value of attribute client_external_id.
-
#dest_currency ⇒ Object
(also: #destination_currency)
readonly
Returns the value of attribute dest_currency.
-
#flat_fee_in_orig_currency ⇒ Object
(also: #flat_fee_in_origin_currency)
readonly
Returns the value of attribute flat_fee_in_orig_currency.
-
#forex_margin ⇒ Object
readonly
Returns the value of attribute forex_margin.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#orig_currency ⇒ Object
(also: #origin_currency)
readonly
Returns the value of attribute orig_currency.
-
#paid_in_orig_currency ⇒ Object
readonly
Returns the value of attribute paid_in_orig_currency.
-
#partner_id ⇒ Object
readonly
Returns the value of attribute partner_id.
-
#payout_method ⇒ Object
readonly
Returns the value of attribute payout_method.
-
#recipient ⇒ Object
readonly
Returns the value of attribute recipient.
-
#sender_id ⇒ Object
readonly
Returns the value of attribute sender_id.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#teller_id ⇒ Object
readonly
Returns the value of attribute teller_id.
Class Method Summary collapse
-
.cancel(sender_id, remittance_id) ⇒ Object
Cancel a remittance.
-
.execute(sender_id, remittance_hash, staging: false) ⇒ Object
Initiate a new money transfer by providing a recipient_id and remittance hash.
-
.list(sender_id) ⇒ Object
Show all remittances belonging to the given sender.
- .path(sender_id) ⇒ Object
- .path_with_id(sender_id, remittance_id) ⇒ Object
-
.retrieve(sender_id, remittance_id) ⇒ Object
Show information about a given remittance with their associated recipient.
Instance Method Summary collapse
-
#initialize(id, partner_id = nil, orig_currency = nil, dest_currency = nil, paid_in_orig_currency = nil, forex_margin = nil, flat_fee_in_orig_currency = nil, payout_method = nil, status = nil, account_name = nil, account_number = nil, teller_id = nil, sender_id = nil, client_external_id = nil, recipient: nil) ⇒ Remittance
constructor
A new instance of Remittance.
Constructor Details
#initialize(id, partner_id = nil, orig_currency = nil, dest_currency = nil, paid_in_orig_currency = nil, forex_margin = nil, flat_fee_in_orig_currency = nil, payout_method = nil, status = nil, account_name = nil, account_number = nil, teller_id = nil, sender_id = nil, client_external_id = nil, recipient: nil) ⇒ Remittance
Returns a new instance of Remittance.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/bloom_remit2/remittance.rb', line 117 def initialize( id, partner_id=nil, orig_currency=nil, dest_currency=nil, paid_in_orig_currency=nil, forex_margin=nil, flat_fee_in_orig_currency=nil, payout_method=nil, status=nil, account_name=nil, account_number=nil, teller_id=nil, sender_id=nil, client_external_id=nil, recipient: nil ) @id = id @partner_id = partner_id @orig_currency = orig_currency @dest_currency = dest_currency @paid_in_orig_currency = paid_in_orig_currency @forex_margin = forex_margin @flat_fee_in_orig_currency = flat_fee_in_orig_currency @payout_method = payout_method @status = status @account_name = account_name @account_number = account_number @teller_id = teller_id @sender_id = sender_id @client_external_id = client_external_id @recipient = recipient end |
Instance Attribute Details
#account_name ⇒ Object (readonly)
Returns the value of attribute account_name.
111 112 113 |
# File 'lib/bloom_remit2/remittance.rb', line 111 def account_name @account_name end |
#account_number ⇒ Object (readonly)
Returns the value of attribute account_number.
111 112 113 |
# File 'lib/bloom_remit2/remittance.rb', line 111 def account_number @account_number end |
#client_external_id ⇒ Object (readonly)
Returns the value of attribute client_external_id.
111 112 113 |
# File 'lib/bloom_remit2/remittance.rb', line 111 def client_external_id @client_external_id end |
#dest_currency ⇒ Object (readonly) Also known as: destination_currency
Returns the value of attribute dest_currency.
111 112 113 |
# File 'lib/bloom_remit2/remittance.rb', line 111 def dest_currency @dest_currency end |
#flat_fee_in_orig_currency ⇒ Object (readonly) Also known as: flat_fee_in_origin_currency
Returns the value of attribute flat_fee_in_orig_currency.
111 112 113 |
# File 'lib/bloom_remit2/remittance.rb', line 111 def flat_fee_in_orig_currency @flat_fee_in_orig_currency end |
#forex_margin ⇒ Object (readonly)
Returns the value of attribute forex_margin.
111 112 113 |
# File 'lib/bloom_remit2/remittance.rb', line 111 def forex_margin @forex_margin end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
111 112 113 |
# File 'lib/bloom_remit2/remittance.rb', line 111 def id @id end |
#orig_currency ⇒ Object (readonly) Also known as: origin_currency
Returns the value of attribute orig_currency.
111 112 113 |
# File 'lib/bloom_remit2/remittance.rb', line 111 def orig_currency @orig_currency end |
#paid_in_orig_currency ⇒ Object (readonly)
Returns the value of attribute paid_in_orig_currency.
111 112 113 |
# File 'lib/bloom_remit2/remittance.rb', line 111 def paid_in_orig_currency @paid_in_orig_currency end |
#partner_id ⇒ Object (readonly)
Returns the value of attribute partner_id.
111 112 113 |
# File 'lib/bloom_remit2/remittance.rb', line 111 def partner_id @partner_id end |
#payout_method ⇒ Object (readonly)
Returns the value of attribute payout_method.
111 112 113 |
# File 'lib/bloom_remit2/remittance.rb', line 111 def payout_method @payout_method end |
#recipient ⇒ Object (readonly)
Returns the value of attribute recipient.
111 112 113 |
# File 'lib/bloom_remit2/remittance.rb', line 111 def recipient @recipient end |
#sender_id ⇒ Object (readonly)
Returns the value of attribute sender_id.
111 112 113 |
# File 'lib/bloom_remit2/remittance.rb', line 111 def sender_id @sender_id end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
111 112 113 |
# File 'lib/bloom_remit2/remittance.rb', line 111 def status @status end |
#teller_id ⇒ Object (readonly)
Returns the value of attribute teller_id.
111 112 113 |
# File 'lib/bloom_remit2/remittance.rb', line 111 def teller_id @teller_id end |
Class Method Details
.cancel(sender_id, remittance_id) ⇒ Object
Cancel a remittance
Note that this changes the status of the remittance to ‘cancelled’ and refunds the partner credits used, but does not delete it from the database.
46 47 48 |
# File 'lib/bloom_remit2/remittance.rb', line 46 def cancel(sender_id, remittance_id) remittance = Client.delete(path_with_id(sender_id, remittance_id)) end |
.execute(sender_id, remittance_hash, staging: false) ⇒ Object
Initiate a new money transfer by providing a recipient_id and remittance hash
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bloom_remit2/remittance.rb', line 5 def execute(sender_id, remittance_hash, staging: false) result = Client.post(path(sender_id), remittance_hash, staging) remittance = result['remittance'].with_indifferent_access new( remittance[:id], remittance[:partner_id], remittance[:orig_currency], remittance[:dest_currency], remittance[:paid_in_orig_currency], remittance[:forex_margin], remittance[:flat_fee_in_orig_currency], remittance[:payout_method], remittance[:status], remittance[:account_name], remittance[:account_number], remittance[:teller_id], remittance[:sender_id], remittance[:client_external_id], recipient: Recipient.new( remittance[:recipient_id], remittance[:sender_id], nil, nil, nil, nil, nil, nil, nil, nil, nil ) ) end |
.list(sender_id) ⇒ Object
Show all remittances belonging to the given sender
54 55 56 57 |
# File 'lib/bloom_remit2/remittance.rb', line 54 def list(sender_id) remittances = Client.get(path(sender_id)) remittances['remittance_ids'].map { |id| new(id) } end |
.path(sender_id) ⇒ Object
102 103 104 |
# File 'lib/bloom_remit2/remittance.rb', line 102 def path(sender_id) "api/v1/partners/#{BloomRemit2.configuration.api_token}/senders/#{sender_id}/remittances" end |
.path_with_id(sender_id, remittance_id) ⇒ Object
106 107 108 |
# File 'lib/bloom_remit2/remittance.rb', line 106 def path_with_id(sender_id, remittance_id) "#{path(sender_id)}/#{remittance_id}" end |
.retrieve(sender_id, remittance_id) ⇒ Object
Show information about a given remittance with their associated recipient
All information about the given remittance and recipient are returned with this call. Important fields to note include status and receivable_in_dest_currency.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/bloom_remit2/remittance.rb', line 67 def retrieve(sender_id, remittance_id) result = Client.get(path_with_id(sender_id, remittance_id)).with_indifferent_access remittance = result['remittance'].with_indifferent_access recipient = result['recipient'].with_indifferent_access new( remittance[:id], remittance[:partner_id], remittance[:orig_currency], remittance[:dest_currency], remittance[:paid_in_orig_currency], remittance[:forex_margin], remittance[:flat_fee_in_orig_currency], remittance[:payout_method], remittance[:status], remittance[:account_name], remittance[:account_number], remittance[:teller_id], remittance[:sender_id], remittance[:client_external_id], recipient: Recipient.new( recipient[:id], recipient[:sender_id], recipient[:first_name], recipient[:last_name], recipient[:email], recipient[:mobile], recipient[:address], nil, nil, recipient[:country], nil ) ) end |