Class: Braspag::Customer

Inherits:
Object
  • Object
show all
Defined in:
lib/braspag/api/customer.rb

Overview

Customer data

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Customer

Returns a new instance of Customer.



20
21
22
# File 'lib/braspag/api/customer.rb', line 20

def initialize(name)
    @name = name
end

Instance Attribute Details

#addressAddress

Customer’s address

Returns:

  • (Address)

    the current value of address



11
12
13
# File 'lib/braspag/api/customer.rb', line 11

def address
  @address
end

#birth_dateObject

Returns the value of attribute birth_date.



12
13
14
# File 'lib/braspag/api/customer.rb', line 12

def birth_date
  @birth_date
end

#birthDateString

Customer’s birth date

Returns:

  • (String)

    the current value of birthDate



11
12
13
# File 'lib/braspag/api/customer.rb', line 11

def birthDate
  @birthDate
end

#delivery_adressObject

Returns the value of attribute delivery_adress.



12
13
14
# File 'lib/braspag/api/customer.rb', line 12

def delivery_adress
  @delivery_adress
end

#deliveryAddressAddress

The delivery address

Returns:

  • (Address)

    the current value of deliveryAddress



11
12
13
# File 'lib/braspag/api/customer.rb', line 11

def deliveryAddress
  @deliveryAddress
end

#emailString

Customer email

Returns:

  • (String)

    the current value of email



11
12
13
# File 'lib/braspag/api/customer.rb', line 11

def email
  @email
end

#identityString

Customer id

Returns:

  • (String)

    the current value of identity



11
12
13
# File 'lib/braspag/api/customer.rb', line 11

def identity
  @identity
end

#identity_typeObject

Returns the value of attribute identity_type.



12
13
14
# File 'lib/braspag/api/customer.rb', line 12

def identity_type
  @identity_type
end

#identityTypeString

The type of customer id

Returns:

  • (String)

    the current value of identityType



11
12
13
# File 'lib/braspag/api/customer.rb', line 11

def identityType
  @identityType
end

#nameString

Customer name

Returns:

  • (String)

    the current value of name



11
12
13
# File 'lib/braspag/api/customer.rb', line 11

def name
  @name
end

Class Method Details

.from_json(data) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/braspag/api/customer.rb', line 30

def self.from_json(data)
    if (data != nil)
        customer = Customer.new(data["Name"] || nil)

        customer.email = data["Email"] || nil
        customer.birth_date = data["BirthDate"] || nil
        customer.identity = data["Identity"] || nil
        customer.identity_type = data["IdentityType"] || nil
        customer.address = Address.from_json(data["Address"] || nil)
        customer.delivery_adress = Address.from_json(data["DeliveryAddress"] || nil)

        return customer
    end
end

Instance Method Details

#to_json(*options) ⇒ Object



24
25
26
27
28
# File 'lib/braspag/api/customer.rb', line 24

def to_json(*options)
    hash = as_json(*options)
    hash.reject! {|k,v| v.nil?}
    hash.to_json(*options)
end