Class: Pagseguro::Charge::Address
- Inherits:
-
Object
- Object
- Pagseguro::Charge::Address
- Defined in:
- lib/pagseguro/charge/address.rb
Overview
Credit card data
Instance Attribute Summary collapse
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#locality ⇒ Object
Returns the value of attribute locality.
-
#number ⇒ Object
Returns the value of attribute number.
-
#postal_code ⇒ Object
Returns the value of attribute postal_code.
-
#region ⇒ Object
Returns the value of attribute region.
-
#region_code ⇒ Object
Returns the value of attribute region_code.
-
#street ⇒ Object
Returns the value of attribute street.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#initialize(args = {}) ⇒ Address
constructor
A new instance of Address.
- #to_json(*options) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Address
Returns a new instance of Address.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pagseguro/charge/address.rb', line 16 def initialize(args = {}) @country = args[:country] @region = args[:region] @region_code = args[:region_code] @city = args[:city] @postal_code = args[:postal_code] @street = args[:street] @number = args[:number] @locality = args[:locality] end |
Instance Attribute Details
#city ⇒ Object
Returns the value of attribute city.
6 7 8 |
# File 'lib/pagseguro/charge/address.rb', line 6 def city @city end |
#country ⇒ Object
Returns the value of attribute country.
6 7 8 |
# File 'lib/pagseguro/charge/address.rb', line 6 def country @country end |
#locality ⇒ Object
Returns the value of attribute locality.
6 7 8 |
# File 'lib/pagseguro/charge/address.rb', line 6 def locality @locality end |
#number ⇒ Object
Returns the value of attribute number.
6 7 8 |
# File 'lib/pagseguro/charge/address.rb', line 6 def number @number end |
#postal_code ⇒ Object
Returns the value of attribute postal_code.
6 7 8 |
# File 'lib/pagseguro/charge/address.rb', line 6 def postal_code @postal_code end |
#region ⇒ Object
Returns the value of attribute region.
6 7 8 |
# File 'lib/pagseguro/charge/address.rb', line 6 def region @region end |
#region_code ⇒ Object
Returns the value of attribute region_code.
6 7 8 |
# File 'lib/pagseguro/charge/address.rb', line 6 def region_code @region_code end |
#street ⇒ Object
Returns the value of attribute street.
6 7 8 |
# File 'lib/pagseguro/charge/address.rb', line 6 def street @street end |
Class Method Details
.fill_from_json(data) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/pagseguro/charge/address.rb', line 33 def self.fill_from_json(data) return if data.nil? address = new address.country = data["country"] address.region = data["region"] address.region_code = data["region_code"] address.city = data["city"] address.postal_code = data["postal_code"] address.street = data["street"] address.number = data["number"] address.locality = data["locality"] address end |
Instance Method Details
#as_json(options = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/pagseguro/charge/address.rb', line 48 def as_json(={}) { country: @country, region: @region, region_code: @region_code, city: @city, postal_code: @postal_code, street: @street, number: @number, locality: @locality } end |
#to_json(*options) ⇒ Object
27 28 29 30 31 |
# File 'lib/pagseguro/charge/address.rb', line 27 def to_json(*) hash = as_json(*) hash.reject! {|k,v| v.nil?} hash.to_json(*) end |