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.
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 25 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.
15 16 17 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 15 def box_name @box_name end |
#commercial_pricing ⇒ Object (readonly)
Returns the value of attribute commercial_pricing.
15 16 17 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 15 def commercial_pricing @commercial_pricing end |
#first_class_mail_type ⇒ Object (readonly)
Returns the value of attribute first_class_mail_type.
15 16 17 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 15 def first_class_mail_type @first_class_mail_type end |
#hold_for_pickup ⇒ Object (readonly)
Returns the value of attribute hold_for_pickup.
15 16 17 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 15 def hold_for_pickup @hold_for_pickup end |
#rectangular ⇒ Object (readonly)
Returns the value of attribute rectangular.
15 16 17 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 15 def rectangular @rectangular end |
#return_dimensional_weight ⇒ Object (readonly)
Returns the value of attribute return_dimensional_weight.
15 16 17 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 15 def return_dimensional_weight @return_dimensional_weight end |
#return_fees ⇒ Object (readonly)
Returns the value of attribute return_fees.
15 16 17 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 15 def return_fees @return_fees end |
#shipping_method ⇒ Object (readonly)
Returns the value of attribute shipping_method.
15 16 17 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 15 def shipping_method @shipping_method end |
#transmit_dimensions ⇒ Object (readonly)
Returns the value of attribute transmit_dimensions.
15 16 17 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 15 def transmit_dimensions @transmit_dimensions end |
Instance Method Details
#container_code ⇒ Object
39 40 41 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 39 def container_code CONTAINERS.fetch(box_name) end |
#first_class_mail_type_code ⇒ Object
43 44 45 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 43 def first_class_mail_type_code FIRST_CLASS_MAIL_TYPES[first_class_mail_type] end |
#service_code ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/friendly_shipping/services/usps/rate_estimate_package_options.rb', line 47 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 |