Sha256: dbd1d2cb50d138aec910bcf13a7b45eb45fe1fc3d8f0449de7fac3714b29e25a
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 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 xml 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.2 | lib/shipping_scale/request.rb |