Class: UspsApi::InternationalPricesLetterRateDetails

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/usps_api/models/international_prices_letter_rate_details.rb

Overview

Informative details about the price.

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(sku: SKIP, description: SKIP, price_type: SKIP, price: SKIP, weight: SKIP, fees: SKIP, start_date: SKIP, end_date: SKIP, mail_class: SKIP, extra_services: SKIP, zone: SKIP, additional_properties: nil) ⇒ InternationalPricesLetterRateDetails

Returns a new instance of InternationalPricesLetterRateDetails.



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/usps_api/models/international_prices_letter_rate_details.rb', line 100

def initialize(sku: SKIP, description: SKIP, price_type: SKIP, price: SKIP,
               weight: SKIP, fees: SKIP, start_date: SKIP, end_date: SKIP,
               mail_class: SKIP, extra_services: SKIP, zone: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @sku = sku unless sku == SKIP
  @description = description unless description == SKIP
  @price_type = price_type unless price_type == SKIP
  @price = price unless price == SKIP
  @weight = weight unless weight == SKIP
  @fees = fees unless fees == SKIP
  @start_date = start_date unless start_date == SKIP
  @end_date = end_date unless end_date == SKIP
  @mail_class = mail_class unless mail_class == SKIP
  @extra_services = extra_services unless extra_services == SKIP
  @zone = zone unless zone == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#descriptionString

The description of the price.

Returns:

  • (String)


18
19
20
# File 'lib/usps_api/models/international_prices_letter_rate_details.rb', line 18

def description
  @description
end

#end_dateString

Effective end date of the rate. If blank the rate doesn’t have an end date as of yet.

Returns:

  • (String)


44
45
46
# File 'lib/usps_api/models/international_prices_letter_rate_details.rb', line 44

def end_date
  @end_date
end

#extra_servicesArray[ExtraService3]

A list of Extra Services to be included in the total rates search. If no extra services are specified all applicable extra services for the mail class will be returned.

Returns:



54
55
56
# File 'lib/usps_api/models/international_prices_letter_rate_details.rb', line 54

def extra_services
  @extra_services
end

#feesArray[Fee1]

The fees associated with the package.

Returns:



35
36
37
# File 'lib/usps_api/models/international_prices_letter_rate_details.rb', line 35

def fees
  @fees
end

#mail_classMailClass3

The mail class of the price.

Returns:



48
49
50
# File 'lib/usps_api/models/international_prices_letter_rate_details.rb', line 48

def mail_class
  @mail_class
end

#priceFloat

The postage price.

Returns:

  • (Float)


26
27
28
# File 'lib/usps_api/models/international_prices_letter_rate_details.rb', line 26

def price
  @price
end

#price_typePriceType3

The type of price type applied (Retail).

Returns:



22
23
24
# File 'lib/usps_api/models/international_prices_letter_rate_details.rb', line 22

def price_type
  @price_type
end

#skuString

The stock keeping unit for the designated rate.

Returns:

  • (String)


14
15
16
# File 'lib/usps_api/models/international_prices_letter_rate_details.rb', line 14

def sku
  @sku
end

#start_dateDate

Effective start date of the rate.

Returns:

  • (Date)


39
40
41
# File 'lib/usps_api/models/international_prices_letter_rate_details.rb', line 39

def start_date
  @start_date
end

#weightFloat

The calculated weight for the package based on user input. The greater of dimWeight and weight will be used to calculated the rate.

Returns:

  • (Float)


31
32
33
# File 'lib/usps_api/models/international_prices_letter_rate_details.rb', line 31

def weight
  @weight
end

#zoneString

Indicates the price group for a given ‘destinationCountryCode` and `mailingDate`.

Returns:

  • (String)


59
60
61
# File 'lib/usps_api/models/international_prices_letter_rate_details.rb', line 59

def zone
  @zone
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/usps_api/models/international_prices_letter_rate_details.rb', line 122

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  sku = hash.key?('SKU') ? hash['SKU'] : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP
  price_type = hash.key?('priceType') ? hash['priceType'] : SKIP
  price = hash.key?('price') ? hash['price'] : SKIP
  weight = hash.key?('weight') ? hash['weight'] : SKIP
  # Parameter is an array, so we need to iterate through it
  fees = nil
  unless hash['fees'].nil?
    fees = []
    hash['fees'].each do |structure|
      fees << (Fee1.from_hash(structure) if structure)
    end
  end

  fees = SKIP unless hash.key?('fees')
  start_date = hash.key?('startDate') ? hash['startDate'] : SKIP
  end_date = hash.key?('endDate') ? hash['endDate'] : SKIP
  mail_class = hash.key?('mailClass') ? hash['mailClass'] : SKIP
  # Parameter is an array, so we need to iterate through it
  extra_services = nil
  unless hash['extraServices'].nil?
    extra_services = []
    hash['extraServices'].each do |structure|
      extra_services << (ExtraService3.from_hash(structure) if structure)
    end
  end

  extra_services = SKIP unless hash.key?('extraServices')
  zone = hash.key?('zone') ? hash['zone'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  InternationalPricesLetterRateDetails.new(sku: sku,
                                           description: description,
                                           price_type: price_type,
                                           price: price,
                                           weight: weight,
                                           fees: fees,
                                           start_date: start_date,
                                           end_date: end_date,
                                           mail_class: mail_class,
                                           extra_services: extra_services,
                                           zone: zone,
                                           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/usps_api/models/international_prices_letter_rate_details.rb', line 62

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['sku'] = 'SKU'
  @_hash['description'] = 'description'
  @_hash['price_type'] = 'priceType'
  @_hash['price'] = 'price'
  @_hash['weight'] = 'weight'
  @_hash['fees'] = 'fees'
  @_hash['start_date'] = 'startDate'
  @_hash['end_date'] = 'endDate'
  @_hash['mail_class'] = 'mailClass'
  @_hash['extra_services'] = 'extraServices'
  @_hash['zone'] = 'zone'
  @_hash
end

.nullablesObject

An array for nullable fields



96
97
98
# File 'lib/usps_api/models/international_prices_letter_rate_details.rb', line 96

def self.nullables
  []
end

.optionalsObject

An array for optional fields



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/usps_api/models/international_prices_letter_rate_details.rb', line 79

def self.optionals
  %w[
    sku
    description
    price_type
    price
    weight
    fees
    start_date
    end_date
    mail_class
    extra_services
    zone
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



188
189
190
191
192
193
194
195
# File 'lib/usps_api/models/international_prices_letter_rate_details.rb', line 188

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} sku: #{@sku.inspect}, description: #{@description.inspect}, price_type:"\
  " #{@price_type.inspect}, price: #{@price.inspect}, weight: #{@weight.inspect}, fees:"\
  " #{@fees.inspect}, start_date: #{@start_date.inspect}, end_date: #{@end_date.inspect},"\
  " mail_class: #{@mail_class.inspect}, extra_services: #{@extra_services.inspect}, zone:"\
  " #{@zone.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



179
180
181
182
183
184
185
# File 'lib/usps_api/models/international_prices_letter_rate_details.rb', line 179

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} sku: #{@sku}, description: #{@description}, price_type: #{@price_type},"\
  " price: #{@price}, weight: #{@weight}, fees: #{@fees}, start_date: #{@start_date},"\
  " end_date: #{@end_date}, mail_class: #{@mail_class}, extra_services: #{@extra_services},"\
  " zone: #{@zone}, additional_properties: #{@additional_properties}>"
end