Class: PinPayment::Recipient
Instance Attribute Summary collapse
-
#bank_account ⇒ Object
readonly
Returns the value of attribute bank_account.
-
#bank_account_token ⇒ Object
readonly
Returns the value of attribute bank_account_token.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Class Method Summary collapse
-
.all ⇒ Array<PinPayment::Recipient>
Fetches all of your recipients using the pin API.
-
.create(recipient_data) ⇒ PinPayment::Recipient
Uses the pin API to create a recipient.
-
.find(token) ⇒ PinPayment::Recipient
Fetches a customer using the pin API.
-
.update(token, email, card_or_token = nil) ⇒ PinPayment::Recipient
Update a recipient using the pin API.
Instance Method Summary collapse
-
#update(email, account_or_token = nil) ⇒ PinPayment::Customer
Update a recipient using the pin API.
Methods inherited from Base
Constructor Details
This class inherits a constructor from PinPayment::Base
Instance Attribute Details
#bank_account ⇒ Object
Returns the value of attribute bank_account.
3 4 5 |
# File 'lib/pin_payment/recipient.rb', line 3 def bank_account @bank_account end |
#bank_account_token ⇒ Object
Returns the value of attribute bank_account_token.
3 4 5 |
# File 'lib/pin_payment/recipient.rb', line 3 def bank_account_token @bank_account_token end |
#email ⇒ Object
Returns the value of attribute email.
3 4 5 |
# File 'lib/pin_payment/recipient.rb', line 3 def email @email end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/pin_payment/recipient.rb', line 3 def name @name end |
#token ⇒ Object
Returns the value of attribute token.
3 4 5 |
# File 'lib/pin_payment/recipient.rb', line 3 def token @token end |
Class Method Details
.all ⇒ Array<PinPayment::Recipient>
Fetches all of your recipients using the pin API.
TODO: pagination
35 36 37 38 |
# File 'lib/pin_payment/recipient.rb', line 35 def self.all response = get(URI.parse(PinPayment.api_url).tap{|uri| uri.path = '/1/recipients' }) response.map{|x| new(x.delete('token'), x) } end |
.create(recipient_data) ⇒ PinPayment::Recipient
Uses the pin API to create a recipient.
14 15 16 17 18 19 |
# File 'lib/pin_payment/recipient.rb', line 14 def self.create recipient_data attributes = self.attributes - [:token] # fix attributes allowed by POST API = (attributes, recipient_data) response = post(URI.parse(PinPayment.api_url).tap{|uri| uri.path = '/1/recipients' }, ) new(response.delete('token'), response) end |
.find(token) ⇒ PinPayment::Recipient
Fetches a customer using the pin API.
44 45 46 47 |
# File 'lib/pin_payment/recipient.rb', line 44 def self.find token response = get(URI.parse(PinPayment.api_url).tap{|uri| uri.path = "/1/recipients/#{token}" }) new(response.delete('token'), response) end |
.update(token, email, card_or_token = nil) ⇒ PinPayment::Recipient
Update a recipient using the pin API.
27 28 29 |
# File 'lib/pin_payment/recipient.rb', line 27 def self.update token, email, card_or_token = nil new(token).tap{|c| c.update(email, card_or_token) } end |
Instance Method Details
#update(email, account_or_token = nil) ⇒ PinPayment::Customer
Update a recipient using the pin API.
54 55 56 57 58 59 60 61 |
# File 'lib/pin_payment/recipient.rb', line 54 def update email, account_or_token = nil attributes = self.class.attributes - [:token, :created_at] = self.class.(attributes, email: email, bank_account: account_or_token) response = self.class.put(URI.parse(PinPayment.api_url).tap{|uri| uri.path = "/1/recipients/#{token}" }, ) self.email = response['email'] self.bank_account = response['bank_account'] self end |