usps-ruby-client 0.1.0 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 905fbeac9ca32a16da34b2d05b5fff6f8da6a6be7c43a106e21ed211baba6009
4
- data.tar.gz: 55d68eb569dc6fdf59936325ced2c66a7126f89387858155f6da8101fbfffa1c
3
+ metadata.gz: d043c38b987945e397288c72d37999ec2cd48feafcfa2ad36e5bf8384f4f3b3f
4
+ data.tar.gz: efdd9aadfd5e17502a72ceed2c5dee89d2c395cb0e784bb77ec6f230a6b5eb5c
5
5
  SHA512:
6
- metadata.gz: 6635afa2a146f0aaf2fd4343894123ae4f0f726d61988127642c0c73d4c391ca16d93d30dc80281071050ddfafed997143e37138d842f6b4646a3c7d513a7839
7
- data.tar.gz: 5252edd86fec07850f0f6f08a4c0b1105fe7155c34607a6824705587733e5bfc4043fc0adc62c62ba2714838d6db053d0785c3f39e60c0079fef1d53390b8dc0
6
+ metadata.gz: 28240a6e23dc9d489e8d8dcf93925e1a71bba85b6e4e78eae4962705aca039abcdbaf3797bcc832c3618646ff47700dad9c71da97e90df54cf3812d08a714a14
7
+ data.tar.gz: bf52634627bd132fffae3c5c493f9c1e29366ebe9e576905ac4c69710cb005f0021ea33ed85113e22e0ce6e23877166efe1abc6e15d85bfcc79c58d7dae7112c
data/Gemfile.lock ADDED
@@ -0,0 +1,113 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ usps-ruby-client (0.1.3)
5
+ activesupport (~> 7.0)
6
+ builder (~> 3.2)
7
+ faraday (~> 0.17)
8
+ faraday_middleware (~> 0.14)
9
+ multi_xml (~> 0.6)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ activesupport (7.0.2.3)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 1.6, < 2)
17
+ minitest (>= 5.1)
18
+ tzinfo (~> 2.0)
19
+ amazing_print (1.4.0)
20
+ ast (2.4.2)
21
+ builder (3.2.4)
22
+ coderay (1.1.3)
23
+ concurrent-ruby (1.1.10)
24
+ diff-lcs (1.5.0)
25
+ docile (1.4.0)
26
+ erubis (2.7.0)
27
+ faraday (0.17.5)
28
+ multipart-post (>= 1.2, < 3)
29
+ faraday_middleware (0.14.0)
30
+ faraday (>= 0.7.4, < 1.0)
31
+ i18n (1.10.0)
32
+ concurrent-ruby (~> 1.0)
33
+ method_source (1.0.0)
34
+ mini_portile2 (2.8.0)
35
+ minitest (5.15.0)
36
+ multi_xml (0.6.0)
37
+ multipart-post (2.1.1)
38
+ nokogiri (1.13.3)
39
+ mini_portile2 (~> 2.8.0)
40
+ racc (~> 1.4)
41
+ parallel (1.22.1)
42
+ parser (3.1.1.0)
43
+ ast (~> 2.4.1)
44
+ pry (0.14.1)
45
+ coderay (~> 1.1)
46
+ method_source (~> 1.0)
47
+ racc (1.6.0)
48
+ rainbow (3.1.1)
49
+ rake (12.3.3)
50
+ regexp_parser (2.2.1)
51
+ rexml (3.2.5)
52
+ rspec (3.11.0)
53
+ rspec-core (~> 3.11.0)
54
+ rspec-expectations (~> 3.11.0)
55
+ rspec-mocks (~> 3.11.0)
56
+ rspec-core (3.11.0)
57
+ rspec-support (~> 3.11.0)
58
+ rspec-expectations (3.11.0)
59
+ diff-lcs (>= 1.2.0, < 2.0)
60
+ rspec-support (~> 3.11.0)
61
+ rspec-mocks (3.11.0)
62
+ diff-lcs (>= 1.2.0, < 2.0)
63
+ rspec-support (~> 3.11.0)
64
+ rspec-support (3.11.0)
65
+ rubocop (1.26.1)
66
+ parallel (~> 1.10)
67
+ parser (>= 3.1.0.0)
68
+ rainbow (>= 2.2.2, < 4.0)
69
+ regexp_parser (>= 1.8, < 3.0)
70
+ rexml
71
+ rubocop-ast (>= 1.16.0, < 2.0)
72
+ ruby-progressbar (~> 1.7)
73
+ unicode-display_width (>= 1.4.0, < 3.0)
74
+ rubocop-ast (1.16.0)
75
+ parser (>= 3.1.1.0)
76
+ rubocop-performance (1.13.3)
77
+ rubocop (>= 1.7.0, < 2.0)
78
+ rubocop-ast (>= 0.4.0)
79
+ rubocop-rspec (2.9.0)
80
+ rubocop (~> 1.19)
81
+ ruby-progressbar (1.11.0)
82
+ simplecov (0.21.2)
83
+ docile (~> 1.1)
84
+ simplecov-html (~> 0.11)
85
+ simplecov_json_formatter (~> 0.1)
86
+ simplecov-html (0.12.3)
87
+ simplecov_json_formatter (0.1.4)
88
+ tzinfo (2.0.4)
89
+ concurrent-ruby (~> 1.0)
90
+ unicode-display_width (2.1.0)
91
+ webrick (1.7.0)
92
+ yard (0.9.27)
93
+ webrick (~> 1.7.0)
94
+
95
+ PLATFORMS
96
+ ruby
97
+
98
+ DEPENDENCIES
99
+ amazing_print (~> 1.2)
100
+ erubis (~> 2.7)
101
+ nokogiri (~> 1.10)
102
+ pry (~> 0.13)
103
+ rake (~> 12.0)
104
+ rspec (~> 3.0)
105
+ rubocop (~> 1.7)
106
+ rubocop-performance (~> 1.9)
107
+ rubocop-rspec (~> 2.1)
108
+ simplecov (~> 0.21)
109
+ usps-ruby-client!
110
+ yard (~> 0.9)
111
+
112
+ BUNDLED WITH
113
+ 2.3.5
data/README.md CHANGED
@@ -6,7 +6,7 @@ USPS Ruby Client
6
6
 
7
7
  An unofficial Ruby client for The United Sates Postal Service Web Tools API.
8
8
 
9
- **Disclaimer** This gem is mostly auto-generated from the [USPS API User Guides](https://www.usps.com/business/web-tools-apis/documentation-updates.htm). Because of inconsistencies and innacurracies in the user guides some end points may not work as expected, or may not be consistent with other methods in this gem.
9
+ **Disclaimer** This gem is mostly auto-generated from the [USPS API User Guides](https://www.usps.com/business/web-tools-apis/documentation-updates.htm). Because of inconsistencies and inaccuracies in the user guides, some endpoints may not work as expected or may not be consistent with other methods in this gem.
10
10
 
11
11
  ## Installation
12
12
 
@@ -52,26 +52,31 @@ client.city_state_lookup({
52
52
  }
53
53
  ```
54
54
 
55
+ ## RubyDoc Automatic Documentation
56
+ The generator also creates [documentation](https://rubydoc.info/gems/usps-ruby-client) to help you navigate the available methods. It has the same issues presented in the disclaimer above.
57
+
55
58
  ## Development
56
59
 
57
60
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
58
61
 
59
62
  ### Updating the auto-generated methods
60
63
 
61
- Because the USPS website does not allow scripts to make requests against their website you must [download the API User Guide HTML files manually](https://www.usps.com/business/web-tools-apis/documentation-updates.htm). I recommend right-clicking the **HTM** and selecting *Save Link As...* to prevent any browser extensions from injecting their code and breaking the parsing.
64
+ Because the USPS website does not allow scripts to make requests against their website, you must [download the API User Guide HTML files manually](https://www.usps.com/business/web-tools-apis/documentation-updates.htm). I recommend right-clicking the **HTM** and selecting *Save Link As...* to prevent any browser extensions from injecting their code and breaking the parsing.
65
+
66
+ Place just the `.htm` files in `lib/data/api` (and remove any that may no longer be active) and run `rake usps:api:update`. This task will recreate all the appropriate methods and some basic spec tests.
62
67
 
63
- Place just the `.htm` files in `lib/data/api` (and remove any they may no longer be active) and run `rake usps:api:update`. This task will recreate all the relevant methods and some basic spec tests.
68
+ We might be able to automate this with a headless browser tool like Watir, but only if we can do that in a way that doesn't bloat the gem as a whole.
64
69
 
65
70
  ## Contributing
66
71
 
67
72
  Bug reports and pull requests are welcome on GitHub at https://github.com/joeyparis/usps-ruby-client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/joeyparis/usps-ruby-client/blob/master/CODE_OF_CONDUCT.md).
68
73
 
69
- This is still an early work-in-progress so any additional help is definitely appreciated!
74
+ This project is still an early work-in-progress, so any additional help is greatly appreciated!
70
75
 
71
76
  ## License
72
77
 
73
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
78
+ The gem is available as open-source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
74
79
 
75
80
  ## Code of Conduct
76
81
 
77
- Everyone interacting in the Usps project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/joeyparis/usps-ruby-client/blob/master/CODE_OF_CONDUCT.md).
82
+ Everyone interacting in the Usps project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [code of conduct](https://github.com/joeyparis/usps-ruby-client/blob/master/CODE_OF_CONDUCT.md).
data/lib/tasks/api.rake CHANGED
@@ -25,7 +25,7 @@ namespace :usps do
25
25
  row_data = {}
26
26
  columns.each_with_index do |k, i|
27
27
  row_data[k.to_s.gsub(/[[:space:]]+/, ' ').strip] =
28
- row[i].is_a? String ? row[i].to_s.gsub(/[[:space:]]+/, ' ').strip : row[i]
28
+ row[i].is_a?(String) ? row[i].to_s.gsub(/[[:space:]]+/, ' ').strip : row[i]
29
29
  end
30
30
  row_data
31
31
  end
@@ -6,57 +6,32 @@ module Usps
6
6
  module Api
7
7
  module Endpoints
8
8
  module CarrierPickupSchedule
9
- #
10
- # Package Pickup Schedule API
11
- #
12
9
  # The Package Pickup Schedule API schedules a
13
10
  # Package Pickup and provides the user a confirmation number for the scheduled
14
11
  # pickup. Prior to making a Pickup Schedule call, it is recommended to use
15
12
  # the Pickup Availability API to confirm that service is available.
16
- #
17
- # @option option [(Alias)] :CarrierPickupScheduleRequest (Required)
18
- # @option option [String] :FirstName (Required)
19
- # - Only alpha characters, apostrophes, spaces, periods, and hyphens "-" may be used. For example: <FirstName>John</FirstName>
20
- # @option option [String] :LastName (Required)
21
- # - Only alpha characters, apostrophes, spaces, periods and hyphens "-" may be used. For example: <LastName>Doe</LastName>
22
- # @option option [String] :FirmName (Optional)
23
- # - Only alpha and numeric characters, apostrophes, spaces, hyphens "-" and ampersands "&" may be used. Use this tag for a firm or company name. Some firms/companies that have their own ZIP codes require the use of firm name to properly identify their address. Note: FirmName is Optional except if the First Name and Last Name tags are null. For example: <FirmName>ABC Company</FirmName>
24
- # @option option [String] :SuiteOrApt (Required)
25
- # - Apartment or suite number. Optional except if needed to uniquely identify an address at a multiple dwelling address, for example, an apartment building. For example: <SuiteOrApt>Suite 777</SuiteOrApt>
26
- # @option option [String] :Address2 (Required)
27
- # - Street address. For example: <Address2>1390 Market Street</Address2>
28
- # @option option [String] :Urbanization (Required)
29
- # - Use this tag for Urbanization (for Puerto Rico only). ZIP Code prefixes 006 to 009, if area is so designated.
30
- # @option option [String] :City (Required)
31
- # - City name. Either ZIP5 or City and State are required. For example: <City>Houston</City>
32
- # @option option [String] :State (Required)
33
- # - State abbreviation. Either ZIP5 or City and State are required. For example: <State>TX</State>
34
- # @option option [String] :ZIP5 (Required)
35
- # - 5-digit ZIP Code. Either ZIP5 or City and State are required. For example: <ZIP5>77058</ZIP5>
36
- # @option option [String] :ZIP4 (Required)
37
- # - Use this tag for a 4 digit ZIP Code. For example: <ZIP4>1234</ZIP4>
38
- # @option option [String] :Phone (Required)
39
- # - Two formats are allowed: (###) 123-4567 or ###-123-4567. For example: <Phone>5555551234</Phone> or <Phone>555-555-1234</Phone>
40
- # @option option [String] :Extension (Optional)
41
- # - Optional value for Phone Extension. For example: <Extension>201</Extension>
42
- # @option option [(Group)] :Package (Required)
43
- # - No values entered with this tag. <ServiceType> and <Count> tags are embedded under this. Refer to the XML request example section, below, to see how these embedded tags are formatted. If the <Count> for a service type is zero, you do not need to encode a <Package> but you must have at least one <Package> with embedded <ServiceType> and <Count> tags.
44
- # @option option [String] :ServiceType (Required)
45
- # - This tag is embedded under the <Package> tag. If your pickup contains more than one Service Type, use additional <Package> tags for each service type with the accompanying <ServiceType> and <Count> tags. Refer to the XML Request Example below to see how these embedded tags are formatted. For example: <ServiceType>PriorityMailExpress</ServiceType>
46
- # @option option [String] :Count (Required)
47
- # - This tag is embedded under the <Package> tag. Enter the number of packages for the accompanying <ServiceType> tag. Maximum characters allowed: 3 or 999 packages. If your pickup contains more than one Service Type, use additional <Package> tags for each service type with the accompanying <ServiceType> and <Count> tags. Refer to the XML request example section, below, to see how these embedded tags are formatted. For example: <Count>2</Count>
48
- # @option option [String] :EstimatedWeight (Required)
49
- # - Enter the estimated aggregate weight (in pounds) of all packages being picked up. For example: <EstimatedWeight>14</EstimatedWeight>
50
- # @option option [String] :PackageLocation (Required)
51
- # - Enter one of the following values: Note: "Other" requires information in the value for the <SpecialInstructions> tag. For example: <PackageLocation>Front Door</PackageLocation>
52
- # @option option [String] :SpecialInstructions (Optional)
53
- # - Value Required when PackageLocation is “Other”. Only alpha, numeric, commas, periods, apostrophes, _, &, -, ( ), ?, #, / +, @ and space characters may be used. For example: <SpecialInstructions>Packages are behind the screen door.</SpecialInstructions>
54
- # @option option [String] :EmailAddress (Optional)
55
- # - If provided, email notifications will be sent confirming package pickup, or request changes and cancellations. Maximum characters allowed: 50. For example: <EmailAddress>cpapple@email.com</EmailAddress>
56
-
57
- #
58
- # @see
59
- def carrier_pickup_schedule(options = {})
13
+ # @param [Hash] options
14
+ # @option options [required, Hash] carrier_pickup_schedule_request
15
+ # * *:first_name* (required, String) — Only alpha characters, apostrophes, spaces, periods, and hyphens "-" may be used. For example: <FirstName>John</FirstName>
16
+ # * *:last_name* (required, String) — Only alpha characters, apostrophes, spaces, periods and hyphens "-" may be used. For example: <LastName>Doe</LastName>
17
+ # * *:firm_name* (String) — Only alpha and numeric characters, apostrophes, spaces, hyphens "-" and ampersands "&" may be used. Use this tag for a firm or company name. Some firms/companies that have their own ZIP codes require the use of firm name to properly identify their address. Note: FirmName is Optional except if the First Name and Last Name tags are null. For example: <FirmName>ABC Company</FirmName>
18
+ # * *:suite_or_apt* (required, String) Apartment or suite number. Optional except if needed to uniquely identify an address at a multiple dwelling address, for example, an apartment building. For example: <SuiteOrApt>Suite 777</SuiteOrApt>
19
+ # * *:address2* (required, String) — Street address. For example: <Address2>1390 Market Street</Address2>
20
+ # * *:urbanization* (required, String) Use this tag for Urbanization (for Puerto Rico only). ZIP Code prefixes 006 to 009, if area is so designated.
21
+ # * *:city* (required, String) — City name. Either ZIP5 or City and State are required. For example: <City>Houston</City>
22
+ # * *:state* (required, String) State abbreviation. Either ZIP5 or City and State are required. For example: <State>TX</State>
23
+ # * *:zip5* (required, String) — 5-digit ZIP Code. Either ZIP5 or City and State are required. For example: <ZIP5>77058</ZIP5>
24
+ # * *:zip4* (required, String) — Use this tag for a 4 digit ZIP Code. For example: <ZIP4>1234</ZIP4>
25
+ # * *:phone* (required, String) — Two formats are allowed: (###) 123-4567 or ###-123-4567. For example: <Phone>5555551234</Phone> or <Phone>555-555-1234</Phone>
26
+ # * *:extension* (String) Optional value for Phone Extension. For example: <Extension>201</Extension>
27
+ # * *:package* (required, Hash) — No values entered with this tag. <ServiceType> and <Count> tags are embedded under this. Refer to the XML request example section, below, to see how these embedded tags are formatted. If the <Count> for a service type is zero, you do not need to encode a <Package> but you must have at least one <Package> with embedded <ServiceType> and <Count> tags.
28
+ # * *:service_type* (required, String) — This tag is embedded under the <Package> tag. If your pickup contains more than one Service Type, use additional <Package> tags for each service type with the accompanying <ServiceType> and <Count> tags. Refer to the XML Request Example below to see how these embedded tags are formatted. For example: <ServiceType>PriorityMailExpress</ServiceType>
29
+ # * *:count* (required, String) — This tag is embedded under the <Package> tag. Enter the number of packages for the accompanying <ServiceType> tag. Maximum characters allowed: 3 or 999 packages. If your pickup contains more than one Service Type, use additional <Package> tags for each service type with the accompanying <ServiceType> and <Count> tags. Refer to the XML request example section, below, to see how these embedded tags are formatted. For example: <Count>2</Count>
30
+ # * *:estimated_weight* (required, String) Enter the estimated aggregate weight (in pounds) of all packages being picked up. For example: <EstimatedWeight>14</EstimatedWeight>
31
+ # * *:package_location* (required, String) — Enter one of the following values: Note: "Other" requires information in the value for the <SpecialInstructions> tag. For example: <PackageLocation>Front Door</PackageLocation>
32
+ # * *:special_instructions* (String) Value Required when PackageLocation is “Other”. Only alpha, numeric, commas, periods, apostrophes, _, &, -, ( ), ?, #, / +, @ and space characters may be used. For example: <SpecialInstructions>Packages are behind the screen door.</SpecialInstructions>
33
+ # * *:email_address* (String) — If provided, email notifications will be sent confirming package pickup, or request changes and cancellations. Maximum characters allowed: 50. For example: <EmailAddress>cpapple@email.com</EmailAddress>
34
+ def carrier_pickup_schedule(options = {})
60
35
  throw ArgumentError.new('Required arguments :carrier_pickup_schedule_request missing') if options[:carrier_pickup_schedule_request].nil?
61
36
  throw ArgumentError.new('Required arguments :carrier_pickup_schedule_request, :first_name missing') if options[:carrier_pickup_schedule_request][:first_name].nil?
62
37
  throw ArgumentError.new('Required arguments :carrier_pickup_schedule_request, :last_name missing') if options[:carrier_pickup_schedule_request][:last_name].nil?
@@ -6,20 +6,13 @@ module Usps
6
6
  module Api
7
7
  module Endpoints
8
8
  module CityStateLookup
9
- #
10
- # CityStateLookup API
11
- #
12
9
  # City/State Lookup API
13
10
  # returns the city and state corresponding to the given ZIP Code. The CityStateLookup API processes up to five lookups per request.
14
- #
15
- # @option option [(Alias)] :CityStateLookupRequest (Required)
16
- # - API= CityStateLookupRequest
17
- # @option option [(Group)] :ZipCode (Required)
18
- # @option option [Integer] :Zip5 (Required)
19
-
20
- #
21
- # @see
22
- def city_state_lookup(options = {})
11
+ # @param [Hash] options
12
+ # @option options [required, Hash] city_state_lookup_request API= CityStateLookupRequest
13
+ # * *:zip_code* (required, Hash) —
14
+ # * *:zip5* (required, Integer)
15
+ def city_state_lookup(options = {})
23
16
  throw ArgumentError.new('Required arguments :city_state_lookup_request missing') if options[:city_state_lookup_request].nil?
24
17
  throw ArgumentError.new('Required arguments :city_state_lookup_request, :zip_code missing') if options[:city_state_lookup_request][:zip_code].nil?
25
18
  throw ArgumentError.new('Required arguments :city_state_lookup_request, :zip_code, :zip5 missing') if options[:city_state_lookup_request][:zip_code][:zip5].nil?