Sha256: 911128096abb904bf51973cdc588b18572b882b29545f6eb5e543da4f3f50b31

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

module ShippingScale
  class Package
    def initialize(**options)
      @weight = options[:weight]
      @pounds = options[:pounds]
      @ounces = options[:ounces]
      @length = options[:length]
      @width = options[:width]
      @height = options[:height]
      @zip_origin = (options[:zip_origin]) ? options[:zip_origin] : ShippingScale.config.zip_origin 
      @zip_destination = (options[:zip_destination]) ? options[:zip_destination] : ShippingScale.config.zip_destination

      @attrs = options
    end

    attr_accessor :response
    
    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

    def get_price!(options = {})
      ShippingScale::Request.config(options)
      @response = ShippingScale::Request.new(packages: [self]).send!     
    end

    def price 
      response.price
    end

    def details
      response.details
    end

    #TODO set methods to determin service, container, and size
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shipping-scale-0.1.0 lib/shipping_scale/package.rb