Class: NewStoreApi::BookingProductCustoms
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- NewStoreApi::BookingProductCustoms
- Defined in:
- lib/new_store_api/models/booking_product_customs.rb
Overview
BookingProductCustoms Model.
Instance Attribute Summary collapse
-
#description ⇒ String
TODO: Write general description for this method.
-
#hts_number ⇒ String
HTS (10-digit) or HS (6-digit) number.
-
#origin_country ⇒ String
Alpha2 Country Code.
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(description = nil, hts_number = nil, origin_country = nil) ⇒ BookingProductCustoms
constructor
A new instance of BookingProductCustoms.
-
#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(description = nil, hts_number = nil, origin_country = nil) ⇒ BookingProductCustoms
Returns a new instance of BookingProductCustoms.
45 46 47 48 49 |
# File 'lib/new_store_api/models/booking_product_customs.rb', line 45 def initialize(description = nil, hts_number = nil, origin_country = nil) @description = description @hts_number = hts_number @origin_country = origin_country end |
Instance Attribute Details
#description ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/new_store_api/models/booking_product_customs.rb', line 14 def description @description end |
#hts_number ⇒ String
HTS (10-digit) or HS (6-digit) number. dots are allowed. prefer HTS numbers. compatibility with HS number exists for historical reasons. See https://www.trade.gov/harmonized-system-hs-codes
20 21 22 |
# File 'lib/new_store_api/models/booking_product_customs.rb', line 20 def hts_number @hts_number end |
#origin_country ⇒ String
Alpha2 Country Code. We allow more for historical reasons.
24 25 26 |
# File 'lib/new_store_api/models/booking_product_customs.rb', line 24 def origin_country @origin_country end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/new_store_api/models/booking_product_customs.rb', line 52 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. description = hash.key?('description') ? hash['description'] : nil hts_number = hash.key?('hts_number') ? hash['hts_number'] : nil origin_country = hash.key?('origin_country') ? hash['origin_country'] : nil # Create object from extracted values. BookingProductCustoms.new(description, hts_number, origin_country) end |
.names ⇒ Object
A mapping from model property names to API property names.
27 28 29 30 31 32 33 |
# File 'lib/new_store_api/models/booking_product_customs.rb', line 27 def self.names @_hash = {} if @_hash.nil? @_hash['description'] = 'description' @_hash['hts_number'] = 'hts_number' @_hash['origin_country'] = 'origin_country' @_hash end |
.nullables ⇒ Object
An array for nullable fields
41 42 43 |
# File 'lib/new_store_api/models/booking_product_customs.rb', line 41 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
36 37 38 |
# File 'lib/new_store_api/models/booking_product_customs.rb', line 36 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/new_store_api/models/booking_product_customs.rb', line 69 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.description, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.hts_number, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.origin_country, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['description'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['hts_number'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['origin_country'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
101 102 103 104 105 |
# File 'lib/new_store_api/models/booking_product_customs.rb', line 101 def inspect class_name = self.class.name.split('::').last "<#{class_name} description: #{@description.inspect}, hts_number: #{@hts_number.inspect},"\ " origin_country: #{@origin_country.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
94 95 96 97 98 |
# File 'lib/new_store_api/models/booking_product_customs.rb', line 94 def to_s class_name = self.class.name.split('::').last "<#{class_name} description: #{@description}, hts_number: #{@hts_number}, origin_country:"\ " #{@origin_country}>" end |