Class: Afterpay::Address
- Inherits:
-
Object
- Object
- Afterpay::Address
- Defined in:
- lib/afterpay/address.rb
Instance Attribute Summary collapse
-
#area_1 ⇒ Object
Returns the value of attribute area_1.
-
#area_2 ⇒ Object
Returns the value of attribute area_2.
-
#country ⇒ Object
Returns the value of attribute country.
-
#line_1 ⇒ Object
Returns the value of attribute line_1.
-
#line_2 ⇒ Object
Returns the value of attribute line_2.
-
#name ⇒ Object
Returns the value of attribute name.
-
#phone ⇒ Object
Returns the value of attribute phone.
-
#postcode ⇒ Object
Returns the value of attribute postcode.
-
#region ⇒ Object
Returns the value of attribute region.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Address
constructor
A new instance of Address.
- #to_hash ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Address
Returns a new instance of Address.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/afterpay/address.rb', line 7 def initialize(attributes = {}) @name = attributes[:name] @line_1 = attributes[:line_1] || "" @line_2 = attributes[:line_2] || "" @area_1 = attributes[:area_1] || "" @area_2 = attributes[:area_2] || "" @region = attributes[:region] || "" @postcode = attributes[:postcode] @country = attributes[:country] || "AU" @phone = attributes[:phone] end |
Instance Attribute Details
#area_1 ⇒ Object
Returns the value of attribute area_1.
5 6 7 |
# File 'lib/afterpay/address.rb', line 5 def area_1 @area_1 end |
#area_2 ⇒ Object
Returns the value of attribute area_2.
5 6 7 |
# File 'lib/afterpay/address.rb', line 5 def area_2 @area_2 end |
#country ⇒ Object
Returns the value of attribute country.
5 6 7 |
# File 'lib/afterpay/address.rb', line 5 def country @country end |
#line_1 ⇒ Object
Returns the value of attribute line_1.
5 6 7 |
# File 'lib/afterpay/address.rb', line 5 def line_1 @line_1 end |
#line_2 ⇒ Object
Returns the value of attribute line_2.
5 6 7 |
# File 'lib/afterpay/address.rb', line 5 def line_2 @line_2 end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/afterpay/address.rb', line 5 def name @name end |
#phone ⇒ Object
Returns the value of attribute phone.
5 6 7 |
# File 'lib/afterpay/address.rb', line 5 def phone @phone end |
#postcode ⇒ Object
Returns the value of attribute postcode.
5 6 7 |
# File 'lib/afterpay/address.rb', line 5 def postcode @postcode end |
#region ⇒ Object
Returns the value of attribute region.
5 6 7 |
# File 'lib/afterpay/address.rb', line 5 def region @region end |
Class Method Details
.from_response(response) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/afterpay/address.rb', line 33 def self.from_response(response) return nil if response.nil? new( name: response[:name], line_1: response[:line1], line_2: response[:line2], area_1: response[:area1], area_2: response[:area2], region: response[:region], postcode: response[:postcode], country: response[:countryCode], phone: response[:phoneNumber] ) end |
Instance Method Details
#to_hash ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/afterpay/address.rb', line 19 def to_hash { name: name, line1: line_1, line2: line_2, area_1: area_1, area_2: area_2, region: region, postcode: postcode.to_s, countryCode: country, phoneNumber: phone.to_s } end |