Class: USPS::Request::DeliveryConfirmation
- Defined in:
- lib/usps/request/delivery_confirmation.rb
Direct Known Subclasses
Constant Summary collapse
- DEFAULTS =
{ :type => 1, :format => 'TIF', :service => 'Priority' }.freeze
- OPTIONS =
List of valid options and their mapping to their tag
{ :type => 'Option', :service => 'ServiceType', :po_zip_code => 'PoZipCode', :label_date => 'LabelDate', :customer_reference => 'CustomerRefNo', :separate_receipt => 'SeparateReceiptPage', :address_service => 'AddressServiceRequested', :sender_name => 'SenderName', :sender_email => 'SenderEMail', :recipient_name => 'RecipientName', :recipient_email => 'RecipientEMail' }.freeze
- FORMATS =
%w(TIF PDF).freeze
Instance Attribute Summary collapse
-
#format ⇒ Object
Returns the value of attribute format.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(to, from, weight, options = {}) ⇒ DeliveryConfirmation
constructor
Options: * <tt>:.
Methods inherited from Base
#api, config, #response_for, #secure?, #send!
Constructor Details
#initialize(to, from, weight, options = {}) ⇒ DeliveryConfirmation
Options:
-
<tt>:
37 38 39 40 41 42 43 44 45 |
# File 'lib/usps/request/delivery_confirmation.rb', line 37 def initialize(to, from, weight, = {}) @to = to @from = from @weight = weight @options = DEFAULTS.merge() @type = @options.delete(:type) self.format = @options.delete(:format) end |
Instance Attribute Details
#format ⇒ Object
Returns the value of attribute format.
10 11 12 |
# File 'lib/usps/request/delivery_confirmation.rb', line 10 def format @format end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
10 11 12 |
# File 'lib/usps/request/delivery_confirmation.rb', line 10 def from @from end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/usps/request/delivery_confirmation.rb', line 10 def @options end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
10 11 12 |
# File 'lib/usps/request/delivery_confirmation.rb', line 10 def to @to end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
10 11 12 |
# File 'lib/usps/request/delivery_confirmation.rb', line 10 def weight @weight end |
Instance Method Details
#build ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/usps/request/delivery_confirmation.rb', line 57 def build super do |builder| builder.tag!('Option', @type) builder.tag!('ImageParameters') [ [self.from, 'From'], [self.to, 'To'] ].each do |address, prefix| builder.tag!("#{prefix}Name", address.name) builder.tag!("#{prefix}Firm", address.company) builder.tag!("#{prefix}Address1", address.extra_address) builder.tag!("#{prefix}Address2", address.address) builder.tag!("#{prefix}City", address.city) builder.tag!("#{prefix}State", address.state) builder.tag!("#{prefix}Zip5", address.zip5) builder.tag!("#{prefix}Zip4", address.zip4) end builder.tag!('WeightInOunces', self.weight) @options.each_pair do |k,v| OPTIONS[k].tap do |tag| builder.tag!(tag, v.to_s) if tag end end builder.tag!('ImageType', @format) end end |