Class: Cielo::API30::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/cielo/api30/address.rb

Overview

Customer’s address.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cityString

the city of customer’s address

Returns:

  • (String)

    the current value of city



12
13
14
# File 'lib/cielo/api30/address.rb', line 12

def city
  @city
end

#complementString

any complement of customer’s address

Returns:

  • (String)

    the current value of complement



12
13
14
# File 'lib/cielo/api30/address.rb', line 12

def complement
  @complement
end

#countryString

the country of customer’s address

Returns:

  • (String)

    the current value of country



12
13
14
# File 'lib/cielo/api30/address.rb', line 12

def country
  @country
end

#numberString

the customer’s address number

Returns:

  • (String)

    the current value of number



12
13
14
# File 'lib/cielo/api30/address.rb', line 12

def number
  @number
end

#stateString

the state of customer’s address

Returns:

  • (String)

    the current value of state



12
13
14
# File 'lib/cielo/api30/address.rb', line 12

def state
  @state
end

#streetString

the customer’s address

Returns:

  • (String)

    the current value of street



12
13
14
# File 'lib/cielo/api30/address.rb', line 12

def street
  @street
end

#zip_codeString

the zip code of customer’s address

Returns:

  • (String)

    the current value of zip_code



12
13
14
# File 'lib/cielo/api30/address.rb', line 12

def zip_code
  @zip_code
end

Class Method Details

.from_json(data) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/cielo/api30/address.rb', line 27

def self.from_json(data)
  return if data.nil?

  address = new
  address.street = data["Street"]
  address.number = data["Number"]
  address.complement = data["Complement"]
  address.zip_code = data["ZipCode"]
  address.city = data["City"]
  address.state = data["State"]
  address.country = data["Country"]
  address
end

Instance Method Details

#as_json(options = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/cielo/api30/address.rb', line 41

def as_json(options={})
  {
    Street: @street,
    Number: @number,
    Complement: @complement,
    ZipCode: @zip_code,
    City: @city,
    State: @state,
    Country: @country
  }
end

#to_json(*options) ⇒ Object



21
22
23
24
25
# File 'lib/cielo/api30/address.rb', line 21

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