usps-ruby-client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.gitattributes +2 -0
  3. data/.gitignore +11 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +41 -0
  6. data/.rubocop_todo.yml +0 -0
  7. data/.travis.yml +6 -0
  8. data/CODE_OF_CONDUCT.md +74 -0
  9. data/Gemfile +8 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +77 -0
  12. data/Rakefile +9 -0
  13. data/bin/console +14 -0
  14. data/bin/setup +8 -0
  15. data/lib/data/api/address-information-api.htm +8229 -0
  16. data/lib/data/api/domestic-mail-service-standards-api.htm +11016 -0
  17. data/lib/data/api/evs-international-label-api.htm +33291 -0
  18. data/lib/data/api/evs-label-api.htm +18895 -0
  19. data/lib/data/api/hold-for-pickup-facilities-lookup-api.htm +5530 -0
  20. data/lib/data/api/package-pickup-api.htm +19157 -0
  21. data/lib/data/api/rate-calculator-api.htm +16355 -0
  22. data/lib/data/api/scan-api.htm +5934 -0
  23. data/lib/data/api/service-delivery-calculator-get-locations-api.htm +12548 -0
  24. data/lib/data/api/track-and-confirm-api.htm +21288 -0
  25. data/lib/data/api/uspsreturnslabel-api.htm +9474 -0
  26. data/lib/helpers/erubis_helper.rb +10 -0
  27. data/lib/tasks/api.rake +246 -0
  28. data/lib/usps-ruby-client.rb +30 -0
  29. data/lib/usps/api/endpoints.rb +70 -0
  30. data/lib/usps/api/endpoints/carrier_pickup_schedule.rb +117 -0
  31. data/lib/usps/api/endpoints/city_state_lookup.rb +50 -0
  32. data/lib/usps/api/endpoints/e_vs_express_mail_intl.rb +359 -0
  33. data/lib/usps/api/endpoints/e_vs_first_class_mail_intl.rb +323 -0
  34. data/lib/usps/api/endpoints/e_vs_priority_mail_intl.rb +366 -0
  35. data/lib/usps/api/endpoints/e_vsgxg_get_label.rb +366 -0
  36. data/lib/usps/api/endpoints/e_vsi_cancel.rb +55 -0
  37. data/lib/usps/api/endpoints/hfp_facility_info.rb +71 -0
  38. data/lib/usps/api/endpoints/intl_rate_v2.rb +135 -0
  39. data/lib/usps/api/endpoints/pts_email.rb +73 -0
  40. data/lib/usps/api/endpoints/pts_pod.rb +86 -0
  41. data/lib/usps/api/endpoints/pts_rre.rb +72 -0
  42. data/lib/usps/api/endpoints/ptst_pod.rb +75 -0
  43. data/lib/usps/api/endpoints/rate_v4.rb +140 -0
  44. data/lib/usps/api/endpoints/scan.rb +121 -0
  45. data/lib/usps/api/endpoints/track_v2.rb +62 -0
  46. data/lib/usps/api/endpoints/usps_returns_label.rb +149 -0
  47. data/lib/usps/api/endpoints/verify.rb +75 -0
  48. data/lib/usps/api/endpoints/zip_code_lookup.rb +69 -0
  49. data/lib/usps/api/error.rb +6 -0
  50. data/lib/usps/api/errors/too_many_requests_error.rb +22 -0
  51. data/lib/usps/api/errors/usps_error.rb +30 -0
  52. data/lib/usps/api/templates/_build_xml.erb +7 -0
  53. data/lib/usps/api/templates/_options.erb +6 -0
  54. data/lib/usps/api/templates/_throw_argument_error.erb +3 -0
  55. data/lib/usps/api/templates/endpoints.erb +22 -0
  56. data/lib/usps/api/templates/method.erb +49 -0
  57. data/lib/usps/api/templates/method_spec.erb +22 -0
  58. data/lib/usps/api/xml.rb +8 -0
  59. data/lib/usps/client.rb +37 -0
  60. data/lib/usps/config.rb +50 -0
  61. data/lib/usps/faraday/connection.rb +34 -0
  62. data/lib/usps/faraday/request.rb +39 -0
  63. data/lib/usps/faraday/response/raise_error.rb +16 -0
  64. data/lib/usps/logger.rb +14 -0
  65. data/lib/usps/version.rb +4 -0
  66. data/usps-ruby-client.gemspec +46 -0
  67. metadata +307 -0
@@ -0,0 +1,55 @@
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 EVSICancel
9
+ #
10
+ # eVS International Cancel API
11
+ #
12
+ # The eVS
13
+ # International Cancel request allows an eVS label to be removed from processing
14
+ # if the request is made prior to 11:59 PM Central Time on the day of label creation.This functionality is available only if the eVS International
15
+ # label has been held for manifest (i.e. <HoldForManifest>=”Y”
16
+ # is included in eVS International label XML request) and the Shipping Services
17
+ # File v2.0 has not yet been created. Depending on customer profile setup, this
18
+ # transmission could occur for created labels every 15 minutes, at the end of the
19
+ # shipping day, or when a SCAN Form is manually triggered by the customer.
20
+ #
21
+ # @option option [(Alias)] :eVSICancelRequest (Required)
22
+ # @option option [] :BarcodeNumber (Required)
23
+ # - BarcodeNumber of original label. Length of 22, 30 or 34 numbers.
24
+ # @option option [] :eVSICancelRequest (Required)
25
+
26
+ #
27
+ # @see
28
+ def e_vsi_cancel(options = {})
29
+ throw ArgumentError.new('Required arguments :e_vsi_cancel_request missing') if options[:e_vsi_cancel_request].nil?
30
+ throw ArgumentError.new('Required arguments :e_vsi_cancel_request, :barcode_number missing') if options[:e_vsi_cancel_request][:barcode_number].nil?
31
+ throw ArgumentError.new('Required arguments :e_vsi_cancel_request, :e_vsi_cancel_request missing') if options[:e_vsi_cancel_request][:e_vsi_cancel_request].nil?
32
+
33
+ request = build_request(:e_vsi_cancel, options)
34
+ get('https://secure.shippingapis.com/ShippingAPI.dll', {
35
+ API: 'eVSICancel',
36
+ XML: request,
37
+ })
38
+ end
39
+
40
+ private
41
+
42
+ def tag_unless_blank(xml, tag_name, data)
43
+ xml.tag!(tag_name, data) unless data.blank? || data.nil?
44
+ end
45
+
46
+ def build_e_vsi_cancel_request(xml, options = {})
47
+ xml.tag!('BarcodeNumber', options[:e_vsi_cancel_request][:barcode_number])
48
+ xml.tag!('eVSICancelRequest', options[:e_vsi_cancel_request][:e_vsi_cancel_request])
49
+ xml.target!
50
+ end
51
+
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,71 @@
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 HFPFacilityInfo
9
+ #
10
+ # Hold for Pickup Facility Information API
11
+ #
12
+ # Hold For
13
+ # Pickup service is available at approximately 31,000 USPS locations. This API
14
+ # will list US Postal Service Facilities where Hold-For-Pickup service is
15
+ # available. The response includes facilities based on ZIP code (five or nine
16
+ # digit) or City/State up to a maximum number of locations. Shipments are
17
+ # available for pickup by the recipient or a designee at the designated Hold For Pickup location by either 10 a.m., noon, or 3 p.m.,
18
+ # based on the service standard associated with the mail class. Hold For Pickup shipments are sent to a designated Hold For
19
+ # Pickup location, such as a Post Office, where the shipment can be picked up
20
+ # within five calendar days. Hold For Pickup service
21
+ # lets customers pick up shipments when it is convenient for them, with the
22
+ # assurance that their shipments are held safely and securely.
23
+ #
24
+ # @option option [(Alias)] :HFPFacilityInfoRequest (Required)
25
+ # - API=HFPFacilityInfo
26
+ # @option option [String] :PickupCity (Required)
27
+ # - Either City/State or ZIP code must be specified. When only city and state are provided, all pickup facilities with addresses within that city and state will be returned. For example: <PickupCity>Boston</PickupCity>
28
+ # @option option [String] :PickupState (Required)
29
+ # - Either City/State or ZIP code must be specified. For example: <PickupState>MA</PickupState>
30
+ # @option option [String] :PickupZIP (Required)
31
+ # - Either City/State or ZIP code must be specified. When PickupZIP provided without PickupZIP4, all pickup facilities that service that ZIP code are returned. For example: <PickupZIP>02111</PickupZIP>
32
+ # @option option [String] :PickupZIP4 (Required)
33
+ # - If PickupZIP is specified, then PickupZIP4 may also be specified. This will match to a single pickup facility with the given nine-digit ZIP code. For example: <PickupZIP4>9998</PickupZIP4>
34
+ # @option option [String] :Service (Optional)
35
+ # - For future use. May be omitted.
36
+
37
+ #
38
+ # @see
39
+ def hfp_facility_info(options = {})
40
+ throw ArgumentError.new('Required arguments :hfp_facility_info_request missing') if options[:hfp_facility_info_request].nil?
41
+ throw ArgumentError.new('Required arguments :hfp_facility_info_request, :pickup_city missing') if options[:hfp_facility_info_request][:pickup_city].nil?
42
+ throw ArgumentError.new('Required arguments :hfp_facility_info_request, :pickup_state missing') if options[:hfp_facility_info_request][:pickup_state].nil?
43
+ throw ArgumentError.new('Required arguments :hfp_facility_info_request, :pickup_zip missing') if options[:hfp_facility_info_request][:pickup_zip].nil?
44
+ throw ArgumentError.new('Required arguments :hfp_facility_info_request, :pickup_zip4 missing') if options[:hfp_facility_info_request][:pickup_zip4].nil?
45
+
46
+ request = build_request(:hfp_facility_info, options)
47
+ get('https://secure.shippingapis.com/ShippingAPI.dll', {
48
+ API: 'HFPFacilityInfo',
49
+ XML: request,
50
+ })
51
+ end
52
+
53
+ private
54
+
55
+ def tag_unless_blank(xml, tag_name, data)
56
+ xml.tag!(tag_name, data) unless data.blank? || data.nil?
57
+ end
58
+
59
+ def build_hfp_facility_info_request(xml, options = {})
60
+ xml.tag!('PickupCity', options[:hfp_facility_info_request][:pickup_city])
61
+ xml.tag!('PickupState', options[:hfp_facility_info_request][:pickup_state])
62
+ xml.tag!('PickupZIP', options[:hfp_facility_info_request][:pickup_zip])
63
+ xml.tag!('PickupZIP4', options[:hfp_facility_info_request][:pickup_zip4])
64
+ tag_unless_blank(xml, 'Service', options[:hfp_facility_info_request][:service])
65
+ xml.target!
66
+ end
67
+
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,135 @@
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 IntlRateV2
9
+ #
10
+ # International Rates API
11
+ #
12
+ # The
13
+ # IntlRateV2 API lets customers calculate the rate for international packages and
14
+ # envelopes given the weight and dimensions of the item. The IntlRateV2 API
15
+ # limits the data requested to twenty-five (25) packages per transaction. For
16
+ # specifications such as package dimensions, delivery information, etc, please refer to the International Mail Manual (IMM) at
17
+ # http://pe.usps.com/.
18
+ #
19
+ # @option option [(Alias)] :IntlRateV2Request (Required)
20
+ # - API=IntlRateV2 This API returns the current international USPS postage corresponding to the parameters given.
21
+ # @option option [String] :Revision (Optional)
22
+ # - Set this value to “2” to return all currently documented response fields. For example: <Revision>2</Revsion>
23
+ # @option option [(Group)] :Package (Optional)
24
+ # - Opening Package tag.
25
+ # @option option [NMTOKEN] :ID (Required)
26
+ # - No restriction on number or type of characters provided valid XML syntax and unique to request. For example: <Package ID="0">...</Package>
27
+ # @option option [Integer] :Pounds (Required)
28
+ # - Value must be numeric. Package weight generally cannot exceed 70 pounds. Maximum Decimal places are 8. Refer to the International Mail Manual (IMM) for weight requirements per country and mail service. The IMM can be found at the Postal Explorer web site. For example: <Pounds>2</Pounds> <Pounds>2.12345678</Pounds>
29
+ # @option option [Decimal] :Ounces (Required)
30
+ # - Value must be numeric. Package weight generally cannot exceed 70 pounds. Maximum Decimal places are 8. Refer to the International Mail Manual (IMM) for weight requirements per country and mail service. The IMM can be found at the Postal Explorer web site. For example: <Ounces>4</Ounces> <Ounces>4.12345678</Ounces>
31
+ # @option option [Boolean] :Machinable (Optional)
32
+ # - Indicates whether or not the item is machinable. A surcharge is applied to a First-Class Mail International item if it has one or more non-machinable characteristics. See International Mail Manual (IMM) Section 241.217 for more information. For example: <Machinable>True</Machinable>
33
+ # @option option [String] :MailType (Required)
34
+ # - Package type being shipped. For example: <MailType>Package</MailType>
35
+ # @option option [(Group)] :GXG (Optional)
36
+ # - If GXG rate is desired, then this group must be specified. Note that if this data precludes delivery, due to size or availability of service at the destination, then GXG rates simply will not be returned (not an error condition.)
37
+ # @option option [String] :POBoxFlag (Required)
38
+ # - Specify as "Y" if the destination is a post office box. For example: <POBoxFlag>Y</POBoxFlag>
39
+ # @option option [String] :GiftFlag (Required)
40
+ # - Specify as "Y" if the package contains a gift. For example: <GiftFlag>Y</GiftFlag>
41
+ # @option option [String] :ValueOfContents (Required)
42
+ # - If specified, used to compute Insurance fee (if insurance is available for service and destination). For example: <ValueOfContents>103.00</ValueOfContents>
43
+ # @option option [String] :Country (Required)
44
+ # - Entries must be from the USPS list of valid countries from the International Country Listings. To access the International Country Listings, go to the Index of Countries and Localities. For example: <Country>Albania</Country>
45
+ # @option option [String] :Container (Optional)
46
+ # - Note: This tag has been deprecated. <Container> tag and any values within the <Container> tag will not result in an error response and will not impact rates that are returned.
47
+ # @option option [String] :Size (Optional)
48
+ # - 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.
49
+ # @option option [Integer] :Width (Optional)
50
+ # - 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
51
+ # @option option [Integer] :Length (Optional)
52
+ # - 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
53
+ # @option option [Integer] :Height (Optional)
54
+ # - 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
55
+ # @option option [Integer] :Girth (Optional)
56
+ # - 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
57
+ # @option option [String] :OriginZip (Optional)
58
+ # - Available when IntlRateV2Request [Revision='2']. Origin ZIP Code is required to determine Priority Mail International price to Canadian destinations and is used to determine mail-ability of Global Express Guaranteed. When provided, the response will return a list of Post Office locations where GXG is accepted. The Origin ZIP Code must be valid. For example: <OriginZip>20770</OriginZip>
59
+ # @option option [String] :CommercialFlag (Optional)
60
+ # - Returns commercial base postage. For example: <CommercialFlag>Y<CommercialFlag>
61
+ # @option option [String] :CommercialPlusFlag (Optional)
62
+ # - Returns commercial plus postage. For example: <CommercialPlusFlag>Y<CommercialPlusFlag>
63
+ # @option option [(Group)] :ExtraServices (Optional)
64
+ # - Available when IntlRateV2Request[Revision='2']. Groups the ExtraService elements.
65
+ # @option option [Extra Service Name] :ExtraService (Optional)
66
+ # - [{"Extra Service Name"=>"Registered Mail", "ServiceID"=>"103"}, {"Extra Service Name"=>"Insurance – Global Express Guaranteed", "ServiceID"=>"106"}, {"Extra Service Name"=>"Insurance – Priority Mail International", "ServiceID"=>"108"}, {"Extra Service Name"=>"Return Receipt", "ServiceID"=>"105"}, {"Extra Service Name"=>"Certificate of Mailing", "ServiceID"=>"100"}, {"Extra Service Name"=>"Electronic USPS Delivery Confirmation International", "ServiceID"=>"109"}]
67
+ # @option option [DateTime] :AcceptanceDateTime (Optional)
68
+ # - Available when IntlRateV2Request[Revision='2']. Date and Time the package is accepted by USPS. The AcceptanceDateTime tag along with the DestinationPostalCode and OriginZip is used to calculate the GuaranteeAvailability and also GuaranteeAvailability response tag for PMEI services in Kahala countries. ISO 8601 formatted date. YYYY-MM-DDThh:mm:ss+/-hh:mm For example, 2014-01-22T14:30:51-06:00
69
+ # @option option [String] :DestinationPostalCode (Optional)
70
+ # - Available when IntlRateV2Request[Revision='2']. Destination Postal Code The AcceptanceDateTime tag along with the DestinationPostalCode and OriginZip is used to calculate the GuaranteeAvailability and also GuaranteeAvailability response tag for PMEI services in Kahala countries.
71
+ # @option option [(Group)] :Content (Optional)
72
+ # - Used to describe the contents of the package.
73
+ # @option option [String] :ContentType (Optional)
74
+ # - Contains the enumerated description of the items in the package. “NonnegotiableDocument” and “Documents” both signify mailable non-negotiable documents and are insured automatically for up to $100, though Insurance will not be returned as an extra service. Additional Insurance cannot be purchased. Any non-document ContentType values are insured automatically for up to $200 and Insurance will be returned as an explicit extra service in the response. Additional Insurance can be purchased for values $200 and greater.
75
+ # @option option [String] :ContentDescription (Optional)
76
+ # - For future use
77
+
78
+ #
79
+ # @see
80
+ def intl_rate_v2(options = {})
81
+ throw ArgumentError.new('Required arguments :intl_rate_v2_request missing') if options[:intl_rate_v2_request].nil?
82
+
83
+ request = build_request(:intl_rate_v2, options)
84
+ get('https://secure.shippingapis.com/ShippingAPI.dll', {
85
+ API: 'IntlRateV2',
86
+ XML: request,
87
+ })
88
+ end
89
+
90
+ private
91
+
92
+ def tag_unless_blank(xml, tag_name, data)
93
+ xml.tag!(tag_name, data) unless data.blank? || data.nil?
94
+ end
95
+
96
+ def build_intl_rate_v2_request(xml, options = {})
97
+ tag_unless_blank(xml, 'Revision', options[:intl_rate_v2_request][:revision])
98
+ xml.tag!('Package') do
99
+ xml.tag!('ID', options[:intl_rate_v2_request][:package][:id])
100
+ xml.tag!('Pounds', options[:intl_rate_v2_request][:package][:pounds])
101
+ xml.tag!('Ounces', options[:intl_rate_v2_request][:package][:ounces])
102
+ tag_unless_blank(xml, 'Machinable', options[:intl_rate_v2_request][:package][:machinable])
103
+ xml.tag!('MailType', options[:intl_rate_v2_request][:package][:mail_type])
104
+ xml.tag!('GXG') do
105
+ xml.tag!('POBoxFlag', options[:intl_rate_v2_request][:package][:gxg][:po_box_flag])
106
+ xml.tag!('GiftFlag', options[:intl_rate_v2_request][:package][:gxg][:gift_flag])
107
+ xml.tag!('ValueOfContents', options[:intl_rate_v2_request][:package][:gxg][:value_of_contents])
108
+ xml.tag!('Country', options[:intl_rate_v2_request][:package][:gxg][:country])
109
+ tag_unless_blank(xml, 'Container', options[:intl_rate_v2_request][:package][:gxg][:container])
110
+ tag_unless_blank(xml, 'Size', options[:intl_rate_v2_request][:package][:gxg][:size])
111
+ tag_unless_blank(xml, 'Width', options[:intl_rate_v2_request][:package][:gxg][:width])
112
+ tag_unless_blank(xml, 'Length', options[:intl_rate_v2_request][:package][:gxg][:length])
113
+ tag_unless_blank(xml, 'Height', options[:intl_rate_v2_request][:package][:gxg][:height])
114
+ tag_unless_blank(xml, 'Girth', options[:intl_rate_v2_request][:package][:gxg][:girth])
115
+ tag_unless_blank(xml, 'OriginZip', options[:intl_rate_v2_request][:package][:gxg][:origin_zip])
116
+ tag_unless_blank(xml, 'CommercialFlag', options[:intl_rate_v2_request][:package][:gxg][:commercial_flag])
117
+ tag_unless_blank(xml, 'CommercialPlusFlag', options[:intl_rate_v2_request][:package][:gxg][:commercial_plus_flag])
118
+ xml.tag!('ExtraServices') do
119
+ tag_unless_blank(xml, 'ExtraService', options[:intl_rate_v2_request][:package][:gxg][:extra_services][:extra_service])
120
+ tag_unless_blank(xml, 'AcceptanceDateTime', options[:intl_rate_v2_request][:package][:gxg][:extra_services][:acceptance_date_time])
121
+ tag_unless_blank(xml, 'DestinationPostalCode', options[:intl_rate_v2_request][:package][:gxg][:extra_services][:destination_postal_code])
122
+ xml.tag!('Content') do
123
+ tag_unless_blank(xml, 'ContentType', options[:intl_rate_v2_request][:package][:gxg][:extra_services][:content][:content_type])
124
+ tag_unless_blank(xml, 'ContentDescription', options[:intl_rate_v2_request][:package][:gxg][:extra_services][:content][:content_description])
125
+ end if options[:intl_rate_v2_request][:package][:gxg][:extra_services][:content].present?
126
+ end if options[:intl_rate_v2_request][:package][:gxg][:extra_services].present?
127
+ end if options[:intl_rate_v2_request][:package][:gxg].present?
128
+ end if options[:intl_rate_v2_request][:package].present?
129
+ xml.target!
130
+ end
131
+
132
+ end
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,73 @@
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 PTSEmail
9
+ #
10
+ # Track and Confirm by Email API
11
+ #
12
+ # The Track and Confirm by
13
+ # Email API allows the customer to submit their email address to be notified of
14
+ # current or future tracking activity. When you request access for this API,
15
+ # please identify your anticipated API volume, mailer ID and how you will be
16
+ # utilizing this API. A mailer identification number (MID) is a 6 or 9-digit
17
+ # number assigned to a customer through the USPS Business Customer Gateway (BCG).
18
+ # Please refer to the following links for help:
19
+ #
20
+ # @option option [(Alias)] :PTSEmailRequest (Required)
21
+ # @option option [String] :TrackId (Required)
22
+ # @option option [String] :ClientIp (Optional)
23
+ # @option option [String] :SourceId (Optional)
24
+ # @option option [Integer] :MpSuffix (Required)
25
+ # @option option [String] :MpDate (Required)
26
+ # @option option [Request Type] :RequestType (Optional)
27
+ # @option option [String] :FirstName (Optional)
28
+ # @option option [String] :LastName (Optional)
29
+ # @option option [String] :Email1 (Required)
30
+ # @option option [String] :Email2 (Optional)
31
+ # @option option [String] :Email3 (Optional)
32
+
33
+ #
34
+ # @see
35
+ def pts_email(options = {})
36
+ throw ArgumentError.new('Required arguments :pts_email_request missing') if options[:pts_email_request].nil?
37
+ throw ArgumentError.new('Required arguments :pts_email_request, :track_id missing') if options[:pts_email_request][:track_id].nil?
38
+ throw ArgumentError.new('Required arguments :pts_email_request, :mp_suffix missing') if options[:pts_email_request][:mp_suffix].nil?
39
+ throw ArgumentError.new('Required arguments :pts_email_request, :mp_date missing') if options[:pts_email_request][:mp_date].nil?
40
+ throw ArgumentError.new('Required arguments :pts_email_request, :email1 missing') if options[:pts_email_request][:email1].nil?
41
+
42
+ request = build_request(:pts_email, options)
43
+ get('https://secure.shippingapis.com/ShippingAPI.dll', {
44
+ API: 'PTSEmail',
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_pts_email_request(xml, options = {})
56
+ xml.tag!('TrackId', options[:pts_email_request][:track_id])
57
+ tag_unless_blank(xml, 'ClientIp', options[:pts_email_request][:client_ip])
58
+ tag_unless_blank(xml, 'SourceId', options[:pts_email_request][:source_id])
59
+ xml.tag!('MpSuffix', options[:pts_email_request][:mp_suffix])
60
+ xml.tag!('MpDate', options[:pts_email_request][:mp_date])
61
+ tag_unless_blank(xml, 'RequestType', options[:pts_email_request][:request_type])
62
+ tag_unless_blank(xml, 'FirstName', options[:pts_email_request][:first_name])
63
+ tag_unless_blank(xml, 'LastName', options[:pts_email_request][:last_name])
64
+ xml.tag!('Email1', options[:pts_email_request][:email1])
65
+ tag_unless_blank(xml, 'Email2', options[:pts_email_request][:email2])
66
+ tag_unless_blank(xml, 'Email3', options[:pts_email_request][:email3])
67
+ xml.target!
68
+ end
69
+
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,86 @@
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 PTSPod
9
+ #
10
+ # Proof of Delivery API
11
+ #
12
+ # Proof of
13
+ # Delivery is a letter that includes the recipient's name and a copy of their
14
+ # signature. The Proof of Delivery API
15
+ # allows the customer to request proof of delivery notification via email. When
16
+ # you request access for this API, please identify your anticipated API volume,
17
+ # mailer ID and how you will be utilizing this API. A mailer identification
18
+ # number (MID) is a 6 or 9-digit number assigned to a customer through the USPS
19
+ # Business Customer Gateway (BCG). Please refer to the following links for help:
20
+ #
21
+ # @option option [(Alias)] :PTSPodRequest (Optional)
22
+ # @option option [String] :TrackId (Required)
23
+ # @option option [String] :ClientIp (Optional)
24
+ # @option option [String] :SourceId (Optional)
25
+ # @option option [integer] :MpSuffix (Required)
26
+ # @option option [String] :MpDate (Required)
27
+ # @option option [String] :RequestType (Required)
28
+ # @option option [String] :FirstName (Required)
29
+ # @option option [String] :LastName (Required)
30
+ # @option option [String] :Email1 (Optional)
31
+ # @option option [String] :Email2 (Optional)
32
+ # @option option [String] :Email3 (Optional)
33
+ # @option option [String] :FaxNumber (Optional)
34
+ # @option option [String] :AddressLine1 (Optional)
35
+ # @option option [String] :AddressLine2 (Optional)
36
+ # @option option [String] :City (Optional)
37
+ # @option option [String] :State (Optional)
38
+ # @option option [String] :Zip (Optional)
39
+ # @option option [Boolean] :VerifyAddress (Optional)
40
+ # @option option [String] :TableCode (Required)
41
+ # @option option [String] :CustRegID (Optional)
42
+
43
+ #
44
+ # @see
45
+ def pts_pod(options = {})
46
+ request = build_request(:pts_pod, options)
47
+ get('https://secure.shippingapis.com/ShippingAPI.dll', {
48
+ API: 'PTSPod',
49
+ XML: request,
50
+ })
51
+ end
52
+
53
+ private
54
+
55
+ def tag_unless_blank(xml, tag_name, data)
56
+ xml.tag!(tag_name, data) unless data.blank? || data.nil?
57
+ end
58
+
59
+ def build_pts_pod_request(xml, options = {})
60
+ xml.tag!('TrackId', options[:pts_pod_request][:track_id])
61
+ tag_unless_blank(xml, 'ClientIp', options[:pts_pod_request][:client_ip])
62
+ tag_unless_blank(xml, 'SourceId', options[:pts_pod_request][:source_id])
63
+ xml.tag!('MpSuffix', options[:pts_pod_request][:mp_suffix])
64
+ xml.tag!('MpDate', options[:pts_pod_request][:mp_date])
65
+ xml.tag!('RequestType', options[:pts_pod_request][:request_type])
66
+ xml.tag!('FirstName', options[:pts_pod_request][:first_name])
67
+ xml.tag!('LastName', options[:pts_pod_request][:last_name])
68
+ tag_unless_blank(xml, 'Email1', options[:pts_pod_request][:email1])
69
+ tag_unless_blank(xml, 'Email2', options[:pts_pod_request][:email2])
70
+ tag_unless_blank(xml, 'Email3', options[:pts_pod_request][:email3])
71
+ tag_unless_blank(xml, 'FaxNumber', options[:pts_pod_request][:fax_number])
72
+ tag_unless_blank(xml, 'AddressLine1', options[:pts_pod_request][:address_line1])
73
+ tag_unless_blank(xml, 'AddressLine2', options[:pts_pod_request][:address_line2])
74
+ tag_unless_blank(xml, 'City', options[:pts_pod_request][:city])
75
+ tag_unless_blank(xml, 'State', options[:pts_pod_request][:state])
76
+ tag_unless_blank(xml, 'Zip', options[:pts_pod_request][:zip])
77
+ tag_unless_blank(xml, 'VerifyAddress', options[:pts_pod_request][:verify_address])
78
+ xml.tag!('TableCode', options[:pts_pod_request][:table_code])
79
+ tag_unless_blank(xml, 'CustRegID', options[:pts_pod_request][:cust_reg_id])
80
+ xml.target!
81
+ end
82
+
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,72 @@
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 PTSRre
9
+ #
10
+ # Return Receipt Electronic API
11
+ #
12
+ # Overview
13
+ #
14
+ # @option option [(Alias)] :PTSRreRequest (Required)
15
+ # @option option [String] :TrackId (Required)
16
+ # @option option [String] :ClientIp (Optional)
17
+ # @option option [String] :SourceId (Optional)
18
+ # @option option [integer] :MpSuffix (Required)
19
+ # @option option [String] :MpDate (Required)
20
+ # @option option [String] :FirstName (Required)
21
+ # @option option [String] :LastName (Required)
22
+ # @option option [String] :Email1 (Required)
23
+ # @option option [String] :Email2 (Optional)
24
+ # @option option [String] :Email3 (Optional)
25
+ # @option option [String] :TableCode (Required)
26
+ # @option option [String] :CustRegID (Optional)
27
+
28
+ #
29
+ # @see
30
+ def pts_rre(options = {})
31
+ throw ArgumentError.new('Required arguments :pts_rre_request missing') if options[:pts_rre_request].nil?
32
+ throw ArgumentError.new('Required arguments :pts_rre_request, :track_id missing') if options[:pts_rre_request][:track_id].nil?
33
+ throw ArgumentError.new('Required arguments :pts_rre_request, :mp_suffix missing') if options[:pts_rre_request][:mp_suffix].nil?
34
+ throw ArgumentError.new('Required arguments :pts_rre_request, :mp_date missing') if options[:pts_rre_request][:mp_date].nil?
35
+ throw ArgumentError.new('Required arguments :pts_rre_request, :first_name missing') if options[:pts_rre_request][:first_name].nil?
36
+ throw ArgumentError.new('Required arguments :pts_rre_request, :last_name missing') if options[:pts_rre_request][:last_name].nil?
37
+ throw ArgumentError.new('Required arguments :pts_rre_request, :email1 missing') if options[:pts_rre_request][:email1].nil?
38
+ throw ArgumentError.new('Required arguments :pts_rre_request, :table_code missing') if options[:pts_rre_request][:table_code].nil?
39
+
40
+ request = build_request(:pts_rre, options)
41
+ get('https://secure.shippingapis.com/ShippingAPI.dll', {
42
+ API: 'PTSRre',
43
+ XML: request,
44
+ })
45
+ end
46
+
47
+ private
48
+
49
+ def tag_unless_blank(xml, tag_name, data)
50
+ xml.tag!(tag_name, data) unless data.blank? || data.nil?
51
+ end
52
+
53
+ def build_pts_rre_request(xml, options = {})
54
+ xml.tag!('TrackId', options[:pts_rre_request][:track_id])
55
+ tag_unless_blank(xml, 'ClientIp', options[:pts_rre_request][:client_ip])
56
+ tag_unless_blank(xml, 'SourceId', options[:pts_rre_request][:source_id])
57
+ xml.tag!('MpSuffix', options[:pts_rre_request][:mp_suffix])
58
+ xml.tag!('MpDate', options[:pts_rre_request][:mp_date])
59
+ xml.tag!('FirstName', options[:pts_rre_request][:first_name])
60
+ xml.tag!('LastName', options[:pts_rre_request][:last_name])
61
+ xml.tag!('Email1', options[:pts_rre_request][:email1])
62
+ tag_unless_blank(xml, 'Email2', options[:pts_rre_request][:email2])
63
+ tag_unless_blank(xml, 'Email3', options[:pts_rre_request][:email3])
64
+ xml.tag!('TableCode', options[:pts_rre_request][:table_code])
65
+ tag_unless_blank(xml, 'CustRegID', options[:pts_rre_request][:cust_reg_id])
66
+ xml.target!
67
+ end
68
+
69
+ end
70
+ end
71
+ end
72
+ end