Class: ShippingScale::Request
- Inherits:
-
Object
- Object
- ShippingScale::Request
- Defined in:
- lib/shipping_scale/request.rb
Class Attribute Summary collapse
-
.api ⇒ Object
readonly
Returns the value of attribute api.
-
.secure ⇒ Object
readonly
Returns the value of attribute secure.
-
.tag ⇒ Object
readonly
Returns the value of attribute tag.
Instance Attribute Summary collapse
-
#packages ⇒ Object
readonly
Returns the value of attribute packages.
-
#response ⇒ Object
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
- #api ⇒ Object
- #build ⇒ Object
-
#initialize(options = {}) ⇒ Request
constructor
A new instance of Request.
- #secure? ⇒ Boolean
- #send! ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Request
Returns a new instance of Request.
16 17 18 19 |
# File 'lib/shipping_scale/request.rb', line 16 def initialize(={}) @response = [:response] @packages = [:packages] end |
Class Attribute Details
.api ⇒ Object (readonly)
Returns the value of attribute api.
4 5 6 |
# File 'lib/shipping_scale/request.rb', line 4 def api @api end |
.secure ⇒ Object (readonly)
Returns the value of attribute secure.
4 5 6 |
# File 'lib/shipping_scale/request.rb', line 4 def secure @secure end |
.tag ⇒ Object (readonly)
Returns the value of attribute tag.
4 5 6 |
# File 'lib/shipping_scale/request.rb', line 4 def tag @tag end |
Instance Attribute Details
#packages ⇒ Object (readonly)
Returns the value of attribute packages.
22 23 24 |
# File 'lib/shipping_scale/request.rb', line 22 def packages @packages end |
#response ⇒ Object
Returns the value of attribute response.
21 22 23 |
# File 'lib/shipping_scale/request.rb', line 21 def response @response end |
Class Method Details
.config(options = {}) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/shipping_scale/request.rb', line 6 def config( = {}) defaults = {api: "RateV4", tag: "RateV4Request"} = defaults.merge() @api = [:api] @tag = [:tag] @secure = !![:secure] end |
Instance Method Details
#api ⇒ Object
28 29 30 |
# File 'lib/shipping_scale/request.rb', line 28 def api self.class.api end |
#build ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/shipping_scale/request.rb', line 32 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 |
#secure? ⇒ Boolean
24 25 26 |
# File 'lib/shipping_scale/request.rb', line 24 def secure? !!self.class.secure end |
#send! ⇒ Object
40 41 42 |
# File 'lib/shipping_scale/request.rb', line 40 def send! ShippingScale.client.request(self) end |