Class: NewStoreApi::BookingProductCustoms

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/booking_product_customs.rb

Overview

BookingProductCustoms Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#descriptionString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/new_store_api/models/booking_product_customs.rb', line 14

def description
  @description
end

#hts_numberString

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

Returns:

  • (String)


20
21
22
# File 'lib/new_store_api/models/booking_product_customs.rb', line 20

def hts_number
  @hts_number
end

#origin_countryString

Alpha2 Country Code. We allow more for historical reasons.

Returns:

  • (String)


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

.namesObject

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

.nullablesObject

An array for nullable fields



41
42
43
# File 'lib/new_store_api/models/booking_product_customs.rb', line 41

def self.nullables
  []
end

.optionalsObject

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.

Parameters:



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

#inspectObject

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_sObject

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