Class: Cielo::API30::Customer
- Inherits:
-
Object
- Object
- Cielo::API30::Customer
- Defined in:
- lib/cielo/api30/customer.rb
Overview
Customer data
Instance Attribute Summary collapse
-
#address ⇒ Address
Customer’s address.
-
#birth_date ⇒ Object
Returns the value of attribute birth_date.
-
#birthDate ⇒ String
Customer’s birth date.
-
#delivery_address ⇒ Object
Returns the value of attribute delivery_address.
-
#deliveryAddress ⇒ Address
The delivery address.
-
#email ⇒ String
Customer email.
-
#identity ⇒ String
Customer id.
-
#identity_type ⇒ Object
Returns the value of attribute identity_type.
-
#identityType ⇒ String
The type of customer id.
-
#name ⇒ String
Customer name.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#initialize(name) ⇒ Customer
constructor
A new instance of Customer.
- #to_json(*options) ⇒ Object
Constructor Details
#initialize(name) ⇒ Customer
Returns a new instance of Customer.
21 22 23 |
# File 'lib/cielo/api30/customer.rb', line 21 def initialize(name) @name = name end |
Instance Attribute Details
#address ⇒ Address
Customer’s address
12 13 14 |
# File 'lib/cielo/api30/customer.rb', line 12 def address @address end |
#birth_date ⇒ Object
Returns the value of attribute birth_date.
13 14 15 |
# File 'lib/cielo/api30/customer.rb', line 13 def birth_date @birth_date end |
#birthDate ⇒ String
Customer’s birth date
12 13 14 |
# File 'lib/cielo/api30/customer.rb', line 12 def birthDate @birthDate end |
#delivery_address ⇒ Object
Returns the value of attribute delivery_address.
13 14 15 |
# File 'lib/cielo/api30/customer.rb', line 13 def delivery_address @delivery_address end |
#deliveryAddress ⇒ Address
The delivery address
12 13 14 |
# File 'lib/cielo/api30/customer.rb', line 12 def deliveryAddress @deliveryAddress end |
#email ⇒ String
Customer email
12 13 14 |
# File 'lib/cielo/api30/customer.rb', line 12 def email @email end |
#identity ⇒ String
Customer id
12 13 14 |
# File 'lib/cielo/api30/customer.rb', line 12 def identity @identity end |
#identity_type ⇒ Object
Returns the value of attribute identity_type.
13 14 15 |
# File 'lib/cielo/api30/customer.rb', line 13 def identity_type @identity_type end |
#identityType ⇒ String
The type of customer id
12 13 14 |
# File 'lib/cielo/api30/customer.rb', line 12 def identityType @identityType end |
#name ⇒ String
Customer name
12 13 14 |
# File 'lib/cielo/api30/customer.rb', line 12 def name @name end |
Class Method Details
.from_json(data) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/cielo/api30/customer.rb', line 31 def self.from_json(data) return if data.nil? customer = new(data["Name"]) customer.email = data["Email"] customer.birth_date = data["BirthDate"] customer.identity = data["Identity"] customer.identity_type = data["IdentityType"] customer.address = Address.from_json(data["Address"]) customer.delivery_address = Address.from_json(data["DeliveryAddress"]) customer end |
Instance Method Details
#as_json(options = {}) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/cielo/api30/customer.rb', line 44 def as_json(={}) { Name: @name, Email: @email, BirthDate: @birth_date, Identity: @identity, IdentityType: @identity_type, Address: @address, DeliveryAddress: @delivery_address } end |
#to_json(*options) ⇒ Object
25 26 27 28 29 |
# File 'lib/cielo/api30/customer.rb', line 25 def to_json(*) hash = as_json(*) hash.reject! {|k,v| v.nil?} hash.to_json(*) end |