usps-imis-api 1.0.0.pre.rc.8 → 1.0.0.pre.rc.10
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/Readme.md +3 -323
- data/lib/usps/imis/api.rb +21 -17
- data/lib/usps/imis/business_object.rb +18 -18
- data/lib/usps/imis/config.rb +6 -2
- data/lib/usps/imis/data.rb +4 -0
- data/lib/usps/imis/error.rb +2 -1
- data/lib/usps/imis/errors/missing_id_error.rb +15 -0
- data/lib/usps/imis/panels/base_panel.rb +2 -1
- data/lib/usps/imis/properties.rb +14 -14
- data/lib/usps/imis/query.rb +78 -25
- data/lib/usps/imis/requests.rb +12 -4
- data/lib/usps/imis/version.rb +1 -1
- data/spec/support/usps/vcr/config.rb +47 -0
- data/spec/support/usps/vcr/filters.rb +89 -0
- data/spec/support/usps/vcr.rb +8 -0
- metadata +6 -27
- data/.github/workflows/main.yml +0 -57
- data/.gitignore +0 -5
- data/.rspec +0 -2
- data/.rubocop.yml +0 -89
- data/.ruby-version +0 -1
- data/.simplecov +0 -8
- data/Gemfile +0 -12
- data/Gemfile.lock +0 -129
- data/Rakefile +0 -12
- data/bin/console +0 -21
- data/bin/setup +0 -8
- data/spec/lib/usps/imis/api_spec.rb +0 -171
- data/spec/lib/usps/imis/business_object_spec.rb +0 -87
- data/spec/lib/usps/imis/config_spec.rb +0 -59
- data/spec/lib/usps/imis/data_spec.rb +0 -66
- data/spec/lib/usps/imis/error_spec.rb +0 -17
- data/spec/lib/usps/imis/errors/response_error_spec.rb +0 -107
- data/spec/lib/usps/imis/mapper_spec.rb +0 -55
- data/spec/lib/usps/imis/mocks/business_object_spec.rb +0 -65
- data/spec/lib/usps/imis/panels/base_panel_spec.rb +0 -33
- data/spec/lib/usps/imis/panels/education_spec.rb +0 -70
- data/spec/lib/usps/imis/panels/vsc_spec.rb +0 -37
- data/spec/lib/usps/imis/properties_spec.rb +0 -19
- data/spec/lib/usps/imis_spec.rb +0 -11
- data/spec/spec_helper.rb +0 -38
- data/usps-imis-api.gemspec +0 -20
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
describe Usps::Imis::Mapper do
|
|
6
|
-
let(:api) { described_class.new.api }
|
|
7
|
-
|
|
8
|
-
describe 'initialize with imis_id' do
|
|
9
|
-
it 'stores the initial imis_id' do
|
|
10
|
-
mapper = described_class.new(imis_id: 42)
|
|
11
|
-
|
|
12
|
-
expect(mapper.api.imis_id).to eq(42)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
describe '#fetch' do
|
|
17
|
-
before { api.imis_id = 31092 }
|
|
18
|
-
|
|
19
|
-
it 'fetches a mapped field' do
|
|
20
|
-
expect(api.mapper.fetch(:mm)).to be_a(Integer)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it 'supports Hash access syntax' do
|
|
24
|
-
expect(api.mapper[:mm]).to be_a(Integer)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it 'supports Hash access syntax on the Api directly' do
|
|
28
|
-
expect(api[:mm]).to be_a(Integer)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it 'raises for unmapped updates' do
|
|
32
|
-
expect { api.mapper.fetch(:another) }.to raise_error(
|
|
33
|
-
Usps::Imis::Errors::MapperError,
|
|
34
|
-
%(Mapper does not recognize field: "another".\n) \
|
|
35
|
-
'Please report what data you are attempting to work with to ITCom leadership.'
|
|
36
|
-
)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
describe '#update' do
|
|
41
|
-
before { api.imis_id = 31092 }
|
|
42
|
-
|
|
43
|
-
it 'sends a mapped update' do
|
|
44
|
-
expect(api.mapper.update(mm: 15).first).to be_a(Hash)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it 'raises for unmapped updates' do
|
|
48
|
-
expect { api.mapper.update(something: 'anything') }.to raise_error(
|
|
49
|
-
Usps::Imis::Errors::MapperError,
|
|
50
|
-
%(Mapper does not recognize field: "something".\n) \
|
|
51
|
-
'Please report what data you are attempting to work with to ITCom leadership.'
|
|
52
|
-
)
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
describe Usps::Imis::Mocks::BusinessObject do
|
|
6
|
-
let(:mock) { described_class.new(**fields) }
|
|
7
|
-
let(:fields) { { TotMMS: 2, Something: 'Another' } }
|
|
8
|
-
|
|
9
|
-
let(:data) do
|
|
10
|
-
Usps::Imis::Properties.build do |props|
|
|
11
|
-
props.add 'TotMMS', 2
|
|
12
|
-
props.add 'Something', 'Another'
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
describe 'get' do
|
|
17
|
-
it 'returns the correct data' do
|
|
18
|
-
expect(mock.get).to eq(data)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
describe 'get_field' do
|
|
23
|
-
it 'returns the correct field value' do
|
|
24
|
-
expect(mock.get_field('TotMMS')).to eq(2)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
describe 'get_fields' do
|
|
29
|
-
it 'returns the correct field values' do
|
|
30
|
-
expect(mock.get_fields('TotMMS', 'Something')).to eq([2, 'Another'])
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
describe 'put_fields' do
|
|
35
|
-
let(:combined_data) do
|
|
36
|
-
Usps::Imis::Properties.build do |props|
|
|
37
|
-
props.add 'TotMMS', 2
|
|
38
|
-
props.add 'Something', 'Another'
|
|
39
|
-
props.add 'SomethingElse', 'interesting'
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it 'returns the correct data' do
|
|
44
|
-
expect(mock.put_fields(SomethingElse: 'interesting')).to eq(combined_data)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
describe 'put' do
|
|
49
|
-
it 'returns the correct data' do
|
|
50
|
-
expect(mock.put(data)).to eq(data)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
describe 'post' do
|
|
55
|
-
it 'returns the correct data' do
|
|
56
|
-
expect(mock.post(data)).to eq(data)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
describe 'delete' do
|
|
61
|
-
it 'returns the correct data' do
|
|
62
|
-
expect(mock.delete).to eq('')
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
module Usps
|
|
6
|
-
module Imis
|
|
7
|
-
module Panels
|
|
8
|
-
class InvalidPanel < BasePanel; end
|
|
9
|
-
|
|
10
|
-
class InvalidPanelWithBusinessObject < BasePanel
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
def business_object = 'Something'
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
describe Usps::Imis::Panels::BasePanel do
|
|
20
|
-
it 'requires #business_object to be defined' do
|
|
21
|
-
expect { Usps::Imis::Panels::InvalidPanel.new.get(1) }.to raise_error(
|
|
22
|
-
Usps::Imis::Errors::PanelUnimplementedError,
|
|
23
|
-
'Usps::Imis::Panels::InvalidPanel must implement #business_object'
|
|
24
|
-
)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it 'requires #payload(data) to be defined' do
|
|
28
|
-
expect { Usps::Imis::Panels::InvalidPanelWithBusinessObject.new.create({}) }.to raise_error(
|
|
29
|
-
Usps::Imis::Errors::PanelUnimplementedError,
|
|
30
|
-
'Usps::Imis::Panels::InvalidPanelWithBusinessObject must implement #payload(data)'
|
|
31
|
-
)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
describe Usps::Imis::Panels::Education do
|
|
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
|
-
end
|
|
19
|
-
|
|
20
|
-
before { education.api.imis_id = 6374 }
|
|
21
|
-
|
|
22
|
-
describe '#get' do
|
|
23
|
-
it 'loads a specific object' do
|
|
24
|
-
expect(education.get(90737)).to be_a(Usps::Imis::Data)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it 'returns specific fields' do
|
|
28
|
-
expect(education.get(90737, 'ABC_Product_Code', 'ABC_Other_Code')).to eq(%w[CRS AP])
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
describe '#get_field' do
|
|
33
|
-
it 'returns a specific field' do
|
|
34
|
-
expect(education.get_field(90737, 'ABC_Product_Code')).to eq('CRS')
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe '#get_fields' do
|
|
39
|
-
it 'returns specific fields' do
|
|
40
|
-
expect(education.get_fields(90737, 'ABC_Product_Code', 'ABC_Other_Code')).to eq(%w[CRS AP])
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
# rubocop:disable RSpec/ExampleLength
|
|
45
|
-
it 'interacts with records correctly', :aggregate_failures do
|
|
46
|
-
new_record = education.create(details)
|
|
47
|
-
expect(new_record).to be_a(Usps::Imis::Data)
|
|
48
|
-
|
|
49
|
-
ordinal = new_record.ordinal
|
|
50
|
-
|
|
51
|
-
update_result =
|
|
52
|
-
education.update(details.merge(source: 'Online Exams System - Modified', ordinal:))
|
|
53
|
-
expect(update_result['ABC_Educ_Source_System']).to eq('Online Exams System - Modified')
|
|
54
|
-
|
|
55
|
-
put_fields_result = education.put_fields(ordinal, 'ABC_Educ_Source_System' => 'Online Exams System - Mod2')
|
|
56
|
-
expect(put_fields_result['ABC_Educ_Source_System']).to eq('Online Exams System - Mod2')
|
|
57
|
-
|
|
58
|
-
expect(education.destroy(ordinal)).to be(true)
|
|
59
|
-
end
|
|
60
|
-
# rubocop:enable RSpec/ExampleLength
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
describe 'initialization with ID' do
|
|
64
|
-
it 'can initialize with an iMIS ID' do
|
|
65
|
-
panel = described_class.new(imis_id: 6374)
|
|
66
|
-
|
|
67
|
-
expect(panel.api.imis_id).to eq(6374)
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
describe Usps::Imis::Panels::Vsc do
|
|
6
|
-
let(:vsc) { described_class.new }
|
|
7
|
-
|
|
8
|
-
let(:details) do
|
|
9
|
-
{
|
|
10
|
-
certificate: 'E136924',
|
|
11
|
-
year: 2024,
|
|
12
|
-
count: 42
|
|
13
|
-
}
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
before { vsc.api.imis_id = 6374 }
|
|
17
|
-
|
|
18
|
-
describe '#get' do
|
|
19
|
-
it 'loads a specific object' do
|
|
20
|
-
expect(vsc.get(1433)).to be_a(Usps::Imis::Data)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# rubocop:disable RSpec/ExampleLength
|
|
25
|
-
it 'handles new records correctly', :aggregate_failures do
|
|
26
|
-
new_record = vsc.create(details)
|
|
27
|
-
expect(new_record).to be_a(Usps::Imis::Data)
|
|
28
|
-
|
|
29
|
-
ordinal = new_record.ordinal
|
|
30
|
-
|
|
31
|
-
update_result = vsc.update(details.merge(count: 43, ordinal:))
|
|
32
|
-
expect(update_result['Quantity']).to eq(43)
|
|
33
|
-
|
|
34
|
-
expect(vsc.destroy(ordinal)).to be(true)
|
|
35
|
-
end
|
|
36
|
-
# rubocop:enable RSpec/ExampleLength
|
|
37
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
describe Usps::Imis::Properties do
|
|
6
|
-
let(:builder) { described_class.new }
|
|
7
|
-
|
|
8
|
-
it 'wraps boolean property values' do
|
|
9
|
-
expect(builder.send(:wrap, true)).to eq(
|
|
10
|
-
'$type' => 'System.Boolean', '$value' => true
|
|
11
|
-
)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it 'raises an error for unexpected property types' do
|
|
15
|
-
expect { builder.send(:wrap, {}) }.to raise_error(
|
|
16
|
-
Usps::Imis::Errors::UnexpectedPropertyTypeError, 'Unexpected property type: {}'
|
|
17
|
-
)
|
|
18
|
-
end
|
|
19
|
-
end
|
data/spec/lib/usps/imis_spec.rb
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
describe Usps::Imis do
|
|
6
|
-
it 'returns configuration from configure without a block' do
|
|
7
|
-
described_class.configuration.environment = 'development'
|
|
8
|
-
|
|
9
|
-
expect(described_class.configure.environment).to eq('development')
|
|
10
|
-
end
|
|
11
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'bundler/setup'
|
|
4
|
-
Bundler.setup
|
|
5
|
-
require 'simplecov'
|
|
6
|
-
SimpleCov.minimum_coverage(line: 100, branch: 100)
|
|
7
|
-
|
|
8
|
-
require 'dotenv/load'
|
|
9
|
-
require 'usps/imis'
|
|
10
|
-
require 'active_support/string_inquirer'
|
|
11
|
-
|
|
12
|
-
ENV['TESTING'] = 'true'
|
|
13
|
-
|
|
14
|
-
RSpec.configure do |config|
|
|
15
|
-
# Enable flags like --only-failures and --next-failure
|
|
16
|
-
config.example_status_persistence_file_path = 'tmp/.rspec_status'
|
|
17
|
-
|
|
18
|
-
# Disable RSpec exposing methods globally on `Module` and `main`
|
|
19
|
-
config.disable_monkey_patching!
|
|
20
|
-
|
|
21
|
-
config.expose_dsl_globally = true
|
|
22
|
-
|
|
23
|
-
config.expect_with :rspec do |c|
|
|
24
|
-
c.syntax = :expect
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
config.before(:suite) do
|
|
28
|
-
Usps::Imis.configure do |imis_config|
|
|
29
|
-
imis_config.environment = :development
|
|
30
|
-
imis_config.imis_id_query_name = ENV.fetch('IMIS_ID_QUERY_NAME', '')
|
|
31
|
-
|
|
32
|
-
imis_config.username = ENV.fetch('IMIS_USERNAME', '')
|
|
33
|
-
imis_config.password = ENV.fetch('IMIS_PASSWORD', '')
|
|
34
|
-
|
|
35
|
-
imis_config.logger = Logger.new(nil)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
data/usps-imis-api.gemspec
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative 'lib/usps/imis/version'
|
|
4
|
-
|
|
5
|
-
Gem::Specification.new do |s|
|
|
6
|
-
s.name = 'usps-imis-api'
|
|
7
|
-
s.version = Usps::Imis::VERSION
|
|
8
|
-
s.summary = 'iMIS API Wrapper'
|
|
9
|
-
s.description = 'A wrapper for the iMIS API.'
|
|
10
|
-
s.homepage = 'https://github.com/unitedstatespowersquadrons/imis-api-ruby'
|
|
11
|
-
s.authors = ['Julian Fiander']
|
|
12
|
-
s.email = 'jsfiander@gmail.com'
|
|
13
|
-
s.require_paths = %w[lib]
|
|
14
|
-
s.files = `git ls-files`.split("\n")
|
|
15
|
-
s.metadata['rubygems_mfa_required'] = 'true'
|
|
16
|
-
|
|
17
|
-
s.required_ruby_version = '>= 3.4'
|
|
18
|
-
|
|
19
|
-
s.add_dependency 'activesupport', '~> 8.0'
|
|
20
|
-
end
|