usps 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +84 -0
  3. data/Rakefile +6 -8
  4. data/lib/usps.rb +6 -5
  5. data/lib/usps/address.rb +1 -1
  6. data/lib/usps/configuration.rb +1 -1
  7. data/lib/usps/request.rb +2 -1
  8. data/lib/usps/request/tracking_field_lookup.rb +28 -0
  9. data/lib/usps/response.rb +1 -0
  10. data/lib/usps/response/address_standardization.rb +15 -1
  11. data/lib/usps/response/city_and_state_lookup.rb +16 -2
  12. data/lib/usps/response/tracking_field_lookup.rb +34 -0
  13. data/lib/usps/response/tracking_lookup.rb +1 -1
  14. data/lib/usps/track_detail.rb +49 -0
  15. data/lib/usps/version.rb +1 -1
  16. data/spec/address_spec.rb +14 -14
  17. data/spec/configuration_spec.rb +4 -4
  18. data/spec/data/tracking_field_lookup.xml +41 -0
  19. data/spec/data/tracking_field_lookup_2.xml +17 -0
  20. data/spec/request/address_standardization_spec.rb +13 -13
  21. data/spec/request/base_spec.rb +2 -2
  22. data/spec/request/city_and_state_lookup_spec.rb +10 -10
  23. data/spec/request/delivery_confirmation_certify_spec.rb +3 -3
  24. data/spec/request/delivery_confirmation_spec.rb +27 -27
  25. data/spec/request/tracking_field_spec.rb +20 -0
  26. data/spec/request/tracking_spec.rb +5 -5
  27. data/spec/request/zip_code_lookup_spec.rb +11 -11
  28. data/spec/response/address_standardization_spec.rb +9 -9
  29. data/spec/response/city_and_state_lookup_spec.rb +6 -6
  30. data/spec/response/delivery_confirmation_spec.rb +19 -19
  31. data/spec/response/tracking_field_lookup_spec.rb +28 -0
  32. data/spec/response/tracking_lookup_spec.rb +10 -10
  33. data/spec/track_detail_spec.rb +51 -0
  34. data/spec/usps_spec.rb +1 -1
  35. metadata +66 -90
  36. data/README.rdoc +0 -60
  37. data/lib/usps/request/signature_confirmation.rb +0 -44
  38. data/spec/request/signature_confirmation_spec.rb +0 -0
  39. data/spec/response/signature_confirmation_spec.rb +0 -0
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe USPS::TrackDetail do
4
+ it "should have the expected fields" do
5
+ track_detail = USPS::TrackDetail.new
6
+
7
+ expect(track_detail).to respond_to(
8
+ :event_time, :event_time=,
9
+ :event_date, :event_date=,
10
+ :event, :event=,
11
+ :event_city, :event_city=,
12
+ :event_state, :event_state=,
13
+ :event_zip_code, :event_zip_code=,
14
+ :event_country, :event_country=,
15
+ :firm_name, :firm_name=,
16
+ :name, :name=,
17
+ :authorized_agent, :authorized_agent=,
18
+ :date)
19
+ end
20
+
21
+ it "should be initializable with a hash" do
22
+ track_detail = USPS::TrackDetail.new(
23
+ :name => 'Chris',
24
+ :event_city => '123 Main St',
25
+ :event => 'DELIVERED'
26
+ )
27
+
28
+ expect(track_detail.name).to eq('Chris')
29
+ expect(track_detail.event_city).to eq('123 Main St')
30
+ expect(track_detail.event).to eq('DELIVERED')
31
+ end
32
+
33
+ it "should calculate a date" do
34
+ track_detail = USPS::TrackDetail.new(
35
+ :event_time => '9:24 pm',
36
+ :event_date => 'March 28, 2001',
37
+ )
38
+ expect(track_detail.date).to eq(Time.parse('2001-03-28 21:24:00 -0500'))
39
+ end
40
+
41
+ it "should handle blank dates" do
42
+ track_detail = USPS::TrackDetail.new(
43
+ :event_time => '',
44
+ :event_date => '',
45
+ )
46
+ expect(track_detail.event_time).to eq("")
47
+ expect(track_detail.event_date).to eq("")
48
+ expect(track_detail.date).to eq(nil)
49
+ end
50
+
51
+ end
@@ -3,6 +3,6 @@ require 'spec_helper'
3
3
  describe USPS do
4
4
  it "should allow setting the USPS API username" do
5
5
  USPS.username = 'melvin'
6
- USPS.username.should == 'melvin'
6
+ expect(USPS.username).to eq('melvin')
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,108 +1,96 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: usps
3
- version: !ruby/object:Gem::Version
4
- hash: 31
5
- prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 2
10
- version: 0.1.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Chris Gaffney
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2011-02-18 00:00:00 -05:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- prerelease: false
23
- type: :runtime
11
+ date: 2014-12-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
24
14
  name: builder
25
- version_requirements: &id001 !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
28
17
  - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 15
31
- segments:
32
- - 2
33
- - 1
34
- - 2
18
+ - !ruby/object:Gem::Version
35
19
  version: 2.1.2
36
- requirement: *id001
37
- - !ruby/object:Gem::Dependency
38
- prerelease: false
39
20
  type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.1.2
27
+ - !ruby/object:Gem::Dependency
40
28
  name: nokogiri
41
- version_requirements: &id002 !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
44
31
  - - ">="
45
- - !ruby/object:Gem::Version
46
- hash: 5
47
- segments:
48
- - 1
49
- - 4
50
- - 1
32
+ - !ruby/object:Gem::Version
51
33
  version: 1.4.1
52
- requirement: *id002
53
- - !ruby/object:Gem::Dependency
54
- prerelease: false
55
34
  type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.4.1
41
+ - !ruby/object:Gem::Dependency
56
42
  name: typhoeus
57
- version_requirements: &id003 !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.18
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
60
52
  - - ">="
61
- - !ruby/object:Gem::Version
62
- hash: 63
63
- segments:
64
- - 0
65
- - 1
66
- - 18
53
+ - !ruby/object:Gem::Version
67
54
  version: 0.1.18
68
- requirement: *id003
69
55
  description:
70
- email:
56
+ email:
71
57
  - gaffneyc@gmail.com
72
58
  executables: []
73
-
74
59
  extensions: []
75
-
76
60
  extra_rdoc_files: []
77
-
78
- files:
61
+ files:
62
+ - LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - lib/usps.rb
79
66
  - lib/usps/address.rb
80
67
  - lib/usps/client.rb
81
68
  - lib/usps/configuration.rb
82
69
  - lib/usps/errors.rb
70
+ - lib/usps/request.rb
83
71
  - lib/usps/request/address_standardization.rb
84
72
  - lib/usps/request/base.rb
85
73
  - lib/usps/request/city_and_state_lookup.rb
86
74
  - lib/usps/request/delivery_confirmation.rb
87
75
  - lib/usps/request/delivery_confirmation_certify.rb
88
- - lib/usps/request/signature_confirmation.rb
76
+ - lib/usps/request/tracking_field_lookup.rb
89
77
  - lib/usps/request/tracking_lookup.rb
90
78
  - lib/usps/request/zip_code_lookup.rb
91
- - lib/usps/request.rb
79
+ - lib/usps/response.rb
92
80
  - lib/usps/response/address_standardization.rb
93
81
  - lib/usps/response/base.rb
94
82
  - lib/usps/response/city_and_state_lookup.rb
95
83
  - lib/usps/response/delivery_confirmation.rb
84
+ - lib/usps/response/tracking_field_lookup.rb
96
85
  - lib/usps/response/tracking_lookup.rb
97
- - lib/usps/response.rb
86
+ - lib/usps/test.rb
98
87
  - lib/usps/test/address_verification.rb
99
88
  - lib/usps/test/city_and_state_lookup.rb
100
89
  - lib/usps/test/delivery_confirmation.rb
101
90
  - lib/usps/test/tracking_lookup.rb
102
91
  - lib/usps/test/zip_code_lookup.rb
103
- - lib/usps/test.rb
92
+ - lib/usps/track_detail.rb
104
93
  - lib/usps/version.rb
105
- - lib/usps.rb
106
94
  - spec/address_spec.rb
107
95
  - spec/configuration_spec.rb
108
96
  - spec/data/address_standardization_1.xml
@@ -111,6 +99,8 @@ files:
111
99
  - spec/data/city_and_state_lookup_2.xml
112
100
  - spec/data/delivery_confirmation_1.xml
113
101
  - spec/data/delivery_confirmation_2.xml
102
+ - spec/data/tracking_field_lookup.xml
103
+ - spec/data/tracking_field_lookup_2.xml
114
104
  - spec/data/tracking_lookup_1.xml
115
105
  - spec/data/tracking_lookup_2.xml
116
106
  - spec/request/address_standardization_spec.rb
@@ -118,54 +108,40 @@ files:
118
108
  - spec/request/city_and_state_lookup_spec.rb
119
109
  - spec/request/delivery_confirmation_certify_spec.rb
120
110
  - spec/request/delivery_confirmation_spec.rb
121
- - spec/request/signature_confirmation_spec.rb
111
+ - spec/request/tracking_field_spec.rb
122
112
  - spec/request/tracking_spec.rb
123
113
  - spec/request/zip_code_lookup_spec.rb
124
114
  - spec/response/address_standardization_spec.rb
125
115
  - spec/response/base_spec.rb
126
116
  - spec/response/city_and_state_lookup_spec.rb
127
117
  - spec/response/delivery_confirmation_spec.rb
128
- - spec/response/signature_confirmation_spec.rb
118
+ - spec/response/tracking_field_lookup_spec.rb
129
119
  - spec/response/tracking_lookup_spec.rb
130
120
  - spec/spec.opts
131
121
  - spec/spec_helper.rb
122
+ - spec/track_detail_spec.rb
132
123
  - spec/usps_spec.rb
133
- - Rakefile
134
- - LICENSE
135
- - README.rdoc
136
- has_rdoc: true
137
124
  homepage: http://github.com/gaffneyc/usps
138
125
  licenses: []
139
-
126
+ metadata: {}
140
127
  post_install_message:
141
128
  rdoc_options: []
142
-
143
- require_paths:
129
+ require_paths:
144
130
  - lib
145
- required_ruby_version: !ruby/object:Gem::Requirement
146
- none: false
147
- requirements:
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
148
133
  - - ">="
149
- - !ruby/object:Gem::Version
150
- hash: 3
151
- segments:
152
- - 0
153
- version: "0"
154
- required_rubygems_version: !ruby/object:Gem::Requirement
155
- none: false
156
- requirements:
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
157
138
  - - ">="
158
- - !ruby/object:Gem::Version
159
- hash: 3
160
- segments:
161
- - 0
162
- version: "0"
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
163
141
  requirements: []
164
-
165
142
  rubyforge_project:
166
- rubygems_version: 1.5.2
143
+ rubygems_version: 2.2.2
167
144
  signing_key:
168
- specification_version: 3
145
+ specification_version: 4
169
146
  summary: USPS Webtools API for Ruby
170
147
  test_files: []
171
-
@@ -1,60 +0,0 @@
1
- = usps
2
-
3
- Ruby API for accessing the USPS WebTools API found here: http://www.usps.com/webtools/technical.htm
4
-
5
- Usage of this library assumes you already have a USPS API account and that all priviledges have been granted.
6
-
7
- == Exposed API Calls
8
-
9
- The following USPS API calls are currently exposed through this library:
10
-
11
- <AddressValidateRequest> -- USPS::Request::AddressStandardization
12
- <CityStateLookupRequest> -- USPS::Request::CityAndStateLookup
13
- <ZipCodeLookupRequest> -- USPS::Request::ZipCodeLookup
14
- <TrackRequest> -- USPS::Request::TrackingLookup
15
-
16
- <DeliveryConfirmationV3.0Request> -- USPS::Request::DeliveryConfirmation (for production)
17
- <DeliveryConfirmCertifyV3.0Request> -- USPS::Request::DeliveryConfirmationCertify (for testing)
18
-
19
- == Usage
20
-
21
- Using the library is as simple as building a new USPS::Request::[type] object, calling #send! and using the response.
22
- For example, to send a tracking request you'd do the following:
23
-
24
- request = USPS::Request::TrackingLookup.new(tracking_number)
25
- response = request.send!
26
-
27
- response.summary
28
- response.details
29
-
30
- The library assumes that either ENV['USPS_USER'] is set, or that you set USPS.username to your USPS API username.
31
-
32
- See the individual USPS::Request classes for details on how to use them.
33
-
34
- == USPS API Certification
35
-
36
- Part of the process of setting up an account with the USPS API is to run certain tests against the USPS API.
37
- This library has all the requisite tests built in, runnable with rake:
38
-
39
- USPS_USER="[username]" rake certify
40
-
41
- or as an installed gem:
42
-
43
- USPS_USER="[username]" ruby -rubygems -e "require 'usps/test'"
44
-
45
- If any of the tests fail, you don't have access to that API and may need to work with USPS to fix it.
46
-
47
- == Note on Patches/Pull Requests
48
-
49
- * Fork the project.
50
- * Make your feature addition or bug fix.
51
- * Add tests for it. This is important so I don't break it in a
52
- future version unintentionally.
53
- * Commit, do not mess with rakefile, version, or history.
54
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
55
- * Send me a pull request. Bonus points for topic branches.
56
-
57
-
58
- == Copyright
59
-
60
- Copyright (c) 2010, 2011 Chris Gaffney. See LICENSE for details.
@@ -1,44 +0,0 @@
1
- module USPS::Request
2
- class SignatureConfirmation < Base
3
- config(
4
- :api => 'DeliveryConfirmationV3',
5
- :tag => 'DeliveryConfirmationV3.0Request',
6
- :secure => true,
7
- :response => USPS::Response::DeliveryConfirmation
8
- )
9
-
10
- attr_reader :to, :from, :weight, :service
11
-
12
- def initialize(to, from, weight, service = 'Priority')
13
- @to = to
14
- @from = from
15
- @weight = weight
16
- @service = service
17
- end
18
-
19
- def build
20
- super do |builder|
21
- builder.tag!('Option', '1')
22
- builder.tag!('ImageParameters')
23
-
24
- [
25
- [self.from, 'From'],
26
- [self.to, 'To']
27
- ].each do |address, prefix|
28
- builder.tag!("#{prefix}Name", address.name)
29
- builder.tag!("#{prefix}Firm", address.company)
30
- builder.tag!("#{prefix}Address1", address.extra_address)
31
- builder.tag!("#{prefix}Address2", address.address)
32
- builder.tag!("#{prefix}City", address.city)
33
- builder.tag!("#{prefix}State", address.state)
34
- builder.tag!("#{prefix}Zip5", address.zip5)
35
- builder.tag!("#{prefix}Zip4", address.zip4)
36
- end
37
-
38
- builder.tag!('WeightInOunces', self.weight)
39
- builder.tag!('ServiceType', self.service)
40
- builder.tag!('ImageType', 'TIF')
41
- end
42
- end
43
- end
44
- end