Class: Moip2::CustomerApi
- Inherits:
-
Object
- Object
- Moip2::CustomerApi
- Defined in:
- lib/moip2/customer_api.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #add_credit_card(customer_external_id, credit_card) ⇒ Object
- #base_path ⇒ Object
- #base_path_credit_card ⇒ Object
- #create(customer) ⇒ Object
- #delete_credit_card!(credit_card_id) ⇒ Object
-
#initialize(client) ⇒ CustomerApi
constructor
A new instance of CustomerApi.
- #show(customer_external_id) ⇒ Object
Constructor Details
#initialize(client) ⇒ CustomerApi
Returns a new instance of CustomerApi.
5 6 7 |
# File 'lib/moip2/customer_api.rb', line 5 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/moip2/customer_api.rb', line 3 def client @client end |
Instance Method Details
#add_credit_card(customer_external_id, credit_card) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/moip2/customer_api.rb', line 25 def add_credit_card(customer_external_id, credit_card) Resource::CreditCard.new client, client.post( "#{base_path}/#{customer_external_id}/fundinginstruments", credit_card, ) end |
#base_path ⇒ Object
9 10 11 |
# File 'lib/moip2/customer_api.rb', line 9 def base_path "/v2/customers" end |
#base_path_credit_card ⇒ Object
13 14 15 |
# File 'lib/moip2/customer_api.rb', line 13 def base_path_credit_card "/v2/fundinginstruments" end |
#create(customer) ⇒ Object
21 22 23 |
# File 'lib/moip2/customer_api.rb', line 21 def create(customer) Resource::Customer.new client, client.post(base_path, customer) end |
#delete_credit_card!(credit_card_id) ⇒ Object
32 33 34 35 36 |
# File 'lib/moip2/customer_api.rb', line 32 def delete_credit_card!(credit_card_id) resp = client.delete("#{base_path_credit_card}/#{credit_card_id}") resp.success? end |