usps-imis-api 0.4.0 → 0.4.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 121b0049500e7ad8611d9a8baefc53a254f33a1d7ff98d68ea4c3f8dc8da3c8d
4
- data.tar.gz: fe0969fbf121eab99f5d371ccdd66735293f61ed0059153faec9f1b21c7af17e
3
+ metadata.gz: 99786c3ccf2dc019726db917d318e8c992a61f091aa1b474402612a73c0558d7
4
+ data.tar.gz: bffec4e5ed9662e63112c1d8e26f99137d922439eb9c3bfb07fab0dad7236e56
5
5
  SHA512:
6
- metadata.gz: 067f10874692d3ea518f9cb5302d6248d574d8200455fb4444a3849d16613d8eb81928ce390d66ec0cf5615c01db6fa0b33601240e8278299128ad8109a25982
7
- data.tar.gz: ead4f120b284879a2a7e0a0ba9dee9f2ed47f106c44b066d6d9d69dd0bd57131d060aa070486d363421fcc9d42e536d5a356104ae0e1f881b77310f83f9baac8
6
+ metadata.gz: 1d0ba175348c95c4d7bdbea774b785f6ed3c807d5e3349b805544cbc1909b8695c3809d7c56765e77d3aadfb1d2c5c20ee0054840899b48b4385de9c27d59c4a
7
+ data.tar.gz: 533532e2686386bd3411550cb68f9da9503762b80f38fea86523f33d0ad168427af5ee5c9967959e9d56259f6dfd34c25124faad813abbbda5f83877fa1160e4
@@ -1,6 +1,15 @@
1
1
  name: 'USPS iMIS API - Ruby'
2
2
  on:
3
3
  push:
4
+ paths:
5
+ - '**.rb'
6
+ - '**.yml'
7
+ - '**.json'
8
+ - 'Gemfile'
9
+ - '.simplecov'
10
+ branches:
11
+ - 'main'
12
+ - '**'
4
13
  workflow_dispatch:
5
14
 
6
15
  jobs:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- usps-imis-api (0.4.0)
4
+ usps-imis-api (0.4.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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.3.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.get_imis_id(certificate)
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 the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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 version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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
@@ -16,7 +16,7 @@ module Usps
16
16
 
17
17
  def initialize(api = nil, imis_id: nil)
18
18
  @api = api || Api.new
19
- api.imis_id = imis_id if imis_id
19
+ @api.imis_id = imis_id if imis_id
20
20
  end
21
21
 
22
22
  # Update a member's data on multiple affected business objects by arbitrary field names
@@ -8,7 +8,7 @@ module Usps
8
8
 
9
9
  def initialize(api = nil, imis_id: nil)
10
10
  @api = api || Api.new
11
- api.imis_id = imis_id if imis_id
11
+ @api.imis_id = imis_id if imis_id
12
12
  end
13
13
 
14
14
  def get(ordinal)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.4.0'
5
+ VERSION = '0.4.2'
6
6
  end
7
7
  end
@@ -3,43 +3,53 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Usps::Imis::Panel::Education do
6
- let(:education) { described_class.new }
7
-
8
- let(:details) do
9
- {
10
- certificate: 'E136924',
11
- description: 'Marine Navigation',
12
- effective_date: Time.now.strftime('%Y-%m-%dT00:00:00'),
13
- source: 'Online Exams System',
14
- code: 'MN',
15
- type_code: 'CRS'
16
-
17
- }
18
- end
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
- before { education.api.imis_id = 6374 }
21
+ before { education.api.imis_id = 6374 }
21
22
 
22
- describe '#get' do
23
- it 'loads a specific object' do
24
- expect(education.get(90737)).to be_a(Hash)
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
- # rubocop:disable RSpec/ExampleLength
29
- it 'handles new records correctly', :aggregate_failures do
30
- new_record = education.create(details)
31
- expect(new_record).to be_a(Hash)
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
- ordinal = new_record['Identity']['IdentityElements']['$values'][1]
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
- update_result =
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
- expect(updated['Value']).to eq('Online Exams System - Modified')
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
- expect(education.destroy(ordinal)).to eq('')
52
+ expect(panel.api.imis_id).to eq('6374')
53
+ end
43
54
  end
44
- # rubocop:enable RSpec/ExampleLength
45
55
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usps-imis-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander