Class: Moka::Customer
- Inherits:
-
Object
- Object
- Moka::Customer
- Defined in:
- lib/moka/model/customer.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#birth_date ⇒ Object
Returns the value of attribute birth_date.
-
#card_list ⇒ Object
Returns the value of attribute card_list.
-
#credit_card ⇒ Object
Returns the value of attribute credit_card.
-
#customer_code ⇒ Object
Returns the value of attribute customer_code.
-
#dealer_customer_id ⇒ Object
Returns the value of attribute dealer_customer_id.
-
#email ⇒ Object
Returns the value of attribute email.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#gender ⇒ Object
Returns the value of attribute gender.
-
#gsm_number ⇒ Object
Returns the value of attribute gsm_number.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#password ⇒ Object
Returns the value of attribute password.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #add_with_card ⇒ Object
- #create ⇒ Object
- #delete ⇒ Object
- #full_name ⇒ Object
- #get ⇒ Object
-
#initialize(opts = {}) ⇒ Customer
constructor
A new instance of Customer.
- #success? ⇒ Boolean
- #update ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Customer
Returns a new instance of Customer.
7 8 9 10 11 |
# File 'lib/moka/model/customer.rb', line 7 def initialize(opts = {}) opts.each do |o| send("#{o.first.to_s}=".to_sym, o.last) end end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
3 4 5 |
# File 'lib/moka/model/customer.rb', line 3 def address @address end |
#birth_date ⇒ Object
Returns the value of attribute birth_date.
3 4 5 |
# File 'lib/moka/model/customer.rb', line 3 def birth_date @birth_date end |
#card_list ⇒ Object
Returns the value of attribute card_list.
3 4 5 |
# File 'lib/moka/model/customer.rb', line 3 def card_list @card_list end |
#credit_card ⇒ Object
Returns the value of attribute credit_card.
3 4 5 |
# File 'lib/moka/model/customer.rb', line 3 def credit_card @credit_card end |
#customer_code ⇒ Object
Returns the value of attribute customer_code.
3 4 5 |
# File 'lib/moka/model/customer.rb', line 3 def customer_code @customer_code end |
#dealer_customer_id ⇒ Object
Returns the value of attribute dealer_customer_id.
3 4 5 |
# File 'lib/moka/model/customer.rb', line 3 def dealer_customer_id @dealer_customer_id end |
#email ⇒ Object
Returns the value of attribute email.
3 4 5 |
# File 'lib/moka/model/customer.rb', line 3 def email @email end |
#first_name ⇒ Object
Returns the value of attribute first_name.
3 4 5 |
# File 'lib/moka/model/customer.rb', line 3 def first_name @first_name end |
#gender ⇒ Object
Returns the value of attribute gender.
3 4 5 |
# File 'lib/moka/model/customer.rb', line 3 def gender @gender end |
#gsm_number ⇒ Object
Returns the value of attribute gsm_number.
3 4 5 |
# File 'lib/moka/model/customer.rb', line 3 def gsm_number @gsm_number end |
#last_name ⇒ Object
Returns the value of attribute last_name.
3 4 5 |
# File 'lib/moka/model/customer.rb', line 3 def last_name @last_name end |
#password ⇒ Object
Returns the value of attribute password.
3 4 5 |
# File 'lib/moka/model/customer.rb', line 3 def password @password end |
#response ⇒ Object
Returns the value of attribute response.
3 4 5 |
# File 'lib/moka/model/customer.rb', line 3 def response @response end |
Instance Method Details
#add_with_card ⇒ Object
37 38 39 40 |
# File 'lib/moka/model/customer.rb', line 37 def add_with_card response = RestClient.post Moka.endpoints.add_customer_with_card, get_and_delete_hash self.response = JSON.parse(response) end |
#create ⇒ Object
17 18 19 20 |
# File 'lib/moka/model/customer.rb', line 17 def create response = RestClient.post Moka.endpoints.add_customer, create_hash self.response = JSON.parse(response) end |
#delete ⇒ Object
32 33 34 35 |
# File 'lib/moka/model/customer.rb', line 32 def delete response = RestClient.post Moka.endpoints.add_customer, get_and_delete_hash self.response = JSON.parse(response) end |
#full_name ⇒ Object
13 14 15 |
# File 'lib/moka/model/customer.rb', line 13 def full_name "#{first_name} #{last_name}" end |
#get ⇒ Object
22 23 24 25 |
# File 'lib/moka/model/customer.rb', line 22 def get response = RestClient.post Moka.endpoints.add_customer, get_and_delete_hash self.response = JSON.parse(response) end |
#success? ⇒ Boolean
42 43 44 |
# File 'lib/moka/model/customer.rb', line 42 def success? response && response['ResultCode'] == 'Success' end |