Class: USPS::Request::SignatureConfirmation

Inherits:
Base
  • Object
show all
Defined in:
lib/usps/request/signature_confirmation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#api, config, #response_for, #secure?, #send!

Constructor Details

#initialize(to, from, weight, service = 'Priority') ⇒ SignatureConfirmation

Returns a new instance of SignatureConfirmation.



12
13
14
15
16
17
# File 'lib/usps/request/signature_confirmation.rb', line 12

def initialize(to, from, weight, service = 'Priority')
  @to = to
  @from = from
  @weight = weight
  @service = service
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



10
11
12
# File 'lib/usps/request/signature_confirmation.rb', line 10

def from
  @from
end

#serviceObject (readonly)

Returns the value of attribute service.



10
11
12
# File 'lib/usps/request/signature_confirmation.rb', line 10

def service
  @service
end

#toObject (readonly)

Returns the value of attribute to.



10
11
12
# File 'lib/usps/request/signature_confirmation.rb', line 10

def to
  @to
end

#weightObject (readonly)

Returns the value of attribute weight.



10
11
12
# File 'lib/usps/request/signature_confirmation.rb', line 10

def weight
  @weight
end

Instance Method Details

#buildObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/usps/request/signature_confirmation.rb', line 19

def build
  super do |builder|
    builder.tag!('Option', '1')
    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)
    builder.tag!('ServiceType', self.service)
    builder.tag!('ImageType', 'TIF')
  end
end