Class: UspsApi::InternationalPricingOption
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UspsApi::InternationalPricingOption
- Defined in:
- lib/usps_api/models/international_pricing_option.rb
Overview
Option for international pricing
Instance Attribute Summary collapse
-
#payment_account ⇒ ShipmentsPaymentAccount
Payment account information.
-
#price_type ⇒ ShipmentsPriceType1
Price type of the Shipping Request.
-
#shipping_options ⇒ Array[InternationalOptions]
List of available shipping services and delivery options for the package.
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(shipping_options: SKIP, price_type: ShipmentsPriceType1::COMMERCIAL, payment_account: SKIP) ⇒ InternationalPricingOption
constructor
A new instance of InternationalPricingOption.
-
#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(shipping_options: SKIP, price_type: ShipmentsPriceType1::COMMERCIAL, payment_account: SKIP) ⇒ InternationalPricingOption
Returns a new instance of InternationalPricingOption.
49 50 51 52 53 54 55 |
# File 'lib/usps_api/models/international_pricing_option.rb', line 49 def initialize(shipping_options: SKIP, price_type: ShipmentsPriceType1::COMMERCIAL, payment_account: SKIP) @shipping_options = unless == SKIP @price_type = price_type unless price_type == SKIP @payment_account = payment_account unless payment_account == SKIP end |
Instance Attribute Details
#payment_account ⇒ ShipmentsPaymentAccount
Payment account information. Used only if ‘priceType` is `CONTRACT`.
24 25 26 |
# File 'lib/usps_api/models/international_pricing_option.rb', line 24 def payment_account @payment_account end |
#price_type ⇒ ShipmentsPriceType1
Price type of the Shipping Request. Note:
-
If ‘priceType` is `CONTRACT`, `paymentAccount` is required.
20 21 22 |
# File 'lib/usps_api/models/international_pricing_option.rb', line 20 def price_type @price_type end |
#shipping_options ⇒ Array[InternationalOptions]
List of available shipping services and delivery options for the package
14 15 16 |
# File 'lib/usps_api/models/international_pricing_option.rb', line 14 def @shipping_options end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/usps_api/models/international_pricing_option.rb', line 58 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. # Parameter is an array, so we need to iterate through it = nil unless hash['shippingOptions'].nil? = [] hash['shippingOptions'].each do |structure| << (InternationalOptions.from_hash(structure) if structure) end end = SKIP unless hash.key?('shippingOptions') price_type = hash['priceType'] ||= ShipmentsPriceType1::COMMERCIAL payment_account = ShipmentsPaymentAccount.from_hash(hash['paymentAccount']) if hash['paymentAccount'] # Create object from extracted values. InternationalPricingOption.new(shipping_options: , price_type: price_type, payment_account: payment_account) end |
.names ⇒ Object
A mapping from model property names to API property names.
27 28 29 30 31 32 33 |
# File 'lib/usps_api/models/international_pricing_option.rb', line 27 def self.names @_hash = {} if @_hash.nil? @_hash['shipping_options'] = 'shippingOptions' @_hash['price_type'] = 'priceType' @_hash['payment_account'] = 'paymentAccount' @_hash end |
.nullables ⇒ Object
An array for nullable fields
45 46 47 |
# File 'lib/usps_api/models/international_pricing_option.rb', line 45 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
36 37 38 39 40 41 42 |
# File 'lib/usps_api/models/international_pricing_option.rb', line 36 def self.optionals %w[ shipping_options price_type payment_account ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
84 85 86 87 88 89 90 |
# File 'lib/usps_api/models/international_pricing_option.rb', line 84 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
100 101 102 103 104 |
# File 'lib/usps_api/models/international_pricing_option.rb', line 100 def inspect class_name = self.class.name.split('::').last "<#{class_name} shipping_options: #{@shipping_options.inspect}, price_type:"\ " #{@price_type.inspect}, payment_account: #{@payment_account.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
93 94 95 96 97 |
# File 'lib/usps_api/models/international_pricing_option.rb', line 93 def to_s class_name = self.class.name.split('::').last "<#{class_name} shipping_options: #{@shipping_options}, price_type: #{@price_type},"\ " payment_account: #{@payment_account}>" end |