Class: FriendlyShipping::Services::Usps::RateEstimatePackageOptions
- Inherits:
-
PackageOptions
- Object
- PackageOptions
- FriendlyShipping::Services::Usps::RateEstimatePackageOptions
- Defined in:
- lib/friendly_shipping/services/usps/rate_estimate_package_options.rb
Instance Attribute Summary collapse
-
#box_name ⇒ Object
readonly
Returns the value of attribute box_name.
-
#commercial_pricing ⇒ Object
readonly
Returns the value of attribute commercial_pricing.
-
#first_class_mail_type ⇒ Object
readonly
Returns the value of attribute first_class_mail_type.
-
#hold_for_pickup ⇒ Object
readonly
Returns the value of attribute hold_for_pickup.
-
#rectangular ⇒ Object
readonly
Returns the value of attribute rectangular.
-
#return_dimensional_weight ⇒ Object
readonly
Returns the value of attribute return_dimensional_weight.
-
#return_fees ⇒ Object
readonly
Returns the value of attribute return_fees.
-
#shipping_method ⇒ Object
readonly
Returns the value of attribute shipping_method.
-
#transmit_dimensions ⇒ Object
readonly
Returns the value of attribute transmit_dimensions.
Attributes inherited from PackageOptions
Instance Method Summary collapse
- #container_code ⇒ Object
- #first_class_mail_type_code ⇒ Object
-
#initialize(**kwargs) ⇒ RateEstimatePackageOptions
constructor
A new instance of RateEstimatePackageOptions.
- #service_code ⇒ Object
Methods inherited from PackageOptions
Constructor Details
#initialize(**kwargs) ⇒ RateEstimatePackageOptions
Returns a new instance of RateEstimatePackageOptions.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 27 def initialize(**kwargs) box_name = value_or_default(:box_name, :variable, kwargs) @box_name = CONTAINERS.key?(box_name) ? box_name : :variable @commercial_pricing = value_or_default(:commercial_pricing, false, kwargs) @first_class_mail_type = kwargs.delete(:first_class_mail_type) @hold_for_pickup = value_or_default(:hold_for_pickup, false, kwargs) @shipping_method = kwargs.delete(:shipping_method) @transmit_dimensions = value_or_default(:transmit_dimensions, true, kwargs) @rectangular = value_or_default(:rectangular, true, kwargs) @return_dimensional_weight = value_or_default(:return_dimensional_weight, true, kwargs) @return_fees = value_or_default(:return_fees, false, kwargs) super(**kwargs) end |
Instance Attribute Details
#box_name ⇒ Object (readonly)
Returns the value of attribute box_name.
17 18 19 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 17 def box_name @box_name end |
#commercial_pricing ⇒ Object (readonly)
Returns the value of attribute commercial_pricing.
17 18 19 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 17 def commercial_pricing @commercial_pricing end |
#first_class_mail_type ⇒ Object (readonly)
Returns the value of attribute first_class_mail_type.
17 18 19 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 17 def first_class_mail_type @first_class_mail_type end |
#hold_for_pickup ⇒ Object (readonly)
Returns the value of attribute hold_for_pickup.
17 18 19 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 17 def hold_for_pickup @hold_for_pickup end |
#rectangular ⇒ Object (readonly)
Returns the value of attribute rectangular.
17 18 19 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 17 def rectangular @rectangular end |
#return_dimensional_weight ⇒ Object (readonly)
Returns the value of attribute return_dimensional_weight.
17 18 19 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 17 def return_dimensional_weight @return_dimensional_weight end |
#return_fees ⇒ Object (readonly)
Returns the value of attribute return_fees.
17 18 19 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 17 def return_fees @return_fees end |
#shipping_method ⇒ Object (readonly)
Returns the value of attribute shipping_method.
17 18 19 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 17 def shipping_method @shipping_method end |
#transmit_dimensions ⇒ Object (readonly)
Returns the value of attribute transmit_dimensions.
17 18 19 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 17 def transmit_dimensions @transmit_dimensions end |
Instance Method Details
#container_code ⇒ Object
41 42 43 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 41 def container_code CONTAINERS.fetch(box_name) end |
#first_class_mail_type_code ⇒ Object
45 46 47 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 45 def first_class_mail_type_code FIRST_CLASS_MAIL_TYPES[first_class_mail_type] end |
#service_code ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 49 def service_code return 'ALL' unless shipping_method # Cubic shipping methods don't have HFP or COMMERCIAL modifiers return shipping_method.service_code if shipping_method.service_code =~ /CUBIC/ service_code = [shipping_method.service_code] service_code << 'HFP' if hold_for_pickup service_code << 'COMMERCIAL' if commercial_pricing service_code.join(' ') end |