usps-imis-api 0.9.9 → 0.9.10.pre.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/lib/usps/imis/business_object.rb +0 -3
- data/lib/usps/imis/config.rb +1 -1
- data/lib/usps/imis/query.rb +0 -3
- data/lib/usps/imis/requests.rb +4 -0
- data/lib/usps/imis/version.rb +1 -1
- metadata +1 -70
- 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 -16
- data/Gemfile.lock +0 -147
- data/Rakefile +0 -12
- data/bin/console +0 -21
- data/bin/setup +0 -8
- data/spec/fixtures/vcr_cassettes/.keep +0 -0
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_authorize/automatically_refreshes_an_expired_token.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_imis_id_for/gets_the_iMIS_ID.yml +0 -131
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_imis_id_for/with_a_query_error/wraps_errors.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_inspect/does_not_show_the_token_instance_variable.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_inspect/is_configured_to_exclude_the_token_instance_variable.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_on/chains_with_on_to_a_single_block.yml +0 -256
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_on/nests_on_and_with.yml +0 -256
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_on/returns_a_BusinessObject_without_a_block.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_on/sends_an_update_from_put.yml +0 -256
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_put/sends_an_update.yml +0 -256
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_put/when_receiving_a_response_error/wraps_the_error.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_query/collects_all_query_results.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/blocks_calling_imis_id_.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/blocks_calling_imis_id_for.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/sends_an_update_from_put.yml +0 -256
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/sends_an_update_from_update.yml +0 -256
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/uses_a_panel_correctly.yml +0 -145
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/stores_the_initial_imis_id.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/_put_field/submits_the_correct_update_request.yml +0 -627
- data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_filter_fields/formats_fields_correctly.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get/delegation_to_get_fields/delegates_to_get_fields.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get/returns_multiple_values.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get_field/returns_a_string_value.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get_field/returns_an_integer_value.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get_fields/returns_multiple_values.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_fetch/fetches_a_mapped_field.yml +0 -158
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_fetch/raises_for_unmapped_updates.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_fetch/supports_Hash_access_syntax.yml +0 -158
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_fetch/supports_Hash_access_syntax_on_the_Api_directly.yml +0 -158
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_update/raises_for_unmapped_updates.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_update/sends_a_mapped_update.yml +0 -256
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/initialize_with_imis_id/stores_the_initial_imis_id.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_BasePanel/requires_business_object_to_be_defined.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_BasePanel/requires_payload_data_to_be_defined.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/_get/loads_a_specific_object.yml +0 -146
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/_get/returns_specific_fields.yml +0 -146
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/_get_field/returns_a_specific_field.yml +0 -146
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/_get_fields/returns_specific_fields.yml +0 -146
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/interacts_with_records_correctly.yml +0 -495
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/initialization_with_ID/can_initialize_with_an_iMIS_ID.yml +0 -67
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Vsc/_get/loads_a_specific_object.yml +0 -145
- data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Vsc/handles_new_records_correctly.yml +0 -319
- data/spec/lib/usps/imis/api_spec.rb +0 -161
- 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 -75
- 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 -78
- data/usps-imis-api.gemspec +0 -20
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
describe Usps::Imis::Panels::Education, :vcr 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, :vcr 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,78 +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
|
-
require 'vcr'
|
|
15
|
-
require 'webmock/rspec'
|
|
16
|
-
WebMock.disable_net_connect!
|
|
17
|
-
record_mode = ENV['VCR'] ? ENV['VCR'].to_sym : :once
|
|
18
|
-
VCR.configure do |config|
|
|
19
|
-
config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
|
|
20
|
-
config.hook_into :webmock
|
|
21
|
-
config.default_cassette_options = {
|
|
22
|
-
record: record_mode,
|
|
23
|
-
match_requests_on: %i[method uri]
|
|
24
|
-
}
|
|
25
|
-
config.configure_rspec_metadata!
|
|
26
|
-
|
|
27
|
-
config.filter_sensitive_data('<USERNAME>') { ENV.fetch('IMIS_USERNAME') }
|
|
28
|
-
config.filter_sensitive_data('<USERNAME>') { CGI.escape(ENV.fetch('IMIS_USERNAME')) }
|
|
29
|
-
|
|
30
|
-
config.filter_sensitive_data('<PASSWORD>') { ENV.fetch('IMIS_PASSWORD') }
|
|
31
|
-
config.filter_sensitive_data('<PASSWORD>') { CGI.escape(ENV.fetch('IMIS_PASSWORD')) }
|
|
32
|
-
|
|
33
|
-
config.filter_sensitive_data('<ACCESS_TOKEN>') do |interaction|
|
|
34
|
-
if interaction.response.headers['Content-Type']&.first&.include?('application/json')
|
|
35
|
-
begin
|
|
36
|
-
response_body = JSON.parse(interaction.response.body)
|
|
37
|
-
response_body['access_token']
|
|
38
|
-
rescue JSON::ParserError
|
|
39
|
-
nil
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
config.filter_sensitive_data('<BEARER_TOKEN>') do |interaction|
|
|
45
|
-
if interaction.request.headers['Authorization']
|
|
46
|
-
auth_header = interaction.request.headers['Authorization'].first
|
|
47
|
-
if (match = auth_header.match(/^Bearer\s+([^,\s]+)/))
|
|
48
|
-
match.captures.first
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
RSpec.configure do |config|
|
|
55
|
-
# Enable flags like --only-failures and --next-failure
|
|
56
|
-
config.example_status_persistence_file_path = 'tmp/.rspec_status'
|
|
57
|
-
|
|
58
|
-
# Disable RSpec exposing methods globally on `Module` and `main`
|
|
59
|
-
config.disable_monkey_patching!
|
|
60
|
-
|
|
61
|
-
config.expose_dsl_globally = true
|
|
62
|
-
|
|
63
|
-
config.expect_with :rspec do |c|
|
|
64
|
-
c.syntax = :expect
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
config.before(:suite) do
|
|
68
|
-
Usps::Imis.configure do |imis_config|
|
|
69
|
-
imis_config.environment = :development
|
|
70
|
-
imis_config.imis_id_query_name = ENV.fetch('IMIS_ID_QUERY_NAME', '')
|
|
71
|
-
|
|
72
|
-
imis_config.username = ENV.fetch('IMIS_USERNAME', '')
|
|
73
|
-
imis_config.password = ENV.fetch('IMIS_PASSWORD', '')
|
|
74
|
-
|
|
75
|
-
imis_config.logger = Logger.new(nil)
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
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
|