Class: CustomersPe

Inherits:
OpenPayResource show all
Defined in:
lib/openpay/peru/customers_pe.rb

Instance Attribute Summary

Attributes inherited from OpenPayResource

#api_hook

Instance Method Summary collapse

Methods inherited from OpenPayResource

#delete, #delete_all, #each, #env, #errors?, #get, #get_with_custom_url, #hash2json, #initialize, #json2hash, #list, #post, #put

Constructor Details

This class inherits a constructor from OpenPayResource

Instance Method Details

#all_cards(customer) ⇒ Object



58
59
60
# File 'lib/openpay/peru/customers_pe.rb', line 58

def all_cards(customer)
  get("#{customer}/cards")
end

#all_charges(customer_id) ⇒ Object

return all charges for the given customer_id



22
23
24
# File 'lib/openpay/peru/customers_pe.rb', line 22

def all_charges(customer_id)
  get("#{customer_id}/charges")
end

#all_checkouts(customer_id) ⇒ Object



71
72
73
# File 'lib/openpay/peru/customers_pe.rb', line 71

def all_checkouts(customer_id)
  get("#{customer_id}/checkouts")
end

#create_card(customer, card) ⇒ Object

Card



27
28
29
# File 'lib/openpay/peru/customers_pe.rb', line 27

def create_card(customer, card)
  create(card, "#{customer}/cards")
end

#create_charge(customer_id, charge) ⇒ Object

Charges customers.create_charge(customer_id,charge)



7
8
9
# File 'lib/openpay/peru/customers_pe.rb', line 7

def create_charge(customer_id, charge)
  create(charge, "#{customer_id}/charges")
end

#create_checkout(customer, checkout) ⇒ Object

Checkouts



63
64
65
# File 'lib/openpay/peru/customers_pe.rb', line 63

def create_checkout(customer, checkout)
  create(checkout, "#{customer}/checkouts")
end

#delete_all_cards(customer_id) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/openpay/peru/customers_pe.rb', line 39

def delete_all_cards(customer_id)
  if env == :production
    raise OpenpayException.new('This method is not supported on PRODUCTION', false)
  end
  each_card(customer_id) do |card|
    delete_card(customer_id, card['id'])
  end
end

#delete_card(customer, card_id) ⇒ Object



35
36
37
# File 'lib/openpay/peru/customers_pe.rb', line 35

def delete_card(customer, card_id)
  delete("#{customer}/cards/#{card_id}")
end

#each_card(customer) ⇒ Object



48
49
50
51
52
# File 'lib/openpay/peru/customers_pe.rb', line 48

def each_card(customer)
  get("#{customer}/cards").each do |card|
    yield card
  end
end

#get_card(customer, card_id) ⇒ Object



31
32
33
# File 'lib/openpay/peru/customers_pe.rb', line 31

def get_card(customer, card_id)
  get("#{customer}/cards/#{card_id}")
end

#get_charge(customer_id, charge_id) ⇒ Object

gets a charge_id for a given customer_id



12
13
14
# File 'lib/openpay/peru/customers_pe.rb', line 12

def get_charge(customer_id, charge_id)
  get("#{customer_id}/charges/#{charge_id}")
end

#get_checkout(customer_id, checkout_id) ⇒ Object



67
68
69
# File 'lib/openpay/peru/customers_pe.rb', line 67

def get_checkout(customer_id, checkout_id)
  get("#{customer_id}/checkouts/#{checkout_id}")
end

#list_cards(customer, search_params) ⇒ Object



54
55
56
# File 'lib/openpay/peru/customers_pe.rb', line 54

def list_cards(customer, search_params)
  get("#{customer}/cards#{search_params.to_s}")
end

#list_charges(customer, search_params) ⇒ Object



16
17
18
# File 'lib/openpay/peru/customers_pe.rb', line 16

def list_charges(customer, search_params)
  get("#{customer}/charges#{search_params.to_s}")
end

#list_checkouts(customer_id, search_params) ⇒ Object



75
76
77
# File 'lib/openpay/peru/customers_pe.rb', line 75

def list_checkouts(customer_id, search_params)
  get("#{customer_id}/checkouts#{search_params.to_s}")
end