Class: USPS::Request::Base
- Inherits:
-
Object
- Object
- USPS::Request::Base
- Defined in:
- lib/usps/request/base.rb
Direct Known Subclasses
AddressStandardization, CityAndStateLookup, DeliveryConfirmation, TrackingFieldLookup, TrackingLookup, ZipCodeLookup
Class Attribute Summary collapse
-
.api ⇒ Object
readonly
Returns the value of attribute api.
-
.response ⇒ Object
readonly
Returns the value of attribute response.
-
.secure ⇒ Object
(also: secure?)
readonly
Returns the value of attribute secure.
-
.tag ⇒ Object
readonly
Returns the value of attribute tag.
Class Method Summary collapse
-
.config(options = {}) ⇒ Object
Config given api: The USPS API name as given in the request URL tag: The root tag used for the request secure: Whether or not the request is against the secure server response: The USPS::Response class used to handle responses.
Instance Method Summary collapse
- #api ⇒ Object
- #build(&block) ⇒ Object
- #response_for(xml) ⇒ Object
- #secure? ⇒ Boolean
- #send! ⇒ Object
Class Attribute Details
.api ⇒ Object (readonly)
Returns the value of attribute api.
4 5 6 |
# File 'lib/usps/request/base.rb', line 4 def api @api end |
.response ⇒ Object (readonly)
Returns the value of attribute response.
4 5 6 |
# File 'lib/usps/request/base.rb', line 4 def response @response end |
.secure ⇒ Object (readonly) Also known as: secure?
Returns the value of attribute secure.
4 5 6 |
# File 'lib/usps/request/base.rb', line 4 def secure @secure end |
.tag ⇒ Object (readonly)
Returns the value of attribute tag.
4 5 6 |
# File 'lib/usps/request/base.rb', line 4 def tag @tag end |
Class Method Details
.config(options = {}) ⇒ Object
Config given
api: The USPS API name as given in the request URL
tag: The root tag used for the request
secure: Whether or not the request is against the secure server
response: The USPS::Response class used to handle responses
13 14 15 16 17 18 |
# File 'lib/usps/request/base.rb', line 13 def config( = {}) @api = [:api].to_s @tag = [:tag].to_s @secure = !![:secure] @response = [:response] end |
Instance Method Details
#api ⇒ Object
29 30 31 |
# File 'lib/usps/request/base.rb', line 29 def api self.class.api end |
#build(&block) ⇒ Object
37 38 39 40 |
# File 'lib/usps/request/base.rb', line 37 def build(&block) builder = Builder::XmlMarkup.new(:indent => 0) builder.tag!(self.class.tag, :USERID => USPS.config.username, &block) end |
#response_for(xml) ⇒ Object
33 34 35 |
# File 'lib/usps/request/base.rb', line 33 def response_for(xml) self.class.response.parse(xml) end |
#secure? ⇒ Boolean
25 26 27 |
# File 'lib/usps/request/base.rb', line 25 def secure? !!self.class.secure? end |