usps-imis-api 1.0.0.pre.rc.8 → 1.0.0.pre.rc.9
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.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/Gemfile.lock +20 -2
- data/Readme.md +2 -0
- data/lib/usps/imis/api.rb +11 -12
- data/lib/usps/imis/business_object.rb +7 -8
- data/lib/usps/imis/data.rb +4 -0
- data/lib/usps/imis/error.rb +1 -1
- data/lib/usps/imis/query.rb +50 -18
- data/lib/usps/imis/requests.rb +7 -3
- data/lib/usps/imis/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/.keep +0 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_authorize/automatically_refreshes_an_expired_token.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_imis_id_for/gets_the_iMIS_ID.yml +131 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_imis_id_for/with_a_query_error/wraps_errors.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_inspect/does_not_show_the_token_instance_variable.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_inspect/is_configured_to_exclude_the_token_instance_variable.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_on/chains_with_on_to_a_single_block.yml +256 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_on/nests_on_and_with.yml +256 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_on/returns_a_BusinessObject_without_a_block.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_on/sends_an_update_from_put.yml +256 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_put/sends_an_update.yml +256 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_put/when_receiving_a_response_error/wraps_the_error.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_query/collects_all_query_results.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/blocks_calling_imis_id_.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/blocks_calling_imis_id_for.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/sends_an_update_from_put.yml +256 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/sends_an_update_from_update.yml +256 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/uses_a_panel_correctly.yml +145 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/stores_the_initial_imis_id.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/_put_field/submits_the_correct_update_request.yml +627 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_filter_fields/formats_fields_correctly.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get/delegation_to_get_fields/delegates_to_get_fields.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get/returns_multiple_values.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get_field/returns_a_string_value.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get_field/returns_an_integer_value.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get_fields/returns_multiple_values.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_fetch/fetches_a_mapped_field.yml +158 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_fetch/raises_for_unmapped_updates.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_fetch/supports_Hash_access_syntax.yml +158 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_fetch/supports_Hash_access_syntax_on_the_Api_directly.yml +158 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_update/raises_for_unmapped_updates.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_update/sends_a_mapped_update.yml +256 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/initialize_with_imis_id/stores_the_initial_imis_id.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_BasePanel/requires_business_object_to_be_defined.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_BasePanel/requires_payload_data_to_be_defined.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/_get/loads_a_specific_object.yml +146 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/_get/returns_specific_fields.yml +146 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/_get_field/returns_a_specific_field.yml +146 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/_get_fields/returns_specific_fields.yml +146 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/interacts_with_records_correctly.yml +495 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/initialization_with_ID/can_initialize_with_an_iMIS_ID.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Vsc/_get/loads_a_specific_object.yml +145 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Vsc/handles_new_records_correctly.yml +319 -0
- data/spec/lib/usps/imis/api_spec.rb +4 -14
- data/spec/lib/usps/imis/business_object_spec.rb +1 -1
- data/spec/lib/usps/imis/data_spec.rb +9 -0
- data/spec/lib/usps/imis/mapper_spec.rb +1 -1
- data/spec/lib/usps/imis/panels/base_panel_spec.rb +1 -1
- data/spec/lib/usps/imis/panels/education_spec.rb +1 -1
- data/spec/lib/usps/imis/panels/vsc_spec.rb +1 -1
- data/spec/spec_helper.rb +40 -0
- metadata +44 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f59d7505f179cc5306b35b07abb68c618229101a28a637240299dfffce94bec7
|
|
4
|
+
data.tar.gz: 6b0f55756ea84ee927b6a7115aef6fdd96934dc2b9256c0cc6b2beac9be8c849
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b83571a81496bf22fcea8886c82aeba87eb5f9a687f7eb3e033458f89bfd0ac58530e72de9cc1a97f315bf6721e1e58dfa7fd527391188ad3ef8c371fdc5dbbd
|
|
7
|
+
data.tar.gz: 232d44e8916a5fa4166a5818609595ba217fec1e61438e175161d0d39e52d16a537457b3829ff673dc0b4b7adfa1eec2c46f5056eb6eb50e8c2a6864abfbe53c
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
usps-imis-api (1.0.0.pre.rc.
|
|
4
|
+
usps-imis-api (1.0.0.pre.rc.9)
|
|
5
5
|
activesupport (~> 8.0)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -20,17 +20,24 @@ GEM
|
|
|
20
20
|
securerandom (>= 0.3)
|
|
21
21
|
tzinfo (~> 2.0, >= 2.0.5)
|
|
22
22
|
uri (>= 0.13.1)
|
|
23
|
+
addressable (2.8.7)
|
|
24
|
+
public_suffix (>= 2.0.2, < 7.0)
|
|
23
25
|
ast (2.4.3)
|
|
24
26
|
base64 (0.3.0)
|
|
25
27
|
bigdecimal (3.3.1)
|
|
28
|
+
cgi (0.5.0)
|
|
26
29
|
concurrent-ruby (1.3.5)
|
|
27
30
|
connection_pool (2.5.4)
|
|
31
|
+
crack (1.0.1)
|
|
32
|
+
bigdecimal
|
|
33
|
+
rexml
|
|
28
34
|
date (3.4.1)
|
|
29
35
|
diff-lcs (1.6.2)
|
|
30
36
|
docile (1.4.1)
|
|
31
37
|
dotenv (3.1.8)
|
|
32
38
|
drb (2.2.3)
|
|
33
39
|
erb (5.1.1)
|
|
40
|
+
hashdiff (1.2.1)
|
|
34
41
|
i18n (1.14.7)
|
|
35
42
|
concurrent-ruby (~> 1.0)
|
|
36
43
|
io-console (0.8.1)
|
|
@@ -38,7 +45,7 @@ GEM
|
|
|
38
45
|
pp (>= 0.6.0)
|
|
39
46
|
rdoc (>= 4.0.0)
|
|
40
47
|
reline (>= 0.4.2)
|
|
41
|
-
json (2.15.
|
|
48
|
+
json (2.15.2)
|
|
42
49
|
language_server-protocol (3.17.0.5)
|
|
43
50
|
lint_roller (1.1.0)
|
|
44
51
|
logger (1.7.0)
|
|
@@ -54,6 +61,7 @@ GEM
|
|
|
54
61
|
psych (5.2.6)
|
|
55
62
|
date
|
|
56
63
|
stringio
|
|
64
|
+
public_suffix (6.0.2)
|
|
57
65
|
racc (1.8.1)
|
|
58
66
|
rainbow (3.1.1)
|
|
59
67
|
rake (13.3.0)
|
|
@@ -64,6 +72,7 @@ GEM
|
|
|
64
72
|
regexp_parser (2.11.3)
|
|
65
73
|
reline (0.6.2)
|
|
66
74
|
io-console (~> 0.5)
|
|
75
|
+
rexml (3.4.4)
|
|
67
76
|
rspec (3.13.2)
|
|
68
77
|
rspec-core (~> 3.13.0)
|
|
69
78
|
rspec-expectations (~> 3.13.0)
|
|
@@ -110,12 +119,19 @@ GEM
|
|
|
110
119
|
unicode-emoji (~> 4.1)
|
|
111
120
|
unicode-emoji (4.1.0)
|
|
112
121
|
uri (1.0.4)
|
|
122
|
+
vcr (6.3.1)
|
|
123
|
+
base64
|
|
124
|
+
webmock (3.25.2)
|
|
125
|
+
addressable (>= 2.8.0)
|
|
126
|
+
crack (>= 0.3.2)
|
|
127
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
|
113
128
|
|
|
114
129
|
PLATFORMS
|
|
115
130
|
arm64-darwin-23
|
|
116
131
|
ruby
|
|
117
132
|
|
|
118
133
|
DEPENDENCIES
|
|
134
|
+
cgi (>= 0.5.0)
|
|
119
135
|
dotenv (>= 3.1.4)
|
|
120
136
|
irb (>= 1.15.2)
|
|
121
137
|
rake (>= 13.2.1)
|
|
@@ -124,6 +140,8 @@ DEPENDENCIES
|
|
|
124
140
|
rubocop-rspec (>= 3.1.0)
|
|
125
141
|
simplecov (>= 0.22.0)
|
|
126
142
|
usps-imis-api!
|
|
143
|
+
vcr (>= 6.3.1)
|
|
144
|
+
webmock (>= 3.25.2)
|
|
127
145
|
|
|
128
146
|
BUNDLED WITH
|
|
129
147
|
2.5.6
|
data/Readme.md
CHANGED
data/lib/usps/imis/api.rb
CHANGED
|
@@ -36,11 +36,10 @@ module Usps
|
|
|
36
36
|
|
|
37
37
|
# A new instance of +Api+
|
|
38
38
|
#
|
|
39
|
-
# @param skip_authentication [bool] Skip authentication on initialization (used for tests)
|
|
40
39
|
# @param imis_id [Integer, String] iMIS ID to select immediately on initialization
|
|
41
40
|
#
|
|
42
|
-
def initialize(
|
|
43
|
-
authenticate
|
|
41
|
+
def initialize(imis_id: nil)
|
|
42
|
+
authenticate
|
|
44
43
|
self.imis_id = imis_id if imis_id
|
|
45
44
|
end
|
|
46
45
|
|
|
@@ -104,9 +103,7 @@ module Usps
|
|
|
104
103
|
#
|
|
105
104
|
# @return [Hash] Response data from the API
|
|
106
105
|
#
|
|
107
|
-
def query(query_name, query_params = {})
|
|
108
|
-
Query.new(self, query_name, query_params)
|
|
109
|
-
end
|
|
106
|
+
def query(query_name, query_params = {}) = Query.new(self, query_name, **query_params)
|
|
110
107
|
|
|
111
108
|
# Run requests as DSL, with specific +BusinessObject+ only maintained for this scope
|
|
112
109
|
#
|
|
@@ -162,20 +159,22 @@ module Usps
|
|
|
162
159
|
def authenticate
|
|
163
160
|
logger.debug 'Authenticating with iMIS'
|
|
164
161
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
authentication_data = {
|
|
162
|
+
request = http_post
|
|
163
|
+
request.body = URI.encode_www_form(
|
|
168
164
|
grant_type: 'password',
|
|
169
165
|
username: Imis.configuration.username,
|
|
170
166
|
password: Imis.configuration.password
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
result = submit(uri, req)
|
|
167
|
+
)
|
|
168
|
+
result = submit(uri, request)
|
|
174
169
|
json = JSON.parse(result.body)
|
|
175
170
|
|
|
176
171
|
@token = json['access_token']
|
|
177
172
|
@token_expiration = Time.parse(json['.expires'])
|
|
178
173
|
end
|
|
174
|
+
|
|
175
|
+
# URI for the authentication endpoint
|
|
176
|
+
#
|
|
177
|
+
def uri(...) = URI(File.join(Imis.configuration.hostname, AUTHENTICATION_PATH))
|
|
179
178
|
end
|
|
180
179
|
end
|
|
181
180
|
end
|
|
@@ -93,7 +93,7 @@ module Usps
|
|
|
93
93
|
#
|
|
94
94
|
# @return [Usps::Imis::Data] Response data from the API
|
|
95
95
|
#
|
|
96
|
-
def put(body) = put_object(
|
|
96
|
+
def put(body) = put_object(http_put, body)
|
|
97
97
|
alias update put
|
|
98
98
|
|
|
99
99
|
# Create a business object for the current member
|
|
@@ -102,14 +102,14 @@ module Usps
|
|
|
102
102
|
#
|
|
103
103
|
# @return [Usps::Imis::Data] Response data from the API
|
|
104
104
|
#
|
|
105
|
-
def post(body) = put_object(
|
|
105
|
+
def post(body) = put_object(http_post, body)
|
|
106
106
|
alias create post
|
|
107
107
|
|
|
108
108
|
# Remove a business object for the current member
|
|
109
109
|
#
|
|
110
110
|
# @return [true] Only on success response (i.e. blank string from the API)
|
|
111
111
|
#
|
|
112
|
-
def delete = submit(uri, authorize(
|
|
112
|
+
def delete = submit(uri, authorize(http_delete)).body == '' # rubocop:disable Naming/PredicateMethod
|
|
113
113
|
alias destroy delete
|
|
114
114
|
|
|
115
115
|
# Ruby 3.5 instance variable filter
|
|
@@ -173,9 +173,8 @@ module Usps
|
|
|
173
173
|
# Useful for stubbing data in tests
|
|
174
174
|
#
|
|
175
175
|
def raw_object
|
|
176
|
-
|
|
177
|
-
result =
|
|
178
|
-
result = Data.from_json(result.body)
|
|
176
|
+
response = submit(uri, authorize(http_get))
|
|
177
|
+
result = Data.from_json(response.body)
|
|
179
178
|
JSON.pretty_generate(result).split("\n").each { logger.debug " -> #{it}" }
|
|
180
179
|
result
|
|
181
180
|
end
|
|
@@ -184,8 +183,8 @@ module Usps
|
|
|
184
183
|
#
|
|
185
184
|
def put_object(request, body)
|
|
186
185
|
request.body = JSON.dump(body)
|
|
187
|
-
|
|
188
|
-
result = Data.from_json(
|
|
186
|
+
response = submit(uri, authorize(request))
|
|
187
|
+
result = Data.from_json(response.body)
|
|
189
188
|
JSON.pretty_generate(result).split("\n").each { logger.debug " -> #{it}" }
|
|
190
189
|
result
|
|
191
190
|
end
|
data/lib/usps/imis/data.rb
CHANGED
|
@@ -50,6 +50,10 @@ module Usps
|
|
|
50
50
|
.index_with { self[it] }
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
+
def []=(...)
|
|
54
|
+
raise Errors::ApiError, '`Data` does not support setting values. If you need to modify it, call `.raw` on it.'
|
|
55
|
+
end
|
|
56
|
+
|
|
53
57
|
def inspect
|
|
54
58
|
stringio = StringIO.new
|
|
55
59
|
PP.pp(self, stringio)
|
data/lib/usps/imis/error.rb
CHANGED
data/lib/usps/imis/query.rb
CHANGED
|
@@ -24,20 +24,32 @@ module Usps
|
|
|
24
24
|
#
|
|
25
25
|
attr_reader :query_params
|
|
26
26
|
|
|
27
|
+
# Current page size for paging through the Query
|
|
28
|
+
#
|
|
29
|
+
attr_accessor :page_size
|
|
30
|
+
|
|
27
31
|
# Current offset for paging through the Query
|
|
28
32
|
#
|
|
29
|
-
|
|
33
|
+
attr_accessor :offset
|
|
34
|
+
|
|
35
|
+
# Count of records processed
|
|
36
|
+
#
|
|
37
|
+
attr_reader :count
|
|
30
38
|
|
|
31
39
|
# A new instance of +Query+
|
|
32
40
|
#
|
|
33
41
|
# @param api [Api] Parent to use for making requests
|
|
34
42
|
# @param query_name [String] Full path of the query in IQA, e.g. +$/_ABC/Fiander/iMIS_ID+
|
|
35
|
-
# @
|
|
43
|
+
# @param page_size [Integer] Number of records to return on each request page
|
|
44
|
+
# @param offset [Integer] Offset index of records to return on next request page
|
|
45
|
+
# @param query_params [Hash] Conforms to pattern +{ param_name => param_value }+
|
|
36
46
|
#
|
|
37
|
-
def initialize(api, query_name, query_params)
|
|
47
|
+
def initialize(api, query_name, page_size: 100, offset: nil, **query_params)
|
|
38
48
|
@api = api
|
|
39
49
|
@query_name = query_name
|
|
40
50
|
@query_params = query_params
|
|
51
|
+
@page_size = page_size
|
|
52
|
+
@offset = offset
|
|
41
53
|
end
|
|
42
54
|
|
|
43
55
|
# Iterate through all results from the query
|
|
@@ -53,26 +65,37 @@ module Usps
|
|
|
53
65
|
# Iterate through all results from the query, fetching one page at a time
|
|
54
66
|
#
|
|
55
67
|
def find_each(&)
|
|
56
|
-
result =
|
|
57
|
-
count = 0
|
|
68
|
+
result = reset!
|
|
58
69
|
|
|
59
70
|
while result['HasNext']
|
|
60
|
-
|
|
71
|
+
result = fetch_next.tap do |result_page|
|
|
72
|
+
result_page['Items']['$values'].map { it.except('$type') }.each(&)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
61
75
|
|
|
62
|
-
|
|
76
|
+
nil
|
|
77
|
+
end
|
|
63
78
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
JSON.pretty_generate(result).split("\n").each { logger.debug " -> #{it}" }
|
|
79
|
+
# Fetch a raw query page
|
|
80
|
+
#
|
|
81
|
+
def fetch = JSON.parse(submit(uri, authorize(http_get)).body)
|
|
68
82
|
|
|
69
|
-
|
|
70
|
-
|
|
83
|
+
# Fetch the next raw query page, and update the current offset
|
|
84
|
+
#
|
|
85
|
+
def fetch_next
|
|
86
|
+
logger.info 'Fetching IQA Query page'
|
|
71
87
|
|
|
72
|
-
|
|
73
|
-
end
|
|
88
|
+
result = fetch
|
|
74
89
|
|
|
75
|
-
|
|
90
|
+
@count += result['Count'] || 0
|
|
91
|
+
total = result['TotalCount']
|
|
92
|
+
logger.info " -> #{@count} / #{total} #{'item'.pluralize(total)}"
|
|
93
|
+
logger.debug ' -> Query page data:'
|
|
94
|
+
JSON.pretty_generate(result).split("\n").each { logger.debug " -> #{it}" }
|
|
95
|
+
|
|
96
|
+
@offset = result['NextOffset']
|
|
97
|
+
|
|
98
|
+
result
|
|
76
99
|
end
|
|
77
100
|
|
|
78
101
|
# Ruby 3.5 instance variable filter
|
|
@@ -84,11 +107,20 @@ module Usps
|
|
|
84
107
|
def token = api.token
|
|
85
108
|
def token_expiration = api.token_expiration
|
|
86
109
|
|
|
87
|
-
def
|
|
110
|
+
def path_params = query_params.merge(QueryName: query_name).merge({ Offset: offset, Limit: page_size }.compact)
|
|
111
|
+
def path = "#{QUERY_PATH}?#{path_params.to_query}"
|
|
88
112
|
def uri = URI(File.join(Imis.configuration.hostname, path))
|
|
89
|
-
def fetch = JSON.parse(submit(uri, authorize(Net::HTTP::Get.new(uri))).body)
|
|
90
113
|
|
|
91
114
|
def logger = Imis.logger('Query')
|
|
115
|
+
|
|
116
|
+
def reset!
|
|
117
|
+
logger.debug 'Resetting Query progress'
|
|
118
|
+
|
|
119
|
+
@count = 0
|
|
120
|
+
@offset = 0
|
|
121
|
+
|
|
122
|
+
{ 'HasNext' => true }
|
|
123
|
+
end
|
|
92
124
|
end
|
|
93
125
|
end
|
|
94
126
|
end
|
data/lib/usps/imis/requests.rb
CHANGED
|
@@ -9,6 +9,11 @@ module Usps
|
|
|
9
9
|
|
|
10
10
|
def logger = Imis.logger
|
|
11
11
|
|
|
12
|
+
def http_get = Net::HTTP::Get.new(uri)
|
|
13
|
+
def http_put = Net::HTTP::Put.new(uri)
|
|
14
|
+
def http_post = Net::HTTP::Post.new(uri(id: ''))
|
|
15
|
+
def http_delete = Net::HTTP::Delete.new(uri)
|
|
16
|
+
|
|
12
17
|
def client(uri)
|
|
13
18
|
Net::HTTP.new(uri.host, uri.port).tap do |http|
|
|
14
19
|
http.use_ssl = true
|
|
@@ -45,9 +50,8 @@ module Usps
|
|
|
45
50
|
body = request.body.dup
|
|
46
51
|
|
|
47
52
|
Imis.config.filtered_parameters.each do |parameter|
|
|
48
|
-
body
|
|
49
|
-
|
|
50
|
-
.gsub(CGI.escape(Imis.config.public_send(parameter)), '[FILTERED]')
|
|
53
|
+
body.gsub!(Imis.config.public_send(parameter), '[FILTERED]')
|
|
54
|
+
body.gsub!(CGI.escape(Imis.config.public_send(parameter)), '[FILTERED]')
|
|
51
55
|
end
|
|
52
56
|
|
|
53
57
|
body
|
data/lib/usps/imis/version.rb
CHANGED
|
File without changes
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: post
|
|
5
|
+
uri: https://abcdev.imiscloud.com/Token
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: grant_type=password&username=<USERNAME>&password=<PASSWORD>
|
|
9
|
+
headers:
|
|
10
|
+
Accept-Encoding:
|
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
12
|
+
Accept:
|
|
13
|
+
- "*/*"
|
|
14
|
+
User-Agent:
|
|
15
|
+
- Ruby
|
|
16
|
+
Host:
|
|
17
|
+
- abcdev.imiscloud.com
|
|
18
|
+
response:
|
|
19
|
+
status:
|
|
20
|
+
code: 200
|
|
21
|
+
message: OK
|
|
22
|
+
headers:
|
|
23
|
+
Date:
|
|
24
|
+
- Sun, 26 Oct 2025 01:24:38 GMT
|
|
25
|
+
Content-Type:
|
|
26
|
+
- application/json; charset=UTF-8
|
|
27
|
+
Transfer-Encoding:
|
|
28
|
+
- chunked
|
|
29
|
+
Connection:
|
|
30
|
+
- keep-alive
|
|
31
|
+
Server:
|
|
32
|
+
- cloudflare
|
|
33
|
+
Cf-Ray:
|
|
34
|
+
- 994627bdc9e8e822-ORD
|
|
35
|
+
Cf-Cache-Status:
|
|
36
|
+
- DYNAMIC
|
|
37
|
+
Access-Control-Allow-Origin:
|
|
38
|
+
- "*"
|
|
39
|
+
Cache-Control:
|
|
40
|
+
- no-cache
|
|
41
|
+
Expires:
|
|
42
|
+
- "-1"
|
|
43
|
+
Strict-Transport-Security:
|
|
44
|
+
- max-age=31536000
|
|
45
|
+
Vary:
|
|
46
|
+
- Accept-Encoding,Accept-Encoding
|
|
47
|
+
Pragma:
|
|
48
|
+
- no-cache
|
|
49
|
+
Access-Control-Expose-Headers:
|
|
50
|
+
- Request-Context
|
|
51
|
+
Request-Context:
|
|
52
|
+
- appId=cid-v1:9c05b5dd-9acf-4a59-aabb-1775785c005f
|
|
53
|
+
X-Aspnet-Version:
|
|
54
|
+
- 4.0.30319
|
|
55
|
+
X-Content-Type-Options:
|
|
56
|
+
- nosniff
|
|
57
|
+
- nosniff
|
|
58
|
+
Set-Cookie:
|
|
59
|
+
- __cf_bm=WthwCIYBGJjeQcPIuJteHBCsffR9_YnIswA1GxBsAY0-1761441878-1.0.1.1-PDKN99A_uKww6R0a3o7xNsGHGxn2nOOhCXcaMzV_6LgrHJ1GEYNmKklmEtAghMWUP4IGpM9INbgu7tFJP1_AlEsAbYw0VOZD80N9_B0VvwU;
|
|
60
|
+
path=/; expires=Sun, 26-Oct-25 01:54:38 GMT; domain=.abcdev.imiscloud.com;
|
|
61
|
+
HttpOnly; Secure; SameSite=None
|
|
62
|
+
body:
|
|
63
|
+
encoding: ASCII-8BIT
|
|
64
|
+
string: '{"access_token":"<ACCESS_TOKEN>","token_type":"bearer","expires_in":3599,"userName":"J.S.FIANDER@GMAIL.COM",".issued":"Sun,
|
|
65
|
+
26 Oct 2025 01:24:38 GMT",".expires":"Sun, 26 Oct 2025 02:24:38 GMT"}'
|
|
66
|
+
recorded_at: Sun, 26 Oct 2025 01:24:38 GMT
|
|
67
|
+
recorded_with: VCR 6.3.1
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: post
|
|
5
|
+
uri: https://abcdev.imiscloud.com/Token
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: grant_type=password&username=<USERNAME>&password=<PASSWORD>
|
|
9
|
+
headers:
|
|
10
|
+
Accept-Encoding:
|
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
12
|
+
Accept:
|
|
13
|
+
- "*/*"
|
|
14
|
+
User-Agent:
|
|
15
|
+
- Ruby
|
|
16
|
+
Host:
|
|
17
|
+
- abcdev.imiscloud.com
|
|
18
|
+
response:
|
|
19
|
+
status:
|
|
20
|
+
code: 200
|
|
21
|
+
message: OK
|
|
22
|
+
headers:
|
|
23
|
+
Date:
|
|
24
|
+
- Sun, 26 Oct 2025 01:24:32 GMT
|
|
25
|
+
Content-Type:
|
|
26
|
+
- application/json; charset=UTF-8
|
|
27
|
+
Transfer-Encoding:
|
|
28
|
+
- chunked
|
|
29
|
+
Connection:
|
|
30
|
+
- keep-alive
|
|
31
|
+
Server:
|
|
32
|
+
- cloudflare
|
|
33
|
+
Cf-Ray:
|
|
34
|
+
- 99462796b97b00fc-ORD
|
|
35
|
+
Cf-Cache-Status:
|
|
36
|
+
- DYNAMIC
|
|
37
|
+
Access-Control-Allow-Origin:
|
|
38
|
+
- "*"
|
|
39
|
+
Cache-Control:
|
|
40
|
+
- no-cache
|
|
41
|
+
Expires:
|
|
42
|
+
- "-1"
|
|
43
|
+
Strict-Transport-Security:
|
|
44
|
+
- max-age=31536000
|
|
45
|
+
Vary:
|
|
46
|
+
- Accept-Encoding,Accept-Encoding
|
|
47
|
+
Pragma:
|
|
48
|
+
- no-cache
|
|
49
|
+
Access-Control-Expose-Headers:
|
|
50
|
+
- Request-Context
|
|
51
|
+
Request-Context:
|
|
52
|
+
- appId=cid-v1:9c05b5dd-9acf-4a59-aabb-1775785c005f
|
|
53
|
+
X-Aspnet-Version:
|
|
54
|
+
- 4.0.30319
|
|
55
|
+
X-Content-Type-Options:
|
|
56
|
+
- nosniff
|
|
57
|
+
- nosniff
|
|
58
|
+
Set-Cookie:
|
|
59
|
+
- __cf_bm=PFJSyqKZeeekZMVQi3_s.iWPPx98MiiU48F5mHgL_cA-1761441872-1.0.1.1-lG7LkZAxwmWx1SpWgmSJy5lupkqhwnGuKgxY2FAeRyhTE5zMcGBa6Rl41WLIQV_mk94PLKmZDxdlrE6TPxlgUvTBWAUfZ7OmauL8RYQcIgc;
|
|
60
|
+
path=/; expires=Sun, 26-Oct-25 01:54:32 GMT; domain=.abcdev.imiscloud.com;
|
|
61
|
+
HttpOnly; Secure; SameSite=None
|
|
62
|
+
body:
|
|
63
|
+
encoding: ASCII-8BIT
|
|
64
|
+
string: '{"access_token":"<ACCESS_TOKEN>","token_type":"bearer","expires_in":3599,"userName":"J.S.FIANDER@GMAIL.COM",".issued":"Sun,
|
|
65
|
+
26 Oct 2025 01:24:32 GMT",".expires":"Sun, 26 Oct 2025 02:24:32 GMT"}'
|
|
66
|
+
recorded_at: Sun, 26 Oct 2025 01:24:32 GMT
|
|
67
|
+
- request:
|
|
68
|
+
method: get
|
|
69
|
+
uri: https://abcdev.imiscloud.com/api/Query?Limit=100&Offset=0&QueryName=$/_ABC/Fiander/iMIS_ID&certificate=E231625
|
|
70
|
+
body:
|
|
71
|
+
encoding: US-ASCII
|
|
72
|
+
string: ''
|
|
73
|
+
headers:
|
|
74
|
+
Accept-Encoding:
|
|
75
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
76
|
+
Accept:
|
|
77
|
+
- "*/*"
|
|
78
|
+
User-Agent:
|
|
79
|
+
- Ruby
|
|
80
|
+
Host:
|
|
81
|
+
- abcdev.imiscloud.com
|
|
82
|
+
Authorization:
|
|
83
|
+
- Bearer <BEARER_TOKEN>
|
|
84
|
+
response:
|
|
85
|
+
status:
|
|
86
|
+
code: 200
|
|
87
|
+
message: OK
|
|
88
|
+
headers:
|
|
89
|
+
Date:
|
|
90
|
+
- Sun, 26 Oct 2025 01:24:32 GMT
|
|
91
|
+
Content-Type:
|
|
92
|
+
- application/json; charset=utf-8
|
|
93
|
+
Transfer-Encoding:
|
|
94
|
+
- chunked
|
|
95
|
+
Connection:
|
|
96
|
+
- keep-alive
|
|
97
|
+
Server:
|
|
98
|
+
- cloudflare
|
|
99
|
+
Cf-Ray:
|
|
100
|
+
- 99462797dac6d2e5-ORD
|
|
101
|
+
Cf-Cache-Status:
|
|
102
|
+
- DYNAMIC
|
|
103
|
+
Cache-Control:
|
|
104
|
+
- no-cache
|
|
105
|
+
Expires:
|
|
106
|
+
- "-1"
|
|
107
|
+
Strict-Transport-Security:
|
|
108
|
+
- max-age=31536000
|
|
109
|
+
Vary:
|
|
110
|
+
- Accept-Encoding,Accept-Encoding
|
|
111
|
+
Pragma:
|
|
112
|
+
- no-cache
|
|
113
|
+
Access-Control-Expose-Headers:
|
|
114
|
+
- Request-Context
|
|
115
|
+
Request-Context:
|
|
116
|
+
- appId=cid-v1:9c05b5dd-9acf-4a59-aabb-1775785c005f
|
|
117
|
+
X-Aspnet-Version:
|
|
118
|
+
- 4.0.30319
|
|
119
|
+
X-Content-Type-Options:
|
|
120
|
+
- nosniff
|
|
121
|
+
- nosniff
|
|
122
|
+
Set-Cookie:
|
|
123
|
+
- __cf_bm=Ge2XMO5ZlsiOnRgnWt_gL9whZaqg0mc0RZ90EdjZf_k-1761441872-1.0.1.1-hIQzTGP2EgqJQDYdiO6cUlVh6o2sOLP1PdTE5PnUZpl7C3M45t5_M0luZVBwOzzfGho_LiQsM4MCLBa48xaeMd0CImLqCqM2QiKj1Q7nPlw;
|
|
124
|
+
path=/; expires=Sun, 26-Oct-25 01:54:32 GMT; domain=.abcdev.imiscloud.com;
|
|
125
|
+
HttpOnly; Secure; SameSite=None
|
|
126
|
+
body:
|
|
127
|
+
encoding: ASCII-8BIT
|
|
128
|
+
string: '{"$type":"Asi.Soa.Core.DataContracts.PagedResult, Asi.Contracts","Items":{"$type":"System.Collections.Generic.List`1[[System.Object,
|
|
129
|
+
mscorlib]], mscorlib","$values":[{"$type":"System.Dynamic.ExpandoObject, System.Core","ID":"31092","MMS_Updated":"2024-12-31T00:00:00","TotMMS":15}]},"Offset":0,"Limit":100,"Count":1,"TotalCount":1,"NextPageLink":null,"HasNext":false,"NextOffset":0}'
|
|
130
|
+
recorded_at: Sun, 26 Oct 2025 01:24:32 GMT
|
|
131
|
+
recorded_with: VCR 6.3.1
|
data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_imis_id_for/with_a_query_error/wraps_errors.yml
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: post
|
|
5
|
+
uri: https://abcdev.imiscloud.com/Token
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: grant_type=password&username=<USERNAME>&password=<PASSWORD>
|
|
9
|
+
headers:
|
|
10
|
+
Accept-Encoding:
|
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
12
|
+
Accept:
|
|
13
|
+
- "*/*"
|
|
14
|
+
User-Agent:
|
|
15
|
+
- Ruby
|
|
16
|
+
Host:
|
|
17
|
+
- abcdev.imiscloud.com
|
|
18
|
+
response:
|
|
19
|
+
status:
|
|
20
|
+
code: 200
|
|
21
|
+
message: OK
|
|
22
|
+
headers:
|
|
23
|
+
Date:
|
|
24
|
+
- Sun, 26 Oct 2025 01:24:32 GMT
|
|
25
|
+
Content-Type:
|
|
26
|
+
- application/json; charset=UTF-8
|
|
27
|
+
Transfer-Encoding:
|
|
28
|
+
- chunked
|
|
29
|
+
Connection:
|
|
30
|
+
- keep-alive
|
|
31
|
+
Server:
|
|
32
|
+
- cloudflare
|
|
33
|
+
Cf-Ray:
|
|
34
|
+
- 99462798f8971135-ORD
|
|
35
|
+
Cf-Cache-Status:
|
|
36
|
+
- DYNAMIC
|
|
37
|
+
Access-Control-Allow-Origin:
|
|
38
|
+
- "*"
|
|
39
|
+
Cache-Control:
|
|
40
|
+
- no-cache
|
|
41
|
+
Expires:
|
|
42
|
+
- "-1"
|
|
43
|
+
Strict-Transport-Security:
|
|
44
|
+
- max-age=31536000
|
|
45
|
+
Vary:
|
|
46
|
+
- Accept-Encoding,Accept-Encoding
|
|
47
|
+
Pragma:
|
|
48
|
+
- no-cache
|
|
49
|
+
Access-Control-Expose-Headers:
|
|
50
|
+
- Request-Context
|
|
51
|
+
Request-Context:
|
|
52
|
+
- appId=cid-v1:9c05b5dd-9acf-4a59-aabb-1775785c005f
|
|
53
|
+
X-Aspnet-Version:
|
|
54
|
+
- 4.0.30319
|
|
55
|
+
X-Content-Type-Options:
|
|
56
|
+
- nosniff
|
|
57
|
+
- nosniff
|
|
58
|
+
Set-Cookie:
|
|
59
|
+
- __cf_bm=n_zLuJcRTY6a4i2eb0ghrXcBn0COYYGPhfc8s5Lc38s-1761441872-1.0.1.1-0YSgS_5uGYSjdQqojtxqxSostgKD2LRiGIwrsyxH0Sb90VtA1TCSImeZ7_2fFVQ24d9ZCvsBwDXjpqAf7S2zSThM.KnjisOZ1cF6utG.Y9w;
|
|
60
|
+
path=/; expires=Sun, 26-Oct-25 01:54:32 GMT; domain=.abcdev.imiscloud.com;
|
|
61
|
+
HttpOnly; Secure; SameSite=None
|
|
62
|
+
body:
|
|
63
|
+
encoding: ASCII-8BIT
|
|
64
|
+
string: '{"access_token":"<ACCESS_TOKEN>","token_type":"bearer","expires_in":3599,"userName":"J.S.FIANDER@GMAIL.COM",".issued":"Sun,
|
|
65
|
+
26 Oct 2025 01:24:32 GMT",".expires":"Sun, 26 Oct 2025 02:24:32 GMT"}'
|
|
66
|
+
recorded_at: Sun, 26 Oct 2025 01:24:32 GMT
|
|
67
|
+
recorded_with: VCR 6.3.1
|