class Cielo::API30::Customer

Customer data

@attr [String] name Customer name @attr [String] email Customer email @attr [String] birthDate Customer's birth date @attr [String] identity Customer id @attr [String] identityType The type of customer id @attr [Address] address Customer's address @attr [Address] deliveryAddress The delivery address

Attributes

address[RW]
birth_date[RW]
delivery_address[RW]
email[RW]
identity[RW]
identity_type[RW]
name[RW]

Public Class Methods

from_json(data) click to toggle source
# 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
new(name) click to toggle source
# File lib/cielo/api30/customer.rb, line 21
def initialize(name)
  @name = name
end

Public Instance Methods

as_json(options={}) click to toggle source
# File lib/cielo/api30/customer.rb, line 44
def as_json(options={})
  {
    Name: @name,
    Email: @email,
    BirthDate: @birth_date,
    Identity: @identity,
    IdentityType: @identity_type,
    Address: @address,
    DeliveryAddress: @delivery_address
  }
end
to_json(*options) click to toggle source
# File lib/cielo/api30/customer.rb, line 25
def to_json(*options)
  hash = as_json(*options)
  hash.reject! {|k,v| v.nil?}
  hash.to_json(*options)
end