Class: Braspag::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/braspag/api/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



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

def city
  @city
end

#complementString

any complement of customer’s address

Returns:

  • (String)

    the current value of complement



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

def complement
  @complement
end

#countryString

the country of customer’s address

Returns:

  • (String)

    the current value of country



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

def country
  @country
end

#numberString

the customer’s address number

Returns:

  • (String)

    the current value of number



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

def number
  @number
end

#stateString

the state of customer’s address

Returns:

  • (String)

    the current value of state



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

def state
  @state
end

#streetString

the customer’s address

Returns:

  • (String)

    the current value of street



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

def street
  @street
end

#zip_codeString

the zip code of customer’s address

Returns:

  • (String)

    the current value of zip_code



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

def zip_code
  @zip_code
end

Class Method Details

.from_json(data) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/braspag/api/address.rb', line 26

def self.from_json(data)
    if (data != nil)
        address = Address.new

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

Instance Method Details

#to_json(*options) ⇒ Object



20
21
22
23
24
# File 'lib/braspag/api/address.rb', line 20

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