usps-imis-api 0.4.0.pre.2 → 0.4.1
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/.github/workflows/main.yml +9 -0
- data/Gemfile.lock +1 -1
- data/Readme.md +9 -4
- data/lib/usps/imis/api.rb +3 -1
- data/lib/usps/imis/error/api.rb +1 -1
- data/lib/usps/imis/error/response.rb +5 -1
- data/lib/usps/imis/panel/base_panel.rb +1 -1
- data/lib/usps/imis/version.rb +1 -1
- data/spec/lib/usps/imis/error/response_spec.rb +2 -3
- data/spec/lib/usps/imis/panel/education_spec.rb +40 -30
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2539e0ba94306f96b55dc0bb009875a4ef810b1ddd361dff751eabe113d1d1d7
|
4
|
+
data.tar.gz: 82f4733468b0b00d9dd7be58d2d3a5dea23ba6a082e5f3948d0def97ba787d95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77732983cdfd02ee695173f8873000f70ab98d2cb20e4ff8742119e167dc4757f6bdb278a26114823f998a7706ed5034b48600ffc9c5bf79851352e0db6fc6e6
|
7
|
+
data.tar.gz: 30a48655eb204abbaf8a4084241661bb52bc27937964984b59e13bffb8373919550f93c51f770d3d4c627a77970c1461525237adbcd3540b9d5360462bc8d02e
|
data/.github/workflows/main.yml
CHANGED
data/Gemfile.lock
CHANGED
data/Readme.md
CHANGED
@@ -13,7 +13,7 @@ gem install usps-imis-api
|
|
13
13
|
or add this line to your Gemfile:
|
14
14
|
|
15
15
|
```ruby
|
16
|
-
gem 'usps-imis-api', '>= 0.
|
16
|
+
gem 'usps-imis-api', '>= 0.4.0'
|
17
17
|
```
|
18
18
|
|
19
19
|
## Setup
|
@@ -63,7 +63,7 @@ database, you can skip this step.
|
|
63
63
|
To convert a member's certificate number into their iMIS ID, run the following method:
|
64
64
|
|
65
65
|
```ruby
|
66
|
-
api.
|
66
|
+
api.imis_id_for(certificate)
|
67
67
|
```
|
68
68
|
|
69
69
|
This will both return the ID, and store it for use with other requests. If you need to change which
|
@@ -245,9 +245,14 @@ Testing and linting are automatically run on every push.
|
|
245
245
|
|
246
246
|
## Development
|
247
247
|
|
248
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run
|
248
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run
|
249
|
+
the tests. You can also run `bin/console` for an interactive prompt that will allow you to
|
250
|
+
experiment.
|
249
251
|
|
250
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new
|
252
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new
|
253
|
+
version, update the version number in `version.rb`, and then run `bundle exec rake release`, which
|
254
|
+
will create a git tag for the version, push git commits and the created tag, and push the `.gem`
|
255
|
+
file to [rubygems.org](https://rubygems.org).
|
251
256
|
|
252
257
|
## PHP
|
253
258
|
|
data/lib/usps/imis/api.rb
CHANGED
@@ -26,6 +26,8 @@ module Usps
|
|
26
26
|
def imis_id_for(certificate)
|
27
27
|
result = query(Imis.configuration.imis_id_query_name, { certificate: certificate })
|
28
28
|
@imis_id = result['Items']['$values'][0]['ID']
|
29
|
+
rescue StandardError
|
30
|
+
raise Error::Api, 'Member not found'
|
29
31
|
end
|
30
32
|
|
31
33
|
# Run requests as DSL, with specific iMIS ID only maintained for this scope
|
@@ -149,7 +151,7 @@ module Usps
|
|
149
151
|
|
150
152
|
def submit(uri, request)
|
151
153
|
client(uri).request(request).tap do |result|
|
152
|
-
raise Error::Response.
|
154
|
+
raise Error::Response.from(result) unless result.is_a?(Net::HTTPSuccess)
|
153
155
|
end
|
154
156
|
end
|
155
157
|
|
data/lib/usps/imis/error/api.rb
CHANGED
@@ -7,7 +7,11 @@ module Usps
|
|
7
7
|
attr_reader :response
|
8
8
|
attr_accessor :metadata
|
9
9
|
|
10
|
-
def
|
10
|
+
def self.from(response)
|
11
|
+
new(nil, response)
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(_message, response, metadata = {})
|
11
15
|
@response = response
|
12
16
|
super(message, metadata)
|
13
17
|
end
|
data/lib/usps/imis/version.rb
CHANGED
@@ -5,6 +5,7 @@ require 'spec_helper'
|
|
5
5
|
ApiResponseStub = Struct.new(:code, :body)
|
6
6
|
|
7
7
|
describe Usps::Imis::Error::Response do
|
8
|
+
let(:response) { ApiResponseStub.new('500', 'Body of the API response error') }
|
8
9
|
let(:warning_text) do
|
9
10
|
<<~WARNING.chomp
|
10
11
|
Usps::Imis::Error::Response: [INTERNAL_SERVER_ERROR] The iMIS API returned an error.
|
@@ -13,8 +14,6 @@ describe Usps::Imis::Error::Response do
|
|
13
14
|
end
|
14
15
|
|
15
16
|
it 'handles an API response correctly' do
|
16
|
-
|
17
|
-
|
18
|
-
expect(described_class.new(response).message).to eq(warning_text)
|
17
|
+
expect(described_class.from(response).message).to eq(warning_text)
|
19
18
|
end
|
20
19
|
end
|
@@ -3,43 +3,53 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Usps::Imis::Panel::Education do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
6
|
+
describe 'api example' do
|
7
|
+
let(:education) { described_class.new }
|
8
|
+
|
9
|
+
let(:details) do
|
10
|
+
{
|
11
|
+
certificate: 'E136924',
|
12
|
+
description: 'Marine Navigation',
|
13
|
+
effective_date: Time.now.strftime('%Y-%m-%dT00:00:00'),
|
14
|
+
source: 'Online Exams System',
|
15
|
+
code: 'MN',
|
16
|
+
type_code: 'CRS'
|
17
|
+
|
18
|
+
}
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
+
before { education.api.imis_id = 6374 }
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
describe '#get' do
|
24
|
+
it 'loads a specific object' do
|
25
|
+
expect(education.get(90737)).to be_a(Hash)
|
26
|
+
end
|
25
27
|
end
|
26
|
-
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
# rubocop:disable RSpec/ExampleLength
|
30
|
+
it 'handles new records correctly', :aggregate_failures do
|
31
|
+
new_record = education.create(details)
|
32
|
+
expect(new_record).to be_a(Hash)
|
33
|
+
|
34
|
+
ordinal = new_record['Identity']['IdentityElements']['$values'][1]
|
32
35
|
|
33
|
-
|
36
|
+
update_result =
|
37
|
+
education.update(details.merge(source: 'Online Exams System - Modified', ordinal: ordinal))
|
38
|
+
updated = update_result['Properties']['$values'].find do |v|
|
39
|
+
v['Name'] == 'ABC_Educ_Source_System'
|
40
|
+
end
|
41
|
+
expect(updated['Value']).to eq('Online Exams System - Modified')
|
34
42
|
|
35
|
-
|
36
|
-
education.update(details.merge(source: 'Online Exams System - Modified', ordinal: ordinal))
|
37
|
-
updated = update_result['Properties']['$values'].find do |v|
|
38
|
-
v['Name'] == 'ABC_Educ_Source_System'
|
43
|
+
expect(education.destroy(ordinal)).to eq('')
|
39
44
|
end
|
40
|
-
|
45
|
+
# rubocop:enable RSpec/ExampleLength
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'initialization with ID' do
|
49
|
+
it 'can initialize with an iMIS ID' do
|
50
|
+
panel = described_class.new(imis_id: 6374)
|
41
51
|
|
42
|
-
|
52
|
+
expect(panel.api.imis_id).to eq('6374')
|
53
|
+
end
|
43
54
|
end
|
44
|
-
# rubocop:enable RSpec/ExampleLength
|
45
55
|
end
|