lib/moip2/customer_api.rb in moip2-0.1.4 vs lib/moip2/customer_api.rb in moip2-1.0.0
- old
+ new
@@ -1,7 +1,6 @@
module Moip2
-
class CustomerApi
attr_reader :client
def initialize(client)
@client = client
@@ -9,16 +8,31 @@
def base_path
"/v2/customers"
end
+ def base_path_credit_card
+ "/v2/fundinginstruments"
+ end
+
def show(customer_external_id)
Resource::Customer.new client, client.get("#{base_path}/#{customer_external_id}")
end
def create(customer)
Resource::Customer.new client, client.post(base_path, customer)
end
- end
+ def add_credit_card(customer_external_id, credit_card)
+ Resource::CreditCard.new client, client.post(
+ "#{base_path}/#{customer_external_id}/fundinginstruments",
+ credit_card,
+ )
+ end
+ def delete_credit_card!(credit_card_id)
+ resp = client.delete("#{base_path_credit_card}/#{credit_card_id}")
+
+ resp.success?
+ end
+ end
end