Sha256: 64c0ccc2ebba8ad5c2b6b3c6d523db24a8aea62bf412b636827f89a203a9a32c
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
module ShippingScale class Request class << self attr_reader :api, :tag, :secure def config(options = {}) defaults = {api: "RateV4", tag: "RateV4Request"} options = defaults.merge(options) @api = options[:api] @tag = options[:tag] @secure = !!options[:secure] end end def initialize(options={}) @response = options[:response] @packages = options[:packages] end attr_accessor :response attr_reader :packages def secure? !!self.class.secure end def api self.class.api end def build xml.tag!(self.class.tag, USERID: ShippingScale.config.user_id) do |req| req.tag!("Revision", "2") packages_to_xml(req) end end def send! ShippingScale.client.request(self) end private def packages_to_xml(xml) i = 1 packages.each do |package| xml.tag!("Package", ID: i) { |pac| package.build_xml(pac) } i += 1 end end def xml @_xml ||= Builder::XmlMarkup.new(indent: 0) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shipping-scale-0.1.0 | lib/shipping_scale/request.rb |