Class: Revolut::Api::Response::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/revolut/api/response/address.rb

Constant Summary collapse

MAPPING =
{
  "country"       =>  :country,
  "city"          =>  :city,
  "postcode"      =>  :postcode,
  "region"        =>  :region,
  "streetLine1"   =>  :street_line_one,
  "streetLine2"   =>  :street_line_two
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ Address

Returns a new instance of Address.



17
18
19
20
21
# File 'lib/revolut/api/response/address.rb', line 17

def initialize(hash = {})
  ::Revolut::Api::Response::Address::MAPPING.each do |revolut_key, accessor|
    self.send("#{accessor}=", hash.fetch(revolut_key, nil))
  end
end

Instance Attribute Details

#cityObject

Returns the value of attribute city.



6
7
8
# File 'lib/revolut/api/response/address.rb', line 6

def city
  @city
end

#countryObject

Returns the value of attribute country.



6
7
8
# File 'lib/revolut/api/response/address.rb', line 6

def country
  @country
end

#mappingObject

Returns the value of attribute mapping.



5
6
7
# File 'lib/revolut/api/response/address.rb', line 5

def mapping
  @mapping
end

#postcodeObject

Returns the value of attribute postcode.



6
7
8
# File 'lib/revolut/api/response/address.rb', line 6

def postcode
  @postcode
end

#regionObject

Returns the value of attribute region.



6
7
8
# File 'lib/revolut/api/response/address.rb', line 6

def region
  @region
end

#street_line_oneObject

Returns the value of attribute street_line_one.



6
7
8
# File 'lib/revolut/api/response/address.rb', line 6

def street_line_one
  @street_line_one
end

#street_line_twoObject

Returns the value of attribute street_line_two.



6
7
8
# File 'lib/revolut/api/response/address.rb', line 6

def street_line_two
  @street_line_two
end

Instance Method Details

#to_api_hashObject



23
24
25
26
27
28
29
30
31
# File 'lib/revolut/api/response/address.rb', line 23

def to_api_hash
  hash                  =   {}

  ::Revolut::Api::Response::Address::MAPPING.each do |revolut_key, accessor|
    hash[revolut_key]   =   self.send(accessor)
  end

  return hash
end