Class: Moka::Customer

Inherits:
Object
  • Object
show all
Defined in:
lib/moka/model/customer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#addressObject

Returns the value of attribute address.



3
4
5
# File 'lib/moka/model/customer.rb', line 3

def address
  @address
end

#birth_dateObject

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_listObject

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_cardObject

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_codeObject

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_idObject

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

#emailObject

Returns the value of attribute email.



3
4
5
# File 'lib/moka/model/customer.rb', line 3

def email
  @email
end

#first_nameObject

Returns the value of attribute first_name.



3
4
5
# File 'lib/moka/model/customer.rb', line 3

def first_name
  @first_name
end

#genderObject

Returns the value of attribute gender.



3
4
5
# File 'lib/moka/model/customer.rb', line 3

def gender
  @gender
end

#gsm_numberObject

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_nameObject

Returns the value of attribute last_name.



3
4
5
# File 'lib/moka/model/customer.rb', line 3

def last_name
  @last_name
end

#passwordObject

Returns the value of attribute password.



3
4
5
# File 'lib/moka/model/customer.rb', line 3

def password
  @password
end

#responseObject

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_cardObject



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

#createObject



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

#deleteObject



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_nameObject



13
14
15
# File 'lib/moka/model/customer.rb', line 13

def full_name
  "#{first_name} #{last_name}"
end

#getObject



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

Returns:

  • (Boolean)


42
43
44
# File 'lib/moka/model/customer.rb', line 42

def success?
  response && response['ResultCode'] == 'Success'
end

#updateObject



27
28
29
30
# File 'lib/moka/model/customer.rb', line 27

def update
  response        = RestClient.post Moka.endpoints.add_customer, update_hash
  self.response   = JSON.parse(response)
end