module Usps::Api::Endpoints::PTSEmail

Public Instance Methods

pts_email(options = {}) click to toggle source

The Track and Confirm by Email API allows the customer to submit their email address to be notified of current or future tracking activity. When you request access for this API, please identify your anticipated API volume, mailer ID and how you will be utilizing this API. A mailer identification number (MID) is a 6 or 9-digit number assigned to a customer through the USPS Business Customer Gateway (BCG). Please refer to the following links for help: @param [Hash] options @option options [required, Hash] pts_email_request

* *:track_id* (required, String)
* *:client_ip* (String)
* *:source_id* (String)
* *:mp_suffix* (required, Integer)
* *:mp_date* (required, String)
* *:request_type* (Request Type)
* *:first_name* (String)
* *:last_name* (String)
* *:email1* (required, String)
* *:email2* (String)
* *:email3* (String)
# File lib/usps/api/endpoints/pts_email.rb, line 29
def pts_email(options = {})
                                        throw ArgumentError.new('Required arguments :pts_email_request missing') if options[:pts_email_request].nil?
                                        throw ArgumentError.new('Required arguments :pts_email_request, :track_id missing') if options[:pts_email_request][:track_id].nil?
                                        throw ArgumentError.new('Required arguments :pts_email_request, :mp_suffix missing') if options[:pts_email_request][:mp_suffix].nil?
                                        throw ArgumentError.new('Required arguments :pts_email_request, :mp_date missing') if options[:pts_email_request][:mp_date].nil?
                                        throw ArgumentError.new('Required arguments :pts_email_request, :email1 missing') if options[:pts_email_request][:email1].nil?

                                        request = build_request(:pts_email, options)
                                        get('https://secure.shippingapis.com/ShippingAPI.dll', {
                                                API: 'PTSEmail',
                                                XML: request,
                                        })
                                end

Private Instance Methods

build_pts_email_request(xml, options = {}) click to toggle source
# File lib/usps/api/endpoints/pts_email.rb, line 49
def build_pts_email_request(xml, options = {})
        xml.tag!('TrackId', options[:pts_email_request][:track_id])
        tag_unless_blank(xml, 'ClientIp', options[:pts_email_request][:client_ip])
        tag_unless_blank(xml, 'SourceId', options[:pts_email_request][:source_id])
        xml.tag!('MpSuffix', options[:pts_email_request][:mp_suffix])
        xml.tag!('MpDate', options[:pts_email_request][:mp_date])
        tag_unless_blank(xml, 'RequestType', options[:pts_email_request][:request_type])
        tag_unless_blank(xml, 'FirstName', options[:pts_email_request][:first_name])
        tag_unless_blank(xml, 'LastName', options[:pts_email_request][:last_name])
        xml.tag!('Email1', options[:pts_email_request][:email1])
        tag_unless_blank(xml, 'Email2', options[:pts_email_request][:email2])
        tag_unless_blank(xml, 'Email3', options[:pts_email_request][:email3])
        xml.target!
end
tag_unless_blank(xml, tag_name, data) click to toggle source
# File lib/usps/api/endpoints/pts_email.rb, line 45
def tag_unless_blank(xml, tag_name, data)
        xml.tag!(tag_name, data) unless data.blank? || data.nil?
end