Class: BloomRemit2::Recipient
- Inherits:
-
Object
- Object
- BloomRemit2::Recipient
- Defined in:
- lib/bloom_remit2/recipient.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#deleted ⇒ Object
readonly
Returns the value of attribute deleted.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#first_name ⇒ Object
readonly
Returns the value of attribute first_name.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#last_name ⇒ Object
readonly
Returns the value of attribute last_name.
-
#mobile ⇒ Object
readonly
Returns the value of attribute mobile.
-
#province ⇒ Object
(also: #state)
readonly
Returns the value of attribute province.
-
#remittance_ids ⇒ Object
readonly
Returns the value of attribute remittance_ids.
-
#sender_id ⇒ Object
readonly
Returns the value of attribute sender_id.
Class Method Summary collapse
- .create(sender_id, recipient_hash) ⇒ Object
- .delete(sender_id, recipient_id) ⇒ Object
- .list(sender_id) ⇒ Object
- .retrieve(sender_id, recipient_id) ⇒ Object
- .update(sender_id, recipient_id, recipient_hash) ⇒ Object
Instance Method Summary collapse
-
#initialize(id, sender_id, first_name = nil, last_name = nil, email = nil, mobile = nil, address = nil, city = nil, province = nil, country = nil, remittance_ids = nil, deleted: false) ⇒ Recipient
constructor
A new instance of Recipient.
Constructor Details
#initialize(id, sender_id, first_name = nil, last_name = nil, email = nil, mobile = nil, address = nil, city = nil, province = nil, country = nil, remittance_ids = nil, deleted: false) ⇒ Recipient
Returns a new instance of Recipient.
66 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 |
# File 'lib/bloom_remit2/recipient.rb', line 66 def initialize( id, sender_id, first_name=nil, last_name=nil, email=nil, mobile=nil, address=nil, city=nil, province=nil, country=nil, remittance_ids=nil, deleted: false ) @id = id @sender_id = sender_id @first_name = first_name @last_name = last_name @email = email @mobile = mobile @address = address @city = city @province = province @country = country @remittance_ids = remittance_ids @deleted = deleted end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
63 64 65 |
# File 'lib/bloom_remit2/recipient.rb', line 63 def address @address end |
#city ⇒ Object (readonly)
Returns the value of attribute city.
63 64 65 |
# File 'lib/bloom_remit2/recipient.rb', line 63 def city @city end |
#country ⇒ Object (readonly)
Returns the value of attribute country.
63 64 65 |
# File 'lib/bloom_remit2/recipient.rb', line 63 def country @country end |
#deleted ⇒ Object (readonly)
Returns the value of attribute deleted.
63 64 65 |
# File 'lib/bloom_remit2/recipient.rb', line 63 def deleted @deleted end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
63 64 65 |
# File 'lib/bloom_remit2/recipient.rb', line 63 def email @email end |
#first_name ⇒ Object (readonly)
Returns the value of attribute first_name.
63 64 65 |
# File 'lib/bloom_remit2/recipient.rb', line 63 def first_name @first_name end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
63 64 65 |
# File 'lib/bloom_remit2/recipient.rb', line 63 def id @id end |
#last_name ⇒ Object (readonly)
Returns the value of attribute last_name.
63 64 65 |
# File 'lib/bloom_remit2/recipient.rb', line 63 def last_name @last_name end |
#mobile ⇒ Object (readonly)
Returns the value of attribute mobile.
63 64 65 |
# File 'lib/bloom_remit2/recipient.rb', line 63 def mobile @mobile end |
#province ⇒ Object (readonly) Also known as: state
Returns the value of attribute province.
63 64 65 |
# File 'lib/bloom_remit2/recipient.rb', line 63 def province @province end |
#remittance_ids ⇒ Object (readonly)
Returns the value of attribute remittance_ids.
63 64 65 |
# File 'lib/bloom_remit2/recipient.rb', line 63 def remittance_ids @remittance_ids end |
#sender_id ⇒ Object (readonly)
Returns the value of attribute sender_id.
63 64 65 |
# File 'lib/bloom_remit2/recipient.rb', line 63 def sender_id @sender_id end |
Class Method Details
.create(sender_id, recipient_hash) ⇒ Object
4 5 6 7 |
# File 'lib/bloom_remit2/recipient.rb', line 4 def create(sender_id, recipient_hash) recipient = Client.post(path(sender_id), recipient_hash) initialize_from_hash(recipient['recipient']) end |
.delete(sender_id, recipient_id) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bloom_remit2/recipient.rb', line 28 def delete(sender_id, recipient_id) = Client.delete("#{path(sender_id)}/#{recipient_id}").with_indifferent_access if [:success] == "We've successfully deleted that recipient." new( recipient_id, sender_id, deleted: true ) end end |
.list(sender_id) ⇒ Object
9 10 11 12 |
# File 'lib/bloom_remit2/recipient.rb', line 9 def list(sender_id) recipients = Client.get(path(sender_id)) recipients.map { |recipient| initialize_from_hash(recipient) } end |
.retrieve(sender_id, recipient_id) ⇒ Object
14 15 16 17 |
# File 'lib/bloom_remit2/recipient.rb', line 14 def retrieve(sender_id, recipient_id) recipient = Client.get("#{path(sender_id)}/#{recipient_id}") initialize_from_hash(recipient['recipient'], recipient['remittance_ids']) end |
.update(sender_id, recipient_id, recipient_hash) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/bloom_remit2/recipient.rb', line 19 def update(sender_id, recipient_id, recipient_hash) body = [] recipient_hash.each do |k, v| body << ["recipient[#{k.to_s.downcase}]", v] end recipient = Client.put("#{path(sender_id)}/#{recipient_id}", body) initialize_from_hash(recipient['recipient']) end |