Class: Conekta::Customer
- Inherits:
-
Resource
- Object
- Hash
- ConektaObject
- Resource
- Conekta::Customer
- Includes:
- Operations::Create, Operations::CreateMember, Operations::CustomAction, Operations::Delete, Operations::Find, Operations::Update, Operations::Where
- Defined in:
- lib/conekta/customer.rb
Instance Attribute Summary collapse
-
#account_age ⇒ Object
Returns the value of attribute account_age.
-
#cards ⇒ Object
Returns the value of attribute cards.
-
#corporate ⇒ Object
Returns the value of attribute corporate.
-
#default_fiscal_entity_id ⇒ Object
Returns the value of attribute default_fiscal_entity_id.
-
#default_payment_source_id ⇒ Object
Returns the value of attribute default_payment_source_id.
-
#default_shipping_contact_id ⇒ Object
Returns the value of attribute default_shipping_contact_id.
-
#email ⇒ Object
Returns the value of attribute email.
-
#first_paid_at ⇒ Object
Returns the value of attribute first_paid_at.
-
#fiscal_entities ⇒ Object
Returns the value of attribute fiscal_entities.
-
#livemode ⇒ Object
Returns the value of attribute livemode.
-
#name ⇒ Object
Returns the value of attribute name.
-
#paid_transactions ⇒ Object
Returns the value of attribute paid_transactions.
-
#payment_sources ⇒ Object
Returns the value of attribute payment_sources.
-
#phone ⇒ Object
Returns the value of attribute phone.
-
#referrer ⇒ Object
Returns the value of attribute referrer.
-
#shipping_contacts ⇒ Object
Returns the value of attribute shipping_contacts.
-
#subscription ⇒ Object
Returns the value of attribute subscription.
Attributes inherited from Resource
Attributes inherited from ConektaObject
Instance Method Summary collapse
- #create_card(params) ⇒ Object
- #create_fiscal_entity(params) ⇒ Object
- #create_payment_source(params) ⇒ Object
- #create_shipping_contact(params) ⇒ Object
- #create_submodels_lists(customer, submodels) ⇒ Object
- #create_subscription(params) ⇒ Object
-
#initialize(id = nil) ⇒ Customer
constructor
A new instance of Customer.
- #load_from(response = nil) ⇒ Object
Methods included from Operations::CreateMember
Methods included from Operations::CustomAction
Methods included from Operations::Update
Methods included from Operations::Delete
Methods included from Operations::Create
Methods included from Operations::Where
handle_type_of_paging, included
Methods included from Operations::Find
Methods inherited from Resource
_url, #_url, #create_member_with_relation, underscored_class
Methods inherited from ConektaObject
#class_name, class_name, #create_attr, #first, #inspect, #last, #set_val, #to_s, #unset_key
Constructor Details
#initialize(id = nil) ⇒ Customer
Returns a new instance of Customer.
16 17 18 19 20 21 22 |
# File 'lib/conekta/customer.rb', line 16 def initialize(id=nil) @id = id @payment_sources ||= List.new("PaymentSource", {}) @fiscal_entities ||= List.new("FiscalEntity", {}) @shipping_contacts ||= List.new("ShippingContacts", {}) super(id) end |
Instance Attribute Details
#account_age ⇒ Object
Returns the value of attribute account_age.
11 12 13 |
# File 'lib/conekta/customer.rb', line 11 def account_age @account_age end |
#cards ⇒ Object
Returns the value of attribute cards.
11 12 13 |
# File 'lib/conekta/customer.rb', line 11 def cards @cards end |
#corporate ⇒ Object
Returns the value of attribute corporate.
11 12 13 |
# File 'lib/conekta/customer.rb', line 11 def corporate @corporate end |
#default_fiscal_entity_id ⇒ Object
Returns the value of attribute default_fiscal_entity_id.
11 12 13 |
# File 'lib/conekta/customer.rb', line 11 def default_fiscal_entity_id @default_fiscal_entity_id end |
#default_payment_source_id ⇒ Object
Returns the value of attribute default_payment_source_id.
11 12 13 |
# File 'lib/conekta/customer.rb', line 11 def default_payment_source_id @default_payment_source_id end |
#default_shipping_contact_id ⇒ Object
Returns the value of attribute default_shipping_contact_id.
11 12 13 |
# File 'lib/conekta/customer.rb', line 11 def default_shipping_contact_id @default_shipping_contact_id end |
#email ⇒ Object
Returns the value of attribute email.
11 12 13 |
# File 'lib/conekta/customer.rb', line 11 def email @email end |
#first_paid_at ⇒ Object
Returns the value of attribute first_paid_at.
11 12 13 |
# File 'lib/conekta/customer.rb', line 11 def first_paid_at @first_paid_at end |
#fiscal_entities ⇒ Object
Returns the value of attribute fiscal_entities.
11 12 13 |
# File 'lib/conekta/customer.rb', line 11 def fiscal_entities @fiscal_entities end |
#livemode ⇒ Object
Returns the value of attribute livemode.
11 12 13 |
# File 'lib/conekta/customer.rb', line 11 def livemode @livemode end |
#name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/conekta/customer.rb', line 11 def name @name end |
#paid_transactions ⇒ Object
Returns the value of attribute paid_transactions.
11 12 13 |
# File 'lib/conekta/customer.rb', line 11 def paid_transactions @paid_transactions end |
#payment_sources ⇒ Object
Returns the value of attribute payment_sources.
11 12 13 |
# File 'lib/conekta/customer.rb', line 11 def payment_sources @payment_sources end |
#phone ⇒ Object
Returns the value of attribute phone.
11 12 13 |
# File 'lib/conekta/customer.rb', line 11 def phone @phone end |
#referrer ⇒ Object
Returns the value of attribute referrer.
11 12 13 |
# File 'lib/conekta/customer.rb', line 11 def referrer @referrer end |
#shipping_contacts ⇒ Object
Returns the value of attribute shipping_contacts.
11 12 13 |
# File 'lib/conekta/customer.rb', line 11 def shipping_contacts @shipping_contacts end |
#subscription ⇒ Object
Returns the value of attribute subscription.
11 12 13 |
# File 'lib/conekta/customer.rb', line 11 def subscription @subscription end |
Instance Method Details
#create_card(params) ⇒ Object
53 54 55 |
# File 'lib/conekta/customer.rb', line 53 def create_card(params) self.create_member_with_relation('cards', params, self) end |
#create_fiscal_entity(params) ⇒ Object
65 66 67 |
# File 'lib/conekta/customer.rb', line 65 def create_fiscal_entity(params) self.create_member_with_relation('fiscal_entities', params, self) end |
#create_payment_source(params) ⇒ Object
57 58 59 |
# File 'lib/conekta/customer.rb', line 57 def create_payment_source(params) self.create_member_with_relation('payment_sources', params, self) end |
#create_shipping_contact(params) ⇒ Object
69 70 71 |
# File 'lib/conekta/customer.rb', line 69 def create_shipping_contact(params) self.create_member_with_relation('shipping_contacts', params, self) end |
#create_submodels_lists(customer, submodels) ⇒ Object
73 74 75 76 77 78 79 80 81 |
# File 'lib/conekta/customer.rb', line 73 def create_submodels_lists(customer, submodels) submodels.each do |submodel| self.send(submodel).each do |k, v| v.create_attr('customer', customer) self.send(submodel).set_val(k,v) end if self.respond_to?(submodel) && !self.send(submodel).nil? end end |
#create_subscription(params) ⇒ Object
61 62 63 |
# File 'lib/conekta/customer.rb', line 61 def create_subscription(params) self.create_member('subscription', params) end |
#load_from(response = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/conekta/customer.rb', line 24 def load_from(response=nil) if response super end customer = self if Conekta.api_version == "2.0.0" submodels = [:fiscal_entities, :payment_sources, :shipping_contacts] create_submodels_lists(customer, submodels) else submodels = [:cards] submodels.each do |submodel| self.send(submodel).each do |k,v| if !v.respond_to? :deleted or !v.deleted v.create_attr('customer', customer) self.send(submodel).set_val(k,v) end end end end if self.respond_to? :subscription and self.subscription self.subscription.create_attr('customer', customer) end end |