Class: NewStoreApi::DeliveryDestination
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- NewStoreApi::DeliveryDestination
- Defined in:
- lib/new_store_api/models/delivery_destination.rb
Overview
Destination country and the zip code where the ordered products are to be delivered.
Instance Attribute Summary collapse
-
#country_code ⇒ String
Country code (2 letter ISO-3166) of the order destination address.
-
#zip_code ⇒ String
Zip code of the order destination address.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(country_code = nil, zip_code = SKIP) ⇒ DeliveryDestination
constructor
A new instance of DeliveryDestination.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(country_code = nil, zip_code = SKIP) ⇒ DeliveryDestination
Returns a new instance of DeliveryDestination.
41 42 43 44 |
# File 'lib/new_store_api/models/delivery_destination.rb', line 41 def initialize(country_code = nil, zip_code = SKIP) @country_code = country_code @zip_code = zip_code unless zip_code == SKIP end |
Instance Attribute Details
#country_code ⇒ String
Country code (2 letter ISO-3166) of the order destination address.
15 16 17 |
# File 'lib/new_store_api/models/delivery_destination.rb', line 15 def country_code @country_code end |
#zip_code ⇒ String
Zip code of the order destination address.
19 20 21 |
# File 'lib/new_store_api/models/delivery_destination.rb', line 19 def zip_code @zip_code end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/new_store_api/models/delivery_destination.rb', line 47 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. country_code = hash.key?('country_code') ? hash['country_code'] : nil zip_code = hash.key?('zip_code') ? hash['zip_code'] : SKIP # Create object from extracted values. DeliveryDestination.new(country_code, zip_code) end |
.names ⇒ Object
A mapping from model property names to API property names.
22 23 24 25 26 27 |
# File 'lib/new_store_api/models/delivery_destination.rb', line 22 def self.names @_hash = {} if @_hash.nil? @_hash['country_code'] = 'country_code' @_hash['zip_code'] = 'zip_code' @_hash end |
.nullables ⇒ Object
An array for nullable fields
37 38 39 |
# File 'lib/new_store_api/models/delivery_destination.rb', line 37 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
30 31 32 33 34 |
# File 'lib/new_store_api/models/delivery_destination.rb', line 30 def self.optionals %w[ zip_code ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/new_store_api/models/delivery_destination.rb', line 61 def self.validate(value) if value.instance_of? self return APIHelper.valid_type?(value.country_code, ->(val) { val.instance_of? String }) end return false unless value.instance_of? Hash APIHelper.valid_type?(value['country_code'], ->(val) { val.instance_of? String }) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
80 81 82 83 |
# File 'lib/new_store_api/models/delivery_destination.rb', line 80 def inspect class_name = self.class.name.split('::').last "<#{class_name} country_code: #{@country_code.inspect}, zip_code: #{@zip_code.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
74 75 76 77 |
# File 'lib/new_store_api/models/delivery_destination.rb', line 74 def to_s class_name = self.class.name.split('::').last "<#{class_name} country_code: #{@country_code}, zip_code: #{@zip_code}>" end |