usps-ruby-client 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitattributes +2 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +41 -0
- data/.rubocop_todo.yml +0 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +77 -0
- data/Rakefile +9 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/data/api/address-information-api.htm +8229 -0
- data/lib/data/api/domestic-mail-service-standards-api.htm +11016 -0
- data/lib/data/api/evs-international-label-api.htm +33291 -0
- data/lib/data/api/evs-label-api.htm +18895 -0
- data/lib/data/api/hold-for-pickup-facilities-lookup-api.htm +5530 -0
- data/lib/data/api/package-pickup-api.htm +19157 -0
- data/lib/data/api/rate-calculator-api.htm +16355 -0
- data/lib/data/api/scan-api.htm +5934 -0
- data/lib/data/api/service-delivery-calculator-get-locations-api.htm +12548 -0
- data/lib/data/api/track-and-confirm-api.htm +21288 -0
- data/lib/data/api/uspsreturnslabel-api.htm +9474 -0
- data/lib/helpers/erubis_helper.rb +10 -0
- data/lib/tasks/api.rake +246 -0
- data/lib/usps-ruby-client.rb +30 -0
- data/lib/usps/api/endpoints.rb +70 -0
- data/lib/usps/api/endpoints/carrier_pickup_schedule.rb +117 -0
- data/lib/usps/api/endpoints/city_state_lookup.rb +50 -0
- data/lib/usps/api/endpoints/e_vs_express_mail_intl.rb +359 -0
- data/lib/usps/api/endpoints/e_vs_first_class_mail_intl.rb +323 -0
- data/lib/usps/api/endpoints/e_vs_priority_mail_intl.rb +366 -0
- data/lib/usps/api/endpoints/e_vsgxg_get_label.rb +366 -0
- data/lib/usps/api/endpoints/e_vsi_cancel.rb +55 -0
- data/lib/usps/api/endpoints/hfp_facility_info.rb +71 -0
- data/lib/usps/api/endpoints/intl_rate_v2.rb +135 -0
- data/lib/usps/api/endpoints/pts_email.rb +73 -0
- data/lib/usps/api/endpoints/pts_pod.rb +86 -0
- data/lib/usps/api/endpoints/pts_rre.rb +72 -0
- data/lib/usps/api/endpoints/ptst_pod.rb +75 -0
- data/lib/usps/api/endpoints/rate_v4.rb +140 -0
- data/lib/usps/api/endpoints/scan.rb +121 -0
- data/lib/usps/api/endpoints/track_v2.rb +62 -0
- data/lib/usps/api/endpoints/usps_returns_label.rb +149 -0
- data/lib/usps/api/endpoints/verify.rb +75 -0
- data/lib/usps/api/endpoints/zip_code_lookup.rb +69 -0
- data/lib/usps/api/error.rb +6 -0
- data/lib/usps/api/errors/too_many_requests_error.rb +22 -0
- data/lib/usps/api/errors/usps_error.rb +30 -0
- data/lib/usps/api/templates/_build_xml.erb +7 -0
- data/lib/usps/api/templates/_options.erb +6 -0
- data/lib/usps/api/templates/_throw_argument_error.erb +3 -0
- data/lib/usps/api/templates/endpoints.erb +22 -0
- data/lib/usps/api/templates/method.erb +49 -0
- data/lib/usps/api/templates/method_spec.erb +22 -0
- data/lib/usps/api/xml.rb +8 -0
- data/lib/usps/client.rb +37 -0
- data/lib/usps/config.rb +50 -0
- data/lib/usps/faraday/connection.rb +34 -0
- data/lib/usps/faraday/request.rb +39 -0
- data/lib/usps/faraday/response/raise_error.rb +16 -0
- data/lib/usps/logger.rb +14 -0
- data/lib/usps/version.rb +4 -0
- data/usps-ruby-client.gemspec +46 -0
- metadata +307 -0
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file was auto-generated by lib/tasks/api.rake
|
4
|
+
|
5
|
+
module Usps
|
6
|
+
module Api
|
7
|
+
module Endpoints
|
8
|
+
module PTSTPod
|
9
|
+
#
|
10
|
+
# Track Proof of Delivery API
|
11
|
+
#
|
12
|
+
# Overview
|
13
|
+
#
|
14
|
+
# @option option [(Alias)] :PTSTPodRequest (Required)
|
15
|
+
# @option option [String] :TrackId (Required)
|
16
|
+
# @option option [integer] :MpSuffix (Required)
|
17
|
+
# @option option [String] :MpDate (Required)
|
18
|
+
# @option option [String] :RequestType (Required)
|
19
|
+
# @option option [String] :FirstName (Required)
|
20
|
+
# @option option [String] :LastName (Required)
|
21
|
+
# @option option [String] :Email1 (Optional)
|
22
|
+
# @option option [String] :Email2 (Optional)
|
23
|
+
# @option option [String] :Email3 (Optional)
|
24
|
+
# @option option [String] :CustRegID (Required)
|
25
|
+
# @option option [String] :TableCode (Required)
|
26
|
+
# @option option [String] :ClientIp (Optional)
|
27
|
+
# @option option [String] :SourceId (Optional)
|
28
|
+
|
29
|
+
#
|
30
|
+
# @see
|
31
|
+
def ptst_pod(options = {})
|
32
|
+
throw ArgumentError.new('Required arguments :ptst_pod_request missing') if options[:ptst_pod_request].nil?
|
33
|
+
throw ArgumentError.new('Required arguments :ptst_pod_request, :track_id missing') if options[:ptst_pod_request][:track_id].nil?
|
34
|
+
throw ArgumentError.new('Required arguments :ptst_pod_request, :mp_suffix missing') if options[:ptst_pod_request][:mp_suffix].nil?
|
35
|
+
throw ArgumentError.new('Required arguments :ptst_pod_request, :mp_date missing') if options[:ptst_pod_request][:mp_date].nil?
|
36
|
+
throw ArgumentError.new('Required arguments :ptst_pod_request, :request_type missing') if options[:ptst_pod_request][:request_type].nil?
|
37
|
+
throw ArgumentError.new('Required arguments :ptst_pod_request, :first_name missing') if options[:ptst_pod_request][:first_name].nil?
|
38
|
+
throw ArgumentError.new('Required arguments :ptst_pod_request, :last_name missing') if options[:ptst_pod_request][:last_name].nil?
|
39
|
+
throw ArgumentError.new('Required arguments :ptst_pod_request, :cust_reg_id missing') if options[:ptst_pod_request][:cust_reg_id].nil?
|
40
|
+
throw ArgumentError.new('Required arguments :ptst_pod_request, :table_code missing') if options[:ptst_pod_request][:table_code].nil?
|
41
|
+
|
42
|
+
request = build_request(:ptst_pod, options)
|
43
|
+
get('https://secure.shippingapis.com/ShippingAPI.dll', {
|
44
|
+
API: 'PTSTPod',
|
45
|
+
XML: request,
|
46
|
+
})
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def tag_unless_blank(xml, tag_name, data)
|
52
|
+
xml.tag!(tag_name, data) unless data.blank? || data.nil?
|
53
|
+
end
|
54
|
+
|
55
|
+
def build_ptst_pod_request(xml, options = {})
|
56
|
+
xml.tag!('TrackId', options[:ptst_pod_request][:track_id])
|
57
|
+
xml.tag!('MpSuffix', options[:ptst_pod_request][:mp_suffix])
|
58
|
+
xml.tag!('MpDate', options[:ptst_pod_request][:mp_date])
|
59
|
+
xml.tag!('RequestType', options[:ptst_pod_request][:request_type])
|
60
|
+
xml.tag!('FirstName', options[:ptst_pod_request][:first_name])
|
61
|
+
xml.tag!('LastName', options[:ptst_pod_request][:last_name])
|
62
|
+
tag_unless_blank(xml, 'Email1', options[:ptst_pod_request][:email1])
|
63
|
+
tag_unless_blank(xml, 'Email2', options[:ptst_pod_request][:email2])
|
64
|
+
tag_unless_blank(xml, 'Email3', options[:ptst_pod_request][:email3])
|
65
|
+
xml.tag!('CustRegID', options[:ptst_pod_request][:cust_reg_id])
|
66
|
+
xml.tag!('TableCode', options[:ptst_pod_request][:table_code])
|
67
|
+
tag_unless_blank(xml, 'ClientIp', options[:ptst_pod_request][:client_ip])
|
68
|
+
tag_unless_blank(xml, 'SourceId', options[:ptst_pod_request][:source_id])
|
69
|
+
xml.target!
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file was auto-generated by lib/tasks/api.rake
|
4
|
+
|
5
|
+
module Usps
|
6
|
+
module Api
|
7
|
+
module Endpoints
|
8
|
+
module RateV4
|
9
|
+
#
|
10
|
+
# Domestic Rates API
|
11
|
+
#
|
12
|
+
# The RateV4 API lets customers calculate the
|
13
|
+
# rate for domestic packages and envelopes given the weight and dimensions of the
|
14
|
+
# item. The RateV4 API limits the data requested to twenty-five (25) packages per
|
15
|
+
# transaction.
|
16
|
+
#
|
17
|
+
# @option option [(Alias)] :RateV4Request (Required)
|
18
|
+
# - API=RateV4 This API returns the current USPS postage corresponding to the parameters given.
|
19
|
+
# @option option [String] :Revision (Optional)
|
20
|
+
# - Set this value to “2” to return all currently documented response fields. For example: <Revision>2</Revsion>
|
21
|
+
# @option option [(Group)] :Package (Optional)
|
22
|
+
# - See the RateV4 Service Request chart for valid combinations of the following tags.
|
23
|
+
# @option option [String] :Service (Required)
|
24
|
+
# - Web Tools validates the entry to one of the service types. For example: <Service>PRIORITY MAIL EXPRESS</Service> Please see Appendix A for detailed business rules regarding combinations of Service, Container, dimensions and other request values. Note: Mailable matter not required to be mailed as First-Class Mail is permitted with Retail Ground to Zones 5-9. Zones 1-4 items are limited to mailable hazardous materials, live animals, and other “surface-only” items. Retail Ground can only be used for Zones 5-9 unless the shipment is oversized or contains classes of materials. (e.g. certain HAZMAT) For more details, see: http://pe.usps.com/businessmail101/classes/packageServices.htm. Note: The use of <Service> = “BPM” is restricted. If access to this service is needed, please reach out to the following email address: webtools@usps.gov.
|
25
|
+
# @option option [String] :FirstClassMailType (Optional)
|
26
|
+
# - Required when: RateV4Request[Service='FIRST CLASS'] or RateV4Request[Service='FIRST CLASS COMMERCIAL’], or RateV4Request[Service='FIRST CLASS HFP COMMERCIAL’] Example: <FirstClassMailType>LETTER</FirstClassMailType> Note: The <FirstClassMailType> tag is returned only if the <ServiceType> submitted is “First Class”. If any other <ServiceType> is returned (Including “First Class Commercial”) the <Container> tag is used. Note: Flats are also known as Large Envelopes
|
27
|
+
# @option option [String] :ZipOrigination (Required)
|
28
|
+
# - ZIP code must be valid. For example: <ZipOrigination>20770</ZipOrigination>
|
29
|
+
# @option option [String] :ZipDestination (Required)
|
30
|
+
# - ZIP code must be valid. For example: <ZipDestination>54324</ZipDestination>
|
31
|
+
# @option option [String] :Pounds (Required)
|
32
|
+
# - Value must be numeric. Package weight cannot exceed 70 pounds. For example: <Pounds>2</Pounds> <Pounds>2.12345678</Pounds>
|
33
|
+
# @option option [String] :Ounces (Required)
|
34
|
+
# - Value must be numeric. Package weight cannot exceed 70 pounds (1120 ounces). For example: <Ounces>0</Ounces> <Ounces>0.12345678</Ounces>
|
35
|
+
# @option option [String] :Container (Required)
|
36
|
+
# - Use to specify container attributes that may affect postage; otherwise, leave blank. Note: The <FirstClassMailType> tag is used instead of the <Container> tag only if the <ServiceType> submitted is “First Class”. Note: “Cubic Soft Pack” and “Cubic Parcels” are only valid containers for service “Priority Mail Cubic”. Dimensions Length and Height are required when requesting Cubic Soft Pack. Dimensions Length, Height, and Width are required when requesting Cubic Parcels. Note: “VARIABLE” is used to denote that a customer is using packaging other than a USPS-produced Flat Rate Box/Envelope or Regional Rate Box”.
|
37
|
+
# @option option [String] :Size (Optional)
|
38
|
+
# - Note: This tag has been deprecated. <Size> tag and any values within the <Size> tag will not result in an error response and will not impact rates that are returned.
|
39
|
+
# @option option [Decimal] :Width (Optional)
|
40
|
+
# - Value must be numeric. Units are inches. If partial dimensions are provided, an error response will return. Length, Width, Height are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. In addition, Girth is required only for a non-rectangular package in addition to Length, Width, Height when any dimension of the package exceeds 12 inches. For rectangular packages, the Girth dimension must be left blank as this dimension is to only be used for non-rectangular packages. For more details on dimensional weight pricing, please reference the Domestic Mail Manual Section 123.1.4 for Retail Mail and Section 223.1.6 for Commercial Mail. https://pe.usps.com/text/dmm300/index.htm
|
41
|
+
# @option option [Decimal] :Length (Optional)
|
42
|
+
# - Value must be numeric. Units are inches. If partial dimensions are provided, an error response will return. Length, Width, Height are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. In addition, Girth is required only for a non-rectangular package in addition to Length, Width, Height when any dimension of the package exceeds 12 inches. For rectangular packages, the Girth dimension must be left blank as this dimension is to only be used for non-rectangular packages. For more details on dimensional weight pricing, please reference the Domestic Mail Manual Section 123.1.4 for Retail Mail and Section 223.1.6 for Commercial Mail. https://pe.usps.com/text/dmm300/index.htm
|
43
|
+
# @option option [Decimal] :Height (Optional)
|
44
|
+
# - Value must be numeric. Units are inches. If partial dimensions are provided, an error response will return. Length, Width, Height are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. In addition, Girth is required only for a non-rectangular package in addition to Length, Width, Height when any dimension of the package exceeds 12 inches. For rectangular packages, the Girth dimension must be left blank as this dimension is to only be used for non-rectangular packages. For more details on dimensional weight pricing, please reference the Domestic Mail Manual Section 123.1.4 for Retail Mail and Section 223.1.6 for Commercial Mail. https://pe.usps.com/text/dmm300/index.htm
|
45
|
+
# @option option [Decimal] :Girth (Optional)
|
46
|
+
# - Value must be numeric. Units are inches. If partial dimensions are provided, an error response will return. Length, Width, Height are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. In addition, Girth is required only for a non-rectangular package in addition to Length, Width, Height when any dimension of the package exceeds 12 inches. For rectangular packages, the Girth dimension must be left blank as this dimension is to only be used for non-rectangular packages. For more details on dimensional weight pricing, please reference the Domestic Mail Manual Section 123.1.4 for Retail Mail and Section 223.1.6 for Commercial Mail. https://pe.usps.com/text/dmm300/index.htm
|
47
|
+
# @option option [String] :Value (Optional)
|
48
|
+
# - Available when RateV4Request [Revision='2']. Package value. Used to determine availability and cost of extra services. For example: <Value>150.00</Value>
|
49
|
+
# @option option [String] :AmountToCollect (Optional)
|
50
|
+
# - Available when RateV4Request [Revision='2']. Collect on delivery amount. Used to determine availability and cost of extra services. For example: <AmountToCollect>150.00</AmountToCollect>
|
51
|
+
# @option option [(Group)] :SpecialServices (Optional)
|
52
|
+
# - Available when RateV4Request [Revision='2']. Groups the SpecialServices elements. Special Services prices and availability will not be returned when Service = “ALL”, “ONLINE”, or “PLUS”
|
53
|
+
# @option option [Special Service Name] :SpecialService (Optional)
|
54
|
+
# - [{"Special Service Name"=>"Insurance", "ServiceID"=>"100"}, {"Special Service Name"=>"Insurance – Priority Mail Express", "ServiceID"=>"101"}, {"Special Service Name"=>"Return Receipt", "ServiceID"=>"102"}, {"Special Service Name"=>"Collect on Delivery", "ServiceID"=>"103"}, {"Special Service Name"=>"Certificate of Mailing (Form 3665)", "ServiceID"=>"104"}, {"Special Service Name"=>"Certified Mail", "ServiceID"=>"105"}, {"Special Service Name"=>"USPS Tracking", "ServiceID"=>"106"}, {"Special Service Name"=>"Signature Confirmation", "ServiceID"=>"108"}, {"Special Service Name"=>"Registered Mail", "ServiceID"=>"109"}, {"Special Service Name"=>"Return Receipt Electronic", "ServiceID"=>"110"}, {"Special Service Name"=>"Registered mail COD collection Charge", "ServiceID"=>"112"}, {"Special Service Name"=>"Return Receipt – Priority Mail Express", "ServiceID"=>"118"}, {"Special Service Name"=>"Adult Signature Required", "ServiceID"=>"119"}, {"Special Service Name"=>"Adult Signature Restricted Delivery", "ServiceID"=>"120"}, {"Special Service Name"=>"Insurance – Priority Mail", "ServiceID"=>"125"}, {"Special Service Name"=>"USPS Tracking Electronic", "ServiceID"=>"155"}, {"Special Service Name"=>"Signature Confirmation Electronic", "ServiceID"=>"156"}, {"Special Service Name"=>"Certificate of Mailing (Form 3817)", "ServiceID"=>"160"}, {"Special Service Name"=>"Priority Mail Express 1030 AM Delivery", "ServiceID"=>"161"}, {"Special Service Name"=>"Certified Mail Restricted Delivery", "ServiceID"=>"170"}, {"Special Service Name"=>"Certified Mail Adult Signature Required", "ServiceID"=>"171"}, {"Special Service Name"=>"Certified Mail Adult Signature Restricted Delivery", "ServiceID"=>"172"}, {"Special Service Name"=>"Signature Confirm. Restrict. Delivery", "ServiceID"=>"173"}, {"Special Service Name"=>"Signature Confirmation Electronic Restricted Delivery", "ServiceID"=>"174"}, {"Special Service Name"=>"Collect on Delivery Restricted Delivery", "ServiceID"=>"175"}, {"Special Service Name"=>"Registered Mail Restricted Delivery", "ServiceID"=>"176"}, {"Special Service Name"=>"Insurance Restricted Delivery", "ServiceID"=>"177"}, {"Special Service Name"=>"Insurance Restrict. Delivery – Priority Mail", "ServiceID"=>"179"}, {"Special Service Name"=>"Insurance Restrict. Delivery – Priority Mail Express", "ServiceID"=>"178"}, {"Special Service Name"=>"Insurance Restrict. Delivery (Bulk Only)", "ServiceID"=>"180"}, {"Special Service Name"=>"Scan Retention", "ServiceID"=>"181"}, {"Special Service Name"=>"Scan + Signature Retention", "ServiceID"=>"182"}, {"Special Service Name"=>"Special Handling - Fragile", "ServiceID"=>"190"}]
|
55
|
+
# @option option [Group] :Content (Optional)
|
56
|
+
# - Available when RateV4Request[Revision='2']. Groups the ContentType and ContentDescription elements.
|
57
|
+
# @option option [String] :ContentType (Optional)
|
58
|
+
# - Available when RateV4Request [Revision=’2’]. Defines the type of content of the package.
|
59
|
+
# @option option [String] :ContentDescription (Optional)
|
60
|
+
# - Available when RateV4Request[Revision=’2’]. Describes the content of the package. Optional but required for ContentType ‘LIVES’.
|
61
|
+
# @option option [Boolean] :GroundOnly (Optional)
|
62
|
+
# - Available when RateV4Request [Revision=’2’]. RateV4Request [Service=’ Retail Ground’] Use “true” when shipment contains mailable hazardous materials, live animals and other “surface-only” items.
|
63
|
+
# @option option [String] :SortBy (Optional)
|
64
|
+
# - Available when RateV4Request [Revision='2']. Returns all mailing services available based on item shape. When specified, value in <Container> is ignored. Available when: RateV4Request[Service='ALL'] RateV4Request[Service='ONLINE'] For example: <SortBy>PACKAGE</SortBy>
|
65
|
+
# @option option [Boolean] :Machinable (Optional)
|
66
|
+
# - RateV4Request/Machinable is required when: RateV4Request[Service='FIRST CLASS' and (FirstClassMailType='LETTER' or FirstClassMailType='FLAT')] RateV4Request[Service='Retail Ground’] RateV4Request[Service='ALL'] RateV4Request[Service='ONLINE'] If false, First Class Mail Letters and Flats will not be returned. For example: <Machinable>true</Machinable>
|
67
|
+
# @option option [Boolean] :ReturnLocations (Optional)
|
68
|
+
# - Include Dropoff Locations in Response if available. Requires "ShipDate" tag.
|
69
|
+
# @option option [Boolean] :ReturnServiceInfo (Optional)
|
70
|
+
# - If a value of “True” is indicated in the request then the response will include the <ServiceInformation> tag containing mail service specific information
|
71
|
+
# @option option [String] :DropOffTime (Optional)
|
72
|
+
# - Time Package Will Be Mailed. Enter drop off time in format: HH:mm, such as 13:45. Inclusion of Drop Off Time will result increased accuracy of <CommitmentName> and <CommitmentDate> in the response for Priority Mail and Priority Mail Express variants. For example: <DropOffTime>13:45</DropOffTime>
|
73
|
+
# @option option [String] :ShipDate (Optional)
|
74
|
+
# - Date Package Will Be Mailed. Ship date may be today plus 0 to 3 days in advance. Enter the date in format: yyyy-mm-dd, such as 2013-07-28. Inclusion of Ship Date will result in <CommitmentName> and <CommitmentDate> in the response for Priority Mail and Priority Mail Express variants For example: <ShipDate Option="HFP">2013-07-28</ShipDate>
|
75
|
+
# @option option [String] :Option (Optional)
|
76
|
+
# - The value of this attribute specifies how the RateV4Response will structure the Priority Express Mail Commitment data elements.
|
77
|
+
# @option option [Boolean] :ReturnDimensionalWeight (Optional)
|
78
|
+
# - This tag must be explicitly set to “true” for dimensional weight to be returned in the xml response.
|
79
|
+
# @option option [String] :TrackingRetentionPeriod (Optional)
|
80
|
+
# - Used to determine period of Retention for tracking data
|
81
|
+
|
82
|
+
#
|
83
|
+
# @see
|
84
|
+
def rate_v4(options = {})
|
85
|
+
throw ArgumentError.new('Required arguments :rate_v4_request missing') if options[:rate_v4_request].nil?
|
86
|
+
|
87
|
+
request = build_request(:rate_v4, options)
|
88
|
+
get('https://secure.shippingapis.com/ShippingAPI.dll', {
|
89
|
+
API: 'RateV4',
|
90
|
+
XML: request,
|
91
|
+
})
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
def tag_unless_blank(xml, tag_name, data)
|
97
|
+
xml.tag!(tag_name, data) unless data.blank? || data.nil?
|
98
|
+
end
|
99
|
+
|
100
|
+
def build_rate_v4_request(xml, options = {})
|
101
|
+
tag_unless_blank(xml, 'Revision', options[:rate_v4_request][:revision])
|
102
|
+
xml.tag!('Package') do
|
103
|
+
xml.tag!('Service', options[:rate_v4_request][:package][:service])
|
104
|
+
tag_unless_blank(xml, 'FirstClassMailType', options[:rate_v4_request][:package][:first_class_mail_type])
|
105
|
+
xml.tag!('ZipOrigination', options[:rate_v4_request][:package][:zip_origination])
|
106
|
+
xml.tag!('ZipDestination', options[:rate_v4_request][:package][:zip_destination])
|
107
|
+
xml.tag!('Pounds', options[:rate_v4_request][:package][:pounds])
|
108
|
+
xml.tag!('Ounces', options[:rate_v4_request][:package][:ounces])
|
109
|
+
xml.tag!('Container', options[:rate_v4_request][:package][:container])
|
110
|
+
tag_unless_blank(xml, 'Size', options[:rate_v4_request][:package][:size])
|
111
|
+
tag_unless_blank(xml, 'Width', options[:rate_v4_request][:package][:width])
|
112
|
+
tag_unless_blank(xml, 'Length', options[:rate_v4_request][:package][:length])
|
113
|
+
tag_unless_blank(xml, 'Height', options[:rate_v4_request][:package][:height])
|
114
|
+
tag_unless_blank(xml, 'Girth', options[:rate_v4_request][:package][:girth])
|
115
|
+
tag_unless_blank(xml, 'Value', options[:rate_v4_request][:package][:value])
|
116
|
+
tag_unless_blank(xml, 'AmountToCollect', options[:rate_v4_request][:package][:amount_to_collect])
|
117
|
+
xml.tag!('SpecialServices') do
|
118
|
+
tag_unless_blank(xml, 'SpecialService', options[:rate_v4_request][:package][:special_services][:special_service])
|
119
|
+
tag_unless_blank(xml, 'Content', options[:rate_v4_request][:package][:special_services][:content])
|
120
|
+
tag_unless_blank(xml, 'ContentType', options[:rate_v4_request][:package][:special_services][:content_type])
|
121
|
+
tag_unless_blank(xml, 'ContentDescription', options[:rate_v4_request][:package][:special_services][:content_description])
|
122
|
+
tag_unless_blank(xml, 'GroundOnly', options[:rate_v4_request][:package][:special_services][:ground_only])
|
123
|
+
tag_unless_blank(xml, 'SortBy', options[:rate_v4_request][:package][:special_services][:sort_by])
|
124
|
+
tag_unless_blank(xml, 'Machinable', options[:rate_v4_request][:package][:special_services][:machinable])
|
125
|
+
tag_unless_blank(xml, 'ReturnLocations', options[:rate_v4_request][:package][:special_services][:return_locations])
|
126
|
+
tag_unless_blank(xml, 'ReturnServiceInfo', options[:rate_v4_request][:package][:special_services][:return_service_info])
|
127
|
+
tag_unless_blank(xml, 'DropOffTime', options[:rate_v4_request][:package][:special_services][:drop_off_time])
|
128
|
+
tag_unless_blank(xml, 'ShipDate', options[:rate_v4_request][:package][:special_services][:ship_date])
|
129
|
+
tag_unless_blank(xml, 'Option', options[:rate_v4_request][:package][:special_services][:option])
|
130
|
+
tag_unless_blank(xml, 'ReturnDimensionalWeight', options[:rate_v4_request][:package][:special_services][:return_dimensional_weight])
|
131
|
+
tag_unless_blank(xml, 'TrackingRetentionPeriod', options[:rate_v4_request][:package][:special_services][:tracking_retention_period])
|
132
|
+
end if options[:rate_v4_request][:package][:special_services].present?
|
133
|
+
end if options[:rate_v4_request][:package].present?
|
134
|
+
xml.target!
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file was auto-generated by lib/tasks/api.rake
|
4
|
+
|
5
|
+
module Usps
|
6
|
+
module Api
|
7
|
+
module Endpoints
|
8
|
+
module SCAN
|
9
|
+
#
|
10
|
+
# SCAN API
|
11
|
+
#
|
12
|
+
# The SCAN API allows integrators to consolidate
|
13
|
+
# multiple domestic and international labels and custom forms through one
|
14
|
+
# Electronic File Number (EFN) and physical SCAN Form (PS Form 5630 or 3152). The
|
15
|
+
# API operates as follows:
|
16
|
+
#
|
17
|
+
# @option option [(Alias)] :SCANRequest (Required)
|
18
|
+
# - API=SCAN
|
19
|
+
# @option option [(Group)] :Option (Optional)
|
20
|
+
# - Groups form information
|
21
|
+
# @option option [String] :Form (Optional)
|
22
|
+
# - Designates desired label option selected by customer. Enter one of the valid entries: ‘3152’ generates PS Form 3152. ‘5630’ generates PS Form 5630. For example: <Form>3152</Form>
|
23
|
+
# @option option [String] :FromName (Required)
|
24
|
+
# - Name of sender. Example: <FromName>Joe Smith</FromName>
|
25
|
+
# @option option [String] :FromFirm (Optional)
|
26
|
+
# - Company name. Example: <FromFirm>ABC Corp.</FromFirm>
|
27
|
+
# @option option [String] :FromAddress1 (Optional)
|
28
|
+
# - From address line 1. Denote apartment or suite number. Example: <FromAddress1>Apt. 3C</FromAddress1>
|
29
|
+
# @option option [String] :FromAddress2 (Required)
|
30
|
+
# - From address line 2. Denote street/structure number. Example: <FromAddress2>475 L’Enfant Plaza SW</FromAddress2>
|
31
|
+
# @option option [String] :FromCity (Required)
|
32
|
+
# - From city. Example: <FromCity>Greenbelt</FromCity>
|
33
|
+
# @option option [String] :FromState (Required)
|
34
|
+
# - From state. Example: <FromState>MD</FromState>
|
35
|
+
# @option option [String] :FromZip5 (Required)
|
36
|
+
# - From ZIP Code. Must be a valid ZIP5 Code. Example: <FromZip5>20770</FromZip5>
|
37
|
+
# @option option [String] :FromZip4 (Optional)
|
38
|
+
# - From ZIP Code+4. Example: <FromZip4>1234</FromZip4>
|
39
|
+
# @option option [(Group)] :Shipment (Optional)
|
40
|
+
# - Groups shipment information
|
41
|
+
# @option option [(Group)] :PackageDetail (Optional)
|
42
|
+
# - Groups package detail information
|
43
|
+
# @option option [String] :PkgBarcode (Required)
|
44
|
+
# - Individual package barcodes. Example: <PkgBarcode>42020260910180521390702413570 </PkgBarcode> Note: The SCAN API can contain no more than 1,000 package barcodes in a single request. If exceeded, 'Total PackageDetail items exceeded 1000.’ error will return”
|
45
|
+
# @option option [(Group)] :SpecialService (Optional)
|
46
|
+
# - FOR FUTURE USE. Groups extra service information.
|
47
|
+
# @option option [String] :SpcServCode (Required)
|
48
|
+
# - FOR FUTURE USE. If present, must be <SpcServFee>. From Extra Service Code table. Example: <SpcServCode>01</SpcServCode>
|
49
|
+
# @option option [String] :SpcServFee (Required)
|
50
|
+
# - FOR FUTURE USE. Fee for Extra Service. Example: <SpcServFee>00275</SpcServFee>
|
51
|
+
# @option option [String] :EMail (Optional)
|
52
|
+
# - FOR FUTURE USE. Email address of acceptance scan event recipient. Example: <EMail>john.smith@abc.com</EMail>
|
53
|
+
# @option option [Boolean] :CloseManifest (Optional)
|
54
|
+
# - Used to include all labels for the submitted UserID. There are two values: “ALL” will close all labels for the submitted USERID. “SHIPDATE” will close all the labels for the submitted USERID that have the <Shipdate> tag matching the value in the <MailDate> tag. Note: When <CloseManifest> is indicated in the request, the following two response fields are eligible to return if conditions are met: · <MaxPackagesExceeded> · <MaxLabelsExceeded>
|
55
|
+
# @option option [String] :MailDate (Required)
|
56
|
+
# - Date of mailing/Carrier Pickup. This denotes date mail to be tendered to Postal Service. YYYYMMDD format. Example: <MailDate>20060103</MailDate>
|
57
|
+
# @option option [String] :MailTime (Required)
|
58
|
+
# - Time of mailing/Carrier Pickup. This is an approximation. This denotes time of mail to be tendered to Postal Service. HHMMSS (24 hour) format. Example: <MailTime>143000</MailTime>
|
59
|
+
# @option option [String] :EntryFacility (Required)
|
60
|
+
# - ZIP Code of Postal Service facility. Populate/required only if different from <FromZip5>. Example: <EntryFacility>07067</EntryFacility>
|
61
|
+
# @option option [String] :ImageType (Required)
|
62
|
+
# - The form image format desired. Enter one of the valid entries: Example: <ImageType>TIF</ImageType>
|
63
|
+
# @option option [String] :CustomerRefNo (Optional)
|
64
|
+
# - Arbitrary number for customers own tracking or inventory systems, does not print to form or manifest with Product Tracking. May be any combination of alpha and numeric characters, up to a maximum of 30. Example: <CustomerRefNo>123456</CustomerRefNo>
|
65
|
+
# @option option [Boolean] :CarrierPickup (Optional)
|
66
|
+
# - FOR FUTURE USE.
|
67
|
+
|
68
|
+
#
|
69
|
+
# @see
|
70
|
+
def scan(options = {})
|
71
|
+
throw ArgumentError.new('Required arguments :scan_request missing') if options[:scan_request].nil?
|
72
|
+
|
73
|
+
request = build_request(:scan, options)
|
74
|
+
get('https://secure.shippingapis.com/ShippingAPI.dll', {
|
75
|
+
API: 'SCAN',
|
76
|
+
XML: request,
|
77
|
+
})
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def tag_unless_blank(xml, tag_name, data)
|
83
|
+
xml.tag!(tag_name, data) unless data.blank? || data.nil?
|
84
|
+
end
|
85
|
+
|
86
|
+
def build_scan_request(xml, options = {})
|
87
|
+
xml.tag!('Option') do
|
88
|
+
tag_unless_blank(xml, 'Form', options[:scan_request][:option][:form])
|
89
|
+
xml.tag!('FromName', options[:scan_request][:option][:from_name])
|
90
|
+
tag_unless_blank(xml, 'FromFirm', options[:scan_request][:option][:from_firm])
|
91
|
+
tag_unless_blank(xml, 'FromAddress1', options[:scan_request][:option][:from_address1])
|
92
|
+
xml.tag!('FromAddress2', options[:scan_request][:option][:from_address2])
|
93
|
+
xml.tag!('FromCity', options[:scan_request][:option][:from_city])
|
94
|
+
xml.tag!('FromState', options[:scan_request][:option][:from_state])
|
95
|
+
xml.tag!('FromZip5', options[:scan_request][:option][:from_zip5])
|
96
|
+
tag_unless_blank(xml, 'FromZip4', options[:scan_request][:option][:from_zip4])
|
97
|
+
xml.tag!('Shipment') do
|
98
|
+
xml.tag!('PackageDetail') do
|
99
|
+
xml.tag!('PkgBarcode', options[:scan_request][:option][:shipment][:package_detail][:pkg_barcode])
|
100
|
+
xml.tag!('SpecialService') do
|
101
|
+
xml.tag!('SpcServCode', options[:scan_request][:option][:shipment][:package_detail][:special_service][:spc_serv_code])
|
102
|
+
xml.tag!('SpcServFee', options[:scan_request][:option][:shipment][:package_detail][:special_service][:spc_serv_fee])
|
103
|
+
tag_unless_blank(xml, 'EMail', options[:scan_request][:option][:shipment][:package_detail][:special_service][:e_mail])
|
104
|
+
tag_unless_blank(xml, 'CloseManifest', options[:scan_request][:option][:shipment][:package_detail][:special_service][:close_manifest])
|
105
|
+
xml.tag!('MailDate', options[:scan_request][:option][:shipment][:package_detail][:special_service][:mail_date])
|
106
|
+
xml.tag!('MailTime', options[:scan_request][:option][:shipment][:package_detail][:special_service][:mail_time])
|
107
|
+
xml.tag!('EntryFacility', options[:scan_request][:option][:shipment][:package_detail][:special_service][:entry_facility])
|
108
|
+
xml.tag!('ImageType', options[:scan_request][:option][:shipment][:package_detail][:special_service][:image_type])
|
109
|
+
tag_unless_blank(xml, 'CustomerRefNo', options[:scan_request][:option][:shipment][:package_detail][:special_service][:customer_ref_no])
|
110
|
+
tag_unless_blank(xml, 'CarrierPickup', options[:scan_request][:option][:shipment][:package_detail][:special_service][:carrier_pickup])
|
111
|
+
end if options[:scan_request][:option][:shipment][:package_detail][:special_service].present?
|
112
|
+
end if options[:scan_request][:option][:shipment][:package_detail].present?
|
113
|
+
end if options[:scan_request][:option][:shipment].present?
|
114
|
+
end if options[:scan_request][:option].present?
|
115
|
+
xml.target!
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file was auto-generated by lib/tasks/api.rake
|
4
|
+
|
5
|
+
module Usps
|
6
|
+
module Api
|
7
|
+
module Endpoints
|
8
|
+
module TrackV2
|
9
|
+
#
|
10
|
+
# Package Tracking
|
11
|
+
#
|
12
|
+
# The Package Tracking “Fields” API is similar
|
13
|
+
# to the Package Track API
|
14
|
+
# except for the request fields, API name, and the return information. Data
|
15
|
+
# returned still contains the detail and summary information, but this
|
16
|
+
# information is broken down into fields instead of having only one line of text.
|
17
|
+
# Up to 10 tracking IDs may be contained in each API request to the Web Tools
|
18
|
+
# server.
|
19
|
+
#
|
20
|
+
# @option option [(Alias)] :TrackFieldRequest (Required)
|
21
|
+
# @option option [Integer] :Revision (Required)
|
22
|
+
# @option option [String] :ClientIp (Optional)
|
23
|
+
# @option option [String] :SourceId (Required)
|
24
|
+
# @option option [String] :TrackID (Required)
|
25
|
+
# @option option [String] :DestinationZipCode (Optional)
|
26
|
+
# @option option [String] :MailingDate (Optional)
|
27
|
+
|
28
|
+
#
|
29
|
+
# @see
|
30
|
+
def track_v2(options = {})
|
31
|
+
throw ArgumentError.new('Required arguments :track_field_request missing') if options[:track_field_request].nil?
|
32
|
+
throw ArgumentError.new('Required arguments :track_field_request, :revision missing') if options[:track_field_request][:revision].nil?
|
33
|
+
throw ArgumentError.new('Required arguments :track_field_request, :source_id missing') if options[:track_field_request][:source_id].nil?
|
34
|
+
throw ArgumentError.new('Required arguments :track_field_request, :track_id missing') if options[:track_field_request][:track_id].nil?
|
35
|
+
|
36
|
+
request = build_request(:track_v2, options)
|
37
|
+
get('https://secure.shippingapis.com/ShippingAPI.dll', {
|
38
|
+
API: 'TrackV2',
|
39
|
+
XML: request,
|
40
|
+
})
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def tag_unless_blank(xml, tag_name, data)
|
46
|
+
xml.tag!(tag_name, data) unless data.blank? || data.nil?
|
47
|
+
end
|
48
|
+
|
49
|
+
def build_track_v2_request(xml, options = {})
|
50
|
+
xml.tag!('Revision', options[:track_field_request][:revision])
|
51
|
+
tag_unless_blank(xml, 'ClientIp', options[:track_field_request][:client_ip])
|
52
|
+
xml.tag!('SourceId', options[:track_field_request][:source_id])
|
53
|
+
xml.tag!('TrackID', options[:track_field_request][:track_id])
|
54
|
+
tag_unless_blank(xml, 'DestinationZipCode', options[:track_field_request][:destination_zip_code])
|
55
|
+
tag_unless_blank(xml, 'MailingDate', options[:track_field_request][:mailing_date])
|
56
|
+
xml.target!
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file was auto-generated by lib/tasks/api.rake
|
4
|
+
|
5
|
+
module Usps
|
6
|
+
module Api
|
7
|
+
module Endpoints
|
8
|
+
module USPSReturnsLabel
|
9
|
+
#
|
10
|
+
# USPS Returns Label API
|
11
|
+
#
|
12
|
+
# The Web Tools USPS Returns Label API enables
|
13
|
+
# customers to receive USPS Returns service labels which are processed using the
|
14
|
+
# new automated returns process via Package Platform. USPS Returns service account holders will pay
|
15
|
+
# postage and fees through an Enterprise Payment System (EPS) account so that
|
16
|
+
# items can be returned by their customers (at no charge to their customers)
|
17
|
+
# using merchant provided USPS Returns service labels. The API allows integrators
|
18
|
+
# to request USPS Returns service labels for
|
19
|
+
# items that can be mailed using First-Class Package Return Service, Priority Mail Return Service, and Ground Return Service. For
|
20
|
+
# additional USPS Returns service details, reference: https://www.federalregister.gov/documents/2020/02/25/2020-03170/usps-returns-service.
|
21
|
+
#
|
22
|
+
# @option option [(Alias)] :USPSReturnsLabelRequest (Required)
|
23
|
+
# - Used with API=USPSReturnsLabel
|
24
|
+
# @option option [String] :Option (Optional)
|
25
|
+
# - For future use.
|
26
|
+
# @option option [String] :Revision (Optional)
|
27
|
+
# - For future use. Used to indicate API version.
|
28
|
+
# @option option [(Group)] :ImageParameters (Required)
|
29
|
+
# - Group containing all request parameters pertaining to the Label Image generation.
|
30
|
+
# @option option [String] :ImageType (Required)
|
31
|
+
# - Label Image Type. For example: <ImageType>PDF</ImageType>
|
32
|
+
# @option option [Boolean] :SeparateReceiptPage (Optional)
|
33
|
+
# - Flag to request a Separate Receipt Image. Enter “true” if you want receipt returned on a separate page – this will return label in <LabelImage> tag and receipt in <ReceiptImage> tag. For example: <SeparateReceiptPage>true</SeparateReceiptPage> Note: If not specified, receipt will return on same page as returns label. Response will contain a single <LabelImage> tag containing label and receipt on the same page.
|
34
|
+
# @option option [String] :CustomerFirstName (Optional)
|
35
|
+
# - First Name of customer returning package. Printed on label and receipt. Either <CustomerFirstName> and <CustomerLastName> OR <CustomerFirm> required. Minimum of 1 character required. Note: <CustomerFirstName> and <CustomerLastName> values have a combined 32-character limit when printed on label. Combined values exceeding 32 characters will be truncated due to space limitations on the label. API request eligible to accept up to 50 characters.
|
36
|
+
# @option option [String] :CustomerLastName (Optional)
|
37
|
+
# - Last Name of customer returning package. Printed on label and receipt. Either <CustomerFirstName> and <CustomerLastName> OR <CustomerFirm> required. Minimum of 1 character required. Note: <CustomerFirstName> and <CustomerLastName> values have a combined 32-character limit when printed on label. Combined values exceeding 32 characters will be truncated due to space limitations on the label. API request eligible to accept up to 50 characters.
|
38
|
+
# @option option [String] :CustomerFirm (Optional)
|
39
|
+
# - Firm Name of customer returning package. Printed on label and receipt. Either <CustomerFirstName> and <CustomerLastName> OR <CustomerFirm> required. Minimum of 1 character required. Note: <CustomerFirm> has a 32-character limit when printed on label. Values exceeding 32 characters will be truncated due to space limitations on the label. API request eligible to accept up to 50 characters.
|
40
|
+
# @option option [String] :CustomerAddress1 (Optional)
|
41
|
+
# - Secondary address unit designator and number (such as an apartment or suite number). For example: “APT 202” or “STE 100” etc. Note: This tag must be included in the request, even if the value is null, to return a successful response. For addresses that do not require secondary information, integrators should include “<CustomerAddress1/>” in the request.
|
42
|
+
# @option option [String] :CustomerAddress2 (Required)
|
43
|
+
# - Address of customer returning the package. (Primary Street address). For example: <CustomerAddress2>123 Main St.</CustomerAddress2>
|
44
|
+
# @option option [String] :CustomerCity (Required)
|
45
|
+
# - City of customer returning the package.
|
46
|
+
# @option option [String] :CustomerState (Required)
|
47
|
+
# - State of customer returning the package. Value should be passed as two-letter state abbreviation. For example: <CustomerState>DC</CustomerState>
|
48
|
+
# @option option [String] :CustomerZip5 (Required)
|
49
|
+
# - ZIP Code of customer returning the package.
|
50
|
+
# @option option [String] :CustomerZip4 (Optional)
|
51
|
+
# - ZIP+4 Code of customer returning the package.
|
52
|
+
# @option option [String] :POZipCode (Optional)
|
53
|
+
# - ZIP Code of Post Office or collection box where item is mailed. May be different than CustomerZip5. This tag will take precedence over CustomerZip5 when provided. For example: <POZipCode>20770</ POZipCode>
|
54
|
+
# @option option [Boolean] :AllowNonCleansedOriginAddr (Optional)
|
55
|
+
# - Allows Non-Validated Origin Street Address. Enter “true” to bypass street address validation failures/errors or “false” if only validated addresses should be allowed. Note: Integrators are recommended to always use “false” to ensure no delivery issues. In the event USPS cannot validate the street address, this tag will “bypass” address validation error when “true” is indicated to allow label creation which could impact delivery. The <AllowNonCleansedOriginAddr> excludes City, State, and ZIP Code which must be valid for a successful response. Reference https://pe.usps.com/text/pub28/28c2_001.htm.
|
56
|
+
# @option option [Integer] :WeightInOunces (Optional)
|
57
|
+
# - Package weight used to calculate postage. Items must weigh 70 pounds (1120 ounces) or less. For example: <WeightInOunces>80</ WeightInOunces> Note: If weight not supplied, 4oz used.
|
58
|
+
# @option option [String] :ServiceType (Required)
|
59
|
+
# - Enter one of the valid Mail Service entries: “PRIORITY” for Priority Mail Return Service. “FIRST CLASS” for First-Class Package Return Service. “GROUND” for Ground Return Service.
|
60
|
+
# @option option [Decimal] :Width (Optional)
|
61
|
+
# - Value must be numeric. Units are inches. For example: <Width>5.5</ Width> If partial dimensions are provided, an error response will return. Length, Width, Height are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. In addition, Girth is required only for a non-rectangular package in addition to Length, Width, Height when any dimension of the package exceeds 12 inches. For rectangular packages, the Girth dimension must be left blank as this dimension is to only be used for non-rectangular packages. For details on dimensional weight pricing, please reference the Domestic Mail Manual Section 123.1.4 for Retail Mail and Section 223.1.6 for Commercial Mail. https://pe.usps.com/text/dmm300/index.htm
|
62
|
+
# @option option [Decimal] :Length (Optional)
|
63
|
+
# - Value must be numeric. Units are inches. Length should be longest dimension when compared to Width and Height values supplied. For example: <Length>11</Length> If partial dimensions are provided, an error response will return. Length, Width, Height are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. In addition, Girth is required only for a non-rectangular package in addition to Length, Width, Height when any dimension of the package exceeds 12 inches. For rectangular packages, the Girth dimension must be left blank as this dimension is to only be used for non-rectangular packages. For details on dimensional weight pricing, please reference the Domestic Mail Manual Section 123.1.4 for Retail Mail and Section 223.1.6 for Commercial Mail. https://pe.usps.com/text/dmm300/index.htm
|
64
|
+
# @option option [Decimal] :Height (Optional)
|
65
|
+
# - Value must be numeric. Units are inches. For example: <Height>7</Height> If partial dimensions are provided, an error response will return. Length, Width, Height are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. In addition, Girth is required only for a non-rectangular package in addition to Length, Width, Height when any dimension of the package exceeds 12 inches. For rectangular packages, the Girth dimension must be left blank as this dimension is to only be used for non-rectangular packages. For details on dimensional weight pricing, please reference the Domestic Mail Manual Section 123.1.4 for Retail Mail and Section 223.1.6 for Commercial Mail. https://pe.usps.com/text/dmm300/index.htm
|
66
|
+
# @option option [Decimal] :Girth (Optional)
|
67
|
+
# - Note: Girth is required only for a non-rectangular package. For rectangular packages, girth must be left blank. Value must be numeric. Units are inches. Girth is distance around the thickest part of package (perpendicular to the length). For details on dimensional weight pricing, please reference the Domestic Mail Manual Section 123.1.4 for Retail Mail and Section 223.1.6 for Commercial Mail https://pe.usps.com/text/dmm300/index.htm. For example: <Girth>25</Girth> Note: If partial dimensions are provided, an error response will return. (i.e. Length, Width, and Height must all be supplied with Girth).
|
68
|
+
# @option option [Boolean] :Machinable (Optional)
|
69
|
+
# - Indicates if packaging is Machinable. Used to calculate postage. For example: <Machinable>true</Machinable>
|
70
|
+
# @option option [String] :ShipDate (Optional)
|
71
|
+
# - Date Package Will Be Mailed. Ship date may be today plus 0 to 3 days in advance. Enter the date in either format: dd-mmm-yyyy, such as 14-Feb-2020, or mm/dd/ yyyy, such as 02/14/2020. If not provided, current day will be used as a basis for delivery date calculations. For example: <ShipDate>02/14/2011</ShipDate>
|
72
|
+
# @option option [String] :SenderName (Optional)
|
73
|
+
# - Used for the USPS Tracking email. Indicates the name of the person or company sending the USPS tracking email notification. Note: No email is returned when generating a Sample (i.e. API=USPSReturnsLabelCertify) request.
|
74
|
+
# @option option [String] :SenderEMail (Optional)
|
75
|
+
# - Used for the USPS Tracking email. Indicates the email address of sender used for USPS tracking email notification. Valid email addresses must be used. Note: <RecipientEMail> must be populated to generate USPS tracking email notification. If <SenderEMail> provided without <RecipientEMail>, USPS tracking email notification will not be generated. Note: No email is returned when generating a Sample (i.e. API=USPSReturnsLabelCertify) request.
|
76
|
+
# @option option [String] :RecipientName (Optional)
|
77
|
+
# - Used for the USPS Tracking email. Indicates the name of the person or company receiving the USPS tracking email notification. If recipient name not provided, email will be addressed to <RecipientEMail> value provided. Note: No email is returned when generating a Sample (i.e. API=USPSReturnsLabelCertify) request.
|
78
|
+
# @option option [String] :RecipientEMail (Optional)
|
79
|
+
# - Required to generate the USPS Tracking email. Indicates email address of recipient receiving the USPS tracking email notification. Valid email addresses must be used. Note: No email is returned when generating a Sample (i.e. API=USPSReturnsLabelCertify) request.
|
80
|
+
# @option option [(Group)] :ExtraServices (Optional)
|
81
|
+
# - Groups extra services elements
|
82
|
+
# @option option [Service Name] :ExtraService (Optional)
|
83
|
+
# - [{"Service Name"=>"Signature Confirmation Electronic", "Service ID"=>"156"}]
|
84
|
+
|
85
|
+
#
|
86
|
+
# @see
|
87
|
+
def usps_returns_label(options = {})
|
88
|
+
throw ArgumentError.new('Required arguments :usps_returns_label_request missing') if options[:usps_returns_label_request].nil?
|
89
|
+
throw ArgumentError.new('Required arguments :usps_returns_label_request, :image_parameters missing') if options[:usps_returns_label_request][:image_parameters].nil?
|
90
|
+
throw ArgumentError.new('Required arguments :usps_returns_label_request, :image_parameters, :image_type missing') if options[:usps_returns_label_request][:image_parameters][:image_type].nil?
|
91
|
+
throw ArgumentError.new('Required arguments :usps_returns_label_request, :image_parameters, :customer_address2 missing') if options[:usps_returns_label_request][:image_parameters][:customer_address2].nil?
|
92
|
+
throw ArgumentError.new('Required arguments :usps_returns_label_request, :image_parameters, :customer_city missing') if options[:usps_returns_label_request][:image_parameters][:customer_city].nil?
|
93
|
+
throw ArgumentError.new('Required arguments :usps_returns_label_request, :image_parameters, :customer_state missing') if options[:usps_returns_label_request][:image_parameters][:customer_state].nil?
|
94
|
+
throw ArgumentError.new('Required arguments :usps_returns_label_request, :image_parameters, :customer_zip5 missing') if options[:usps_returns_label_request][:image_parameters][:customer_zip5].nil?
|
95
|
+
throw ArgumentError.new('Required arguments :usps_returns_label_request, :image_parameters, :service_type missing') if options[:usps_returns_label_request][:image_parameters][:service_type].nil?
|
96
|
+
|
97
|
+
request = build_request(:usps_returns_label, options)
|
98
|
+
get('https://secure.shippingapis.com/ShippingAPI.dll', {
|
99
|
+
API: 'USPSReturnsLabel',
|
100
|
+
XML: request,
|
101
|
+
})
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
def tag_unless_blank(xml, tag_name, data)
|
107
|
+
xml.tag!(tag_name, data) unless data.blank? || data.nil?
|
108
|
+
end
|
109
|
+
|
110
|
+
def build_usps_returns_label_request(xml, options = {})
|
111
|
+
tag_unless_blank(xml, 'Option', options[:usps_returns_label_request][:option])
|
112
|
+
tag_unless_blank(xml, 'Revision', options[:usps_returns_label_request][:revision])
|
113
|
+
xml.tag!('ImageParameters') do
|
114
|
+
xml.tag!('ImageType', options[:usps_returns_label_request][:image_parameters][:image_type])
|
115
|
+
tag_unless_blank(xml, 'SeparateReceiptPage', options[:usps_returns_label_request][:image_parameters][:separate_receipt_page])
|
116
|
+
tag_unless_blank(xml, 'CustomerFirstName', options[:usps_returns_label_request][:image_parameters][:customer_first_name])
|
117
|
+
tag_unless_blank(xml, 'CustomerLastName', options[:usps_returns_label_request][:image_parameters][:customer_last_name])
|
118
|
+
tag_unless_blank(xml, 'CustomerFirm', options[:usps_returns_label_request][:image_parameters][:customer_firm])
|
119
|
+
tag_unless_blank(xml, 'CustomerAddress1', options[:usps_returns_label_request][:image_parameters][:customer_address1])
|
120
|
+
xml.tag!('CustomerAddress2', options[:usps_returns_label_request][:image_parameters][:customer_address2])
|
121
|
+
xml.tag!('CustomerCity', options[:usps_returns_label_request][:image_parameters][:customer_city])
|
122
|
+
xml.tag!('CustomerState', options[:usps_returns_label_request][:image_parameters][:customer_state])
|
123
|
+
xml.tag!('CustomerZip5', options[:usps_returns_label_request][:image_parameters][:customer_zip5])
|
124
|
+
tag_unless_blank(xml, 'CustomerZip4', options[:usps_returns_label_request][:image_parameters][:customer_zip4])
|
125
|
+
tag_unless_blank(xml, 'POZipCode', options[:usps_returns_label_request][:image_parameters][:po_zip_code])
|
126
|
+
tag_unless_blank(xml, 'AllowNonCleansedOriginAddr', options[:usps_returns_label_request][:image_parameters][:allow_non_cleansed_origin_addr])
|
127
|
+
tag_unless_blank(xml, 'WeightInOunces', options[:usps_returns_label_request][:image_parameters][:weight_in_ounces])
|
128
|
+
xml.tag!('ServiceType', options[:usps_returns_label_request][:image_parameters][:service_type])
|
129
|
+
tag_unless_blank(xml, 'Width', options[:usps_returns_label_request][:image_parameters][:width])
|
130
|
+
tag_unless_blank(xml, 'Length', options[:usps_returns_label_request][:image_parameters][:length])
|
131
|
+
tag_unless_blank(xml, 'Height', options[:usps_returns_label_request][:image_parameters][:height])
|
132
|
+
tag_unless_blank(xml, 'Girth', options[:usps_returns_label_request][:image_parameters][:girth])
|
133
|
+
tag_unless_blank(xml, 'Machinable', options[:usps_returns_label_request][:image_parameters][:machinable])
|
134
|
+
tag_unless_blank(xml, 'ShipDate', options[:usps_returns_label_request][:image_parameters][:ship_date])
|
135
|
+
tag_unless_blank(xml, 'SenderName', options[:usps_returns_label_request][:image_parameters][:sender_name])
|
136
|
+
tag_unless_blank(xml, 'SenderEMail', options[:usps_returns_label_request][:image_parameters][:sender_e_mail])
|
137
|
+
tag_unless_blank(xml, 'RecipientName', options[:usps_returns_label_request][:image_parameters][:recipient_name])
|
138
|
+
tag_unless_blank(xml, 'RecipientEMail', options[:usps_returns_label_request][:image_parameters][:recipient_e_mail])
|
139
|
+
xml.tag!('ExtraServices') do
|
140
|
+
tag_unless_blank(xml, 'ExtraService', options[:usps_returns_label_request][:image_parameters][:extra_services][:extra_service])
|
141
|
+
end if options[:usps_returns_label_request][:image_parameters][:extra_services].present?
|
142
|
+
end
|
143
|
+
xml.target!
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|