Class: Blackbird::Retoure::SimpleAddress
- Inherits:
-
Object
- Object
- Blackbird::Retoure::SimpleAddress
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/blackbird/retoure/simple_address.rb
Overview
Public: Representation of DHLs SimpleClass object.
Instance Attribute Summary collapse
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#house_number ⇒ Object
readonly
Returns the value of attribute house_number.
-
#name1 ⇒ Object
readonly
Returns the value of attribute name1.
-
#name2 ⇒ Object
readonly
Returns the value of attribute name2.
-
#name3 ⇒ Object
readonly
Returns the value of attribute name3.
-
#post_code ⇒ Object
readonly
Returns the value of attribute post_code.
-
#street_name ⇒ Object
readonly
Returns the value of attribute street_name.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ SimpleAddress
constructor
A new instance of SimpleAddress.
-
#to_json ⇒ Object
Public: Create a JSON payload of this class.
Constructor Details
#initialize(args = {}) ⇒ SimpleAddress
Returns a new instance of SimpleAddress.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/blackbird/retoure/simple_address.rb', line 22 def initialize(args = {}) @name1 = args[:name1] @name2 = args[:name2] @name3 = args[:name3] @street_name = args[:street_name] @house_number = args[:house_number] @post_code = args[:post_code] @city = args[:city] self.country = args[:country] if args[:country] end |
Instance Attribute Details
#city ⇒ Object (readonly)
Returns the value of attribute city.
7 8 9 |
# File 'lib/blackbird/retoure/simple_address.rb', line 7 def city @city end |
#country ⇒ Object
Returns the value of attribute country.
7 8 9 |
# File 'lib/blackbird/retoure/simple_address.rb', line 7 def country @country end |
#house_number ⇒ Object (readonly)
Returns the value of attribute house_number.
7 8 9 |
# File 'lib/blackbird/retoure/simple_address.rb', line 7 def house_number @house_number end |
#name1 ⇒ Object (readonly)
Returns the value of attribute name1.
7 8 9 |
# File 'lib/blackbird/retoure/simple_address.rb', line 7 def name1 @name1 end |
#name2 ⇒ Object (readonly)
Returns the value of attribute name2.
7 8 9 |
# File 'lib/blackbird/retoure/simple_address.rb', line 7 def name2 @name2 end |
#name3 ⇒ Object (readonly)
Returns the value of attribute name3.
7 8 9 |
# File 'lib/blackbird/retoure/simple_address.rb', line 7 def name3 @name3 end |
#post_code ⇒ Object (readonly)
Returns the value of attribute post_code.
7 8 9 |
# File 'lib/blackbird/retoure/simple_address.rb', line 7 def post_code @post_code end |
#street_name ⇒ Object (readonly)
Returns the value of attribute street_name.
7 8 9 |
# File 'lib/blackbird/retoure/simple_address.rb', line 7 def street_name @street_name end |
Instance Method Details
#to_json ⇒ Object
Public: Create a JSON payload of this class.
Returns a String representing the JSON payload.
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/blackbird/retoure/simple_address.rb', line 49 def to_json json_payload = { name1: @name1, streetName: @street_name, houseNumber: @house_number, postCode: @post_code, city: @city } json_payload[:name2] = @name2 if @name2.present? json_payload[:name3] = @name3 if @name3.present? json_payload[:country] = JSON.parse(@country.to_json) if @country.present? json_payload.to_json end |