Class: ShippingScale::Package
- Inherits:
-
Object
- Object
- ShippingScale::Package
- Defined in:
- lib/shipping_scale/package.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #build_xml(package) ⇒ Object
- #details ⇒ Object
- #get_price!(options = {}) ⇒ Object
-
#initialize(**options) ⇒ Package
constructor
A new instance of Package.
- #price ⇒ Object
Constructor Details
#initialize(**options) ⇒ Package
Returns a new instance of Package.
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/shipping_scale/package.rb', line 3 def initialize(**) @weight = [:weight] @pounds = [:pounds] @ounces = [:ounces] @length = [:length] @width = [:width] @height = [:height] @zip_origin = ([:zip_origin]) ? [:zip_origin] : ShippingScale.config.zip_origin @zip_destination = ([:zip_destination]) ? [:zip_destination] : ShippingScale.config.zip_destination @attrs = end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
16 17 18 |
# File 'lib/shipping_scale/package.rb', line 16 def response @response end |
Instance Method Details
#build_xml(package) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/shipping_scale/package.rb', line 18 def build_xml(package) package.tag!("Service", "All") package.tag!("Container", "VARAIBLE") package.tag!("Size", "REGULAR") @attrs.each { |k, v| package.tag!(k.to_s, v) } end |
#details ⇒ Object
34 35 36 |
# File 'lib/shipping_scale/package.rb', line 34 def details response.details end |
#get_price!(options = {}) ⇒ Object
25 26 27 28 |
# File 'lib/shipping_scale/package.rb', line 25 def get_price!( = {}) ShippingScale::Request.config() @response = ShippingScale::Request.new(packages: [self]).send! end |
#price ⇒ Object
30 31 32 |
# File 'lib/shipping_scale/package.rb', line 30 def price response.price end |