class PandaPay::Customer

Attributes

cards[R]
email[R]
id[R]
livemode[R]
object[R]

Public Class Methods

create(email: , source: ) click to toggle source
# File lib/pandapay/customer.rb, line 14
def self.create(email: , source: )
        conn = Faraday.new(:url => "https://#{PandaPay.secret_key}:@#{PandaPay_API_URL}")     
        response = conn.post '/v1/customers', { :email => email, :source => source}
        attributes = JSON.parse(response.body)
        if attributes.has_key? "error" or attributes.has_key? "errors"
                raise response.body
        else 
                new(attributes)
        end
end
delete(customer_id: ) click to toggle source
# File lib/pandapay/customer.rb, line 43
def self.delete(customer_id: )
        conn = Faraday.new(:url => "https://#{PandaPay.secret_key}:@#{PandaPay_API_URL}")     
        response = conn.delete "/v1/customers/#{customer_id}"
        attributes = JSON.parse(response.body)
        if attributes.has_key? "error" or attributes.has_key? "errors"
                raise response.body
        else 
                new(attributes)
        end
end
new(attributes) click to toggle source
# File lib/pandapay/customer.rb, line 6
def initialize(attributes)
        @id = attributes["id"]
        @object = attributes["object"]
        @email = attributes["email"]
        @livemode = attributes["livemode"]
        @cards = attributes["cards"]
end
update(customer_id: , email: nil, source: nil) click to toggle source
# File lib/pandapay/customer.rb, line 25
def self.update(customer_id: , email: nil, source: nil)
        params = {}
        unless email.nil?
                params[:email] = email
        end 
        unless source.nil?
                params[:source] = source
        end 
        conn = Faraday.new(:url => "https://#{PandaPay.secret_key}:@#{PandaPay_API_URL}")     
        response = conn.put "/v1/customers/#{customer_id}", params
        attributes = JSON.parse(response.body)
        if attributes.has_key? "error" or attributes.has_key? "errors"
                raise response.body
        else 
                new(attributes)
        end
end