usps-imis-api 0.6.16 → 0.7.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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -3
  3. data/Gemfile.lock +36 -30
  4. data/Readme.md +39 -15
  5. data/lib/usps/imis/api.rb +8 -7
  6. data/lib/usps/imis/business_object.rb +55 -34
  7. data/lib/usps/imis/config.rb +1 -1
  8. data/lib/usps/imis/error.rb +51 -0
  9. data/lib/usps/imis/errors/api_error.rb +11 -0
  10. data/lib/usps/imis/errors/config_error.rb +11 -0
  11. data/lib/usps/imis/errors/locked_id_error.rb +15 -0
  12. data/lib/usps/imis/errors/mapper_error.rb +29 -0
  13. data/lib/usps/imis/errors/not_found_error.rb +11 -0
  14. data/lib/usps/imis/errors/panel_unimplemented_error.rb +34 -0
  15. data/lib/usps/imis/{error → errors}/response_error.rb +4 -7
  16. data/lib/usps/imis/errors/unexpected_property_type_error.rb +31 -0
  17. data/lib/usps/imis/mapper.rb +1 -5
  18. data/lib/usps/imis/mocks/business_object.rb +37 -0
  19. data/lib/usps/imis/mocks.rb +11 -0
  20. data/lib/usps/imis/{panel → panels}/base_panel.rb +26 -22
  21. data/lib/usps/imis/{panel → panels}/education.rb +1 -1
  22. data/lib/usps/imis/{panel → panels}/vsc.rb +1 -1
  23. data/lib/usps/imis/panels.rb +25 -0
  24. data/lib/usps/imis/properties.rb +1 -1
  25. data/lib/usps/imis/requests.rb +1 -1
  26. data/lib/usps/imis/version.rb +1 -1
  27. data/lib/usps/imis.rb +5 -15
  28. data/spec/lib/usps/imis/api_spec.rb +5 -5
  29. data/spec/lib/usps/imis/business_object_spec.rb +35 -13
  30. data/spec/lib/usps/imis/config_spec.rb +1 -1
  31. data/spec/lib/usps/imis/{error/api_error_spec.rb → error_spec.rb} +1 -1
  32. data/spec/lib/usps/imis/{error → errors}/response_error_spec.rb +4 -4
  33. data/spec/lib/usps/imis/mapper_spec.rb +2 -2
  34. data/spec/lib/usps/imis/{business_object_mock_spec.rb → mocks/business_object_spec.rb} +1 -1
  35. data/spec/lib/usps/imis/panels/base_panel_spec.rb +33 -0
  36. data/spec/lib/usps/imis/{panel → panels}/education_spec.rb +12 -2
  37. data/spec/lib/usps/imis/{panel → panels}/vsc_spec.rb +2 -2
  38. data/spec/lib/usps/imis/properties_spec.rb +1 -1
  39. data/usps-imis-api.gemspec +1 -1
  40. metadata +23 -16
  41. data/lib/ext/hash.rb +0 -10
  42. data/lib/usps/imis/business_object_mock.rb +0 -35
  43. data/lib/usps/imis/error/api_error.rb +0 -44
  44. data/lib/usps/imis/error/mapper_error.rb +0 -11
  45. data/spec/lib/usps/imis/panel/base_panel_spec.rb +0 -32
@@ -2,10 +2,10 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- module Error
5
+ module Errors
6
6
  # Exception raised due to receiving an error response from the API
7
7
  #
8
- class ResponseError < ApiError
8
+ class ResponseError < Error
9
9
  # [Net::HTTPResponse] The response received from the API
10
10
  #
11
11
  attr_reader :response
@@ -18,17 +18,14 @@ module Usps
18
18
  #
19
19
  # @param response [Net::HTTPResponse] The response received from the API
20
20
  #
21
- def self.from(response)
22
- new(nil, response)
23
- end
21
+ def self.from(response) = new(response)
24
22
 
25
23
  # Create a new instance of +ResponseError+
26
24
  #
27
- # @param _message Ignored
28
25
  # @param response [Net::HTTPResponse] The response received from the API
29
26
  # @param metadata [Hash] Additional call-specific metadata to pass through to Bugsnag
30
27
  #
31
- def initialize(_message, response, metadata = {})
28
+ def initialize(response, metadata = {})
32
29
  @response = response
33
30
  super(message, metadata)
34
31
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Usps
4
+ module Imis
5
+ module Errors
6
+ # Exception raised when attempting to wrap an unexpected property type
7
+ #
8
+ class UnexpectedPropertyTypeError < Error
9
+ # Create a new instance of +UnexpectedPropertyTypeError+ from an unexpected value
10
+ #
11
+ # @param value Unexpected value
12
+ #
13
+ def self.from(value) = new(value)
14
+
15
+ # Create a new instance of +UnexpectedPropertyTypeError+
16
+ #
17
+ # @param value Unexpected value
18
+ # @param metadata [Hash] Additional call-specific metadata to pass through to Bugsnag
19
+ #
20
+ def initialize(value, metadata = {})
21
+ @value = value
22
+ super(message, metadata)
23
+ end
24
+
25
+ # Exception message including the undefined method
26
+ #
27
+ def message = "Unexpected property type: #{@value.inspect}"
28
+ end
29
+ end
30
+ end
31
+ end
@@ -73,11 +73,7 @@ module Usps
73
73
  # :nocov:
74
74
  end
75
75
 
76
- raise(
77
- Error::MapperError,
78
- "Unrecognized field: \"#{field_name}\". " \
79
- 'Please report what data you are attempting to work with to ITCom leadership.'
80
- )
76
+ raise Errors::MapperError.new({ field_name: })
81
77
  end
82
78
  end
83
79
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Usps
4
+ module Imis
5
+ module Mocks
6
+ # Mock data response for testing
7
+ #
8
+ class BusinessObject
9
+ attr_reader :fields
10
+
11
+ def initialize(**fields)
12
+ @fields = fields.transform_keys(&:to_s)
13
+ end
14
+
15
+ def get_field(name) = fields[name]
16
+
17
+ def get
18
+ Usps::Imis::Properties.build do |props|
19
+ fields.each { |name, value| props.add(name, value) }
20
+ end
21
+ end
22
+
23
+ def put_fields(data)
24
+ Usps::Imis::Properties.build do |props|
25
+ fields.merge(data.transform_keys(&:to_s)).each { |name, value| props.add(name, value) }
26
+ end
27
+ end
28
+
29
+ def put(data) = data
30
+
31
+ def post(data) = data
32
+
33
+ def delete = ''
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'mocks/business_object'
4
+
5
+ module Usps
6
+ module Imis
7
+ # Namespace for all Mocks
8
+ #
9
+ module Mocks; end
10
+ end
11
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- module Panel
5
+ module Panels
6
6
  # Base class for configuring Panels
7
7
  #
8
8
  class BasePanel
@@ -17,25 +17,37 @@ module Usps
17
17
 
18
18
  # Get a specific object from the Panel
19
19
  #
20
+ # If +fields+ is provided, will return only those field values
21
+ #
22
+ # @param fields [String] Field names to return
23
+ #
20
24
  # @param ordinal [Integer] The ordinal identifier for the desired object
21
25
  #
22
- def get(ordinal)
23
- api.on(business_object, ordinal:).get
24
- end
26
+ # @return [Hash, Array<Hash>] Response data from the API
27
+ #
28
+ def get(ordinal, *fields) = api.on(business_object, ordinal:).get(*fields)
25
29
  alias read get
26
30
 
27
31
  # Get a single named field from a Panel for the current member
28
32
  #
29
33
  # @param ordinal [Integer] The ordinal identifier for the desired object
30
- # @param name [String] Field name to return
34
+ # @param field [String] Field name to return
31
35
  #
32
36
  # @return [Hash] Response data from the API
33
37
  #
34
- def get_field(ordinal, name)
35
- api.on(business_object, ordinal:).get_field(name)
36
- end
38
+ def get_field(ordinal, field) = api.on(business_object, ordinal:).get_field(field)
37
39
  alias fetch get_field
38
40
 
41
+ # Get named fields from a Panel for the current member
42
+ #
43
+ # @param ordinal [Integer] The ordinal identifier for the desired object
44
+ # @param fields [Array<String>] Field names to return
45
+ #
46
+ # @return [Hash] Response data from the API
47
+ #
48
+ def get_fields(ordinal, *fields) = api.on(business_object, ordinal:).get_fields(*fields)
49
+ alias fetch_all get_fields
50
+
39
51
  # Update only specific fields on a Panel for the current member
40
52
  #
41
53
  # @param ordinal [Integer] The ordinal identifier for the desired object
@@ -43,9 +55,7 @@ module Usps
43
55
  #
44
56
  # @return [Hash] Response data from the API
45
57
  #
46
- def put_fields(ordinal, fields)
47
- api.on(business_object, ordinal:).put_fields(fields)
48
- end
58
+ def put_fields(ordinal, fields) = api.on(business_object, ordinal:).put_fields(fields)
49
59
  alias patch put_fields
50
60
 
51
61
  # Update an existing object in the Panel
@@ -53,37 +63,31 @@ module Usps
53
63
  # @param data [Hash] The record data for the desired object -- including the required
54
64
  # +ordinal+ identifier
55
65
  #
56
- def put(data)
57
- api.on(business_object, ordinal: data[:ordinal]).put(payload(data))
58
- end
66
+ def put(data) = api.on(business_object, ordinal: data[:ordinal]).put(payload(data))
59
67
  alias update put
60
68
 
61
69
  # Create a new object in the Panel
62
70
  #
63
71
  # @param data [Hash] The record data for the desired object
64
72
  #
65
- def post(data)
66
- api.on(business_object).post(payload(data))
67
- end
73
+ def post(data) = api.on(business_object).post(payload(data))
68
74
  alias create post
69
75
 
70
76
  # Remove a specific object from the Panel
71
77
  #
72
78
  # @param ordinal [Integer] The ordinal identifier for the desired object
73
79
  #
74
- def delete(ordinal)
75
- api.on(business_object, ordinal:).delete
76
- end
80
+ def delete(ordinal) = api.on(business_object, ordinal:).delete
77
81
  alias destroy delete
78
82
 
79
83
  private
80
84
 
81
85
  def business_object
82
- raise Error::ApiError, "#{self.class.name} must implement #business_object"
86
+ raise Errors::PanelUnimplementedError.from(self.class.name, 'business_object')
83
87
  end
84
88
 
85
89
  def payload(_data)
86
- raise Error::ApiError, "#{self.class.name} must implement #payload(data)"
90
+ raise Errors::PanelUnimplementedError.from(self.class.name, 'payload(data)')
87
91
  end
88
92
 
89
93
  def payload_header(data)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- module Panel
5
+ module Panels
6
6
  # Panel for accessing the Educational completions business object
7
7
  #
8
8
  class Education < BasePanel
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- module Panel
5
+ module Panels
6
6
  # Panel for accessing the annual VSC completed counts business object
7
7
  #
8
8
  class Vsc < BasePanel
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'panels/base_panel'
4
+ require_relative 'panels/vsc'
5
+ require_relative 'panels/education'
6
+
7
+ module Usps
8
+ module Imis
9
+ # Namespace for all Panels
10
+ #
11
+ module Panels
12
+ # Convenience accessor for available Panel objects
13
+ #
14
+ # @param api [Api] Parent to use for making requests
15
+ #
16
+ def self.all(api = Api.new)
17
+ panels = constants.reject { it == :BasePanel }
18
+
19
+ Struct
20
+ .new(*panels.map { it.to_s.underscore.to_sym })
21
+ .new(*panels.map { const_get(it).new(api) })
22
+ end
23
+ end
24
+ end
25
+ end
@@ -42,7 +42,7 @@ module Usps
42
42
  when Integer then { '$type' => 'System.Int32', '$value' => value }
43
43
  when true, false then { '$type' => 'System.Boolean', '$value' => value }
44
44
  else
45
- raise Error::ApiError, "Unexpected property type: #{value.inspect}"
45
+ raise Errors::UnexpectedPropertyTypeError.from(value)
46
46
  end
47
47
  end
48
48
  end
@@ -25,7 +25,7 @@ module Usps
25
25
 
26
26
  def submit(uri, request)
27
27
  client(uri).request(request).tap do |result|
28
- raise Error::ResponseError.from(result) unless result.is_a?(Net::HTTPSuccess)
28
+ raise Errors::ResponseError.from(result) unless result.is_a?(Net::HTTPSuccess)
29
29
  end
30
30
  end
31
31
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.6.16'
5
+ VERSION = '0.7.1'
6
6
  end
7
7
  end
data/lib/usps/imis.rb CHANGED
@@ -6,27 +6,17 @@ require 'json'
6
6
  require 'time'
7
7
  require 'cgi'
8
8
 
9
+ require 'active_support/core_ext/string/inflections'
10
+ require 'active_support/core_ext/object/to_query'
9
11
  require 'active_support/string_inquirer'
10
12
 
11
- # Extensions
12
- # :nocov:
13
- require 'ext/hash' unless defined?(Rails)
14
- # :nocov:
15
-
16
13
  # Internal requires
17
14
  require_relative 'imis/config'
18
- require_relative 'imis/error/api_error'
19
- require_relative 'imis/error/mapper_error'
20
- require_relative 'imis/error/response_error'
21
- require_relative 'imis/requests'
22
- require_relative 'imis/business_object'
15
+ require_relative 'imis/error'
23
16
  require_relative 'imis/api'
24
- require_relative 'imis/mapper'
25
17
  require_relative 'imis/properties'
26
- require_relative 'imis/business_object_mock'
27
- require_relative 'imis/panel/base_panel'
28
- require_relative 'imis/panel/vsc'
29
- require_relative 'imis/panel/education'
18
+ require_relative 'imis/panels'
19
+ require_relative 'imis/mocks'
30
20
 
31
21
  module Usps
32
22
  # API wrapper for interacting with iMIS
@@ -31,7 +31,7 @@ describe Usps::Imis::Api do
31
31
 
32
32
  it 'wraps errors' do
33
33
  expect { api.imis_id_for('E231625') }.to raise_error(
34
- Usps::Imis::Error::ApiError, 'Member not found'
34
+ Usps::Imis::Errors::NotFoundError, 'Member not found'
35
35
  )
36
36
  end
37
37
  end
@@ -64,7 +64,7 @@ describe Usps::Imis::Api do
64
64
  context 'when receiving a response error' do
65
65
  let(:warning_text) do
66
66
  <<~WARNING.chomp
67
- Usps::Imis::Error::ResponseError: [INTERNAL_SERVER_ERROR] The iMIS API returned an error.
67
+ Usps::Imis::Errors::ResponseError: [INTERNAL_SERVER_ERROR] The iMIS API returned an error.
68
68
  Something went wrong
69
69
  WARNING
70
70
  end
@@ -79,7 +79,7 @@ describe Usps::Imis::Api do
79
79
 
80
80
  it 'wraps the error' do
81
81
  expect { api.on('ABC_ASC_Individual_Demog').put_fields('TotMMS' => 15) }.to(
82
- raise_error(Usps::Imis::Error::ApiError, warning_text)
82
+ raise_error(Usps::Imis::Errors::ResponseError, warning_text)
83
83
  )
84
84
  end
85
85
  end
@@ -103,13 +103,13 @@ describe Usps::Imis::Api do
103
103
  it 'blocks calling imis_id=' do
104
104
  expect do
105
105
  api.with(31092) { self.imis_id = 31092 }
106
- end.to raise_error(Usps::Imis::Error::ApiError, 'Cannot change iMIS ID while locked')
106
+ end.to raise_error(Usps::Imis::Errors::LockedIdError, 'Cannot change iMIS ID while locked')
107
107
  end
108
108
 
109
109
  it 'blocks calling imis_id_for' do
110
110
  expect do
111
111
  api.with(31092) { imis_id_for('E231625') }
112
- end.to raise_error(Usps::Imis::Error::ApiError, 'Cannot change iMIS ID while locked')
112
+ end.to raise_error(Usps::Imis::Errors::LockedIdError, 'Cannot change iMIS ID while locked')
113
113
  end
114
114
  end
115
115
 
@@ -6,20 +6,8 @@ describe Usps::Imis::BusinessObject do
6
6
  let(:business_object) { described_class.new(api, 'Stub') }
7
7
  let(:api) { Usps::Imis::Api.new }
8
8
 
9
- let(:expected) do
10
- {
11
- 'Properties' => {
12
- '$values' => [
13
- { 'Name' => 'ID', 'Value' => { '$value' => '31092' } },
14
- { 'Name' => 'Stub Integer', 'Value' => { '$value' => 43 } },
15
- { 'Name' => 'Stub String', 'Value' => 'other' }
16
- ]
17
- }
18
- }
19
- end
20
-
21
9
  before do
22
- allow(business_object).to receive(:get).and_return({
10
+ allow(business_object).to receive(:raw_object).and_return({
23
11
  'Properties' => {
24
12
  '$values' => [
25
13
  { 'Name' => 'ID', 'Value' => { '$value' => '31092' } },
@@ -30,6 +18,22 @@ describe Usps::Imis::BusinessObject do
30
18
  })
31
19
  end
32
20
 
21
+ describe '#get' do
22
+ it 'returns multiple values' do
23
+ expect(business_object.get('Stub String', 'Stub Integer')).to eq(['something', 42])
24
+ end
25
+
26
+ describe 'delegation to get_fields' do
27
+ before { allow(business_object).to receive(:get_fields).with('Stub String', 'Stub Integer') }
28
+
29
+ it 'delegates to get_fields' do
30
+ business_object.get('Stub String', 'Stub Integer')
31
+
32
+ expect(business_object).to have_received(:get_fields).with('Stub String', 'Stub Integer')
33
+ end
34
+ end
35
+ end
36
+
33
37
  describe '#get_field' do
34
38
  it 'returns a string value' do
35
39
  expect(business_object.get_field('Stub String')).to eq('something')
@@ -40,7 +44,25 @@ describe Usps::Imis::BusinessObject do
40
44
  end
41
45
  end
42
46
 
47
+ describe '#get_fields' do
48
+ it 'returns multiple values' do
49
+ expect(business_object.get_fields('Stub String', 'Stub Integer')).to eq(['something', 42])
50
+ end
51
+ end
52
+
43
53
  describe '#filter_fields' do
54
+ let(:expected) do
55
+ {
56
+ 'Properties' => {
57
+ '$values' => [
58
+ { 'Name' => 'ID', 'Value' => { '$value' => '31092' } },
59
+ { 'Name' => 'Stub Integer', 'Value' => { '$value' => 43 } },
60
+ { 'Name' => 'Stub String', 'Value' => 'other' }
61
+ ]
62
+ }
63
+ }
64
+ end
65
+
44
66
  it 'formats fields correctly' do
45
67
  updated = business_object.send(:filter_fields, 'Stub Integer' => 43, 'Stub String' => 'other')
46
68
 
@@ -51,7 +51,7 @@ describe Usps::Imis::Config do
51
51
 
52
52
  it 'raises an error' do
53
53
  expect { config.hostname }.to raise_error(
54
- Usps::Imis::Error::ApiError, 'Unexpected API environment: nothing'
54
+ Usps::Imis::Errors::ConfigError, 'Unexpected API environment: nothing'
55
55
  )
56
56
  end
57
57
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Usps::Imis::Error::ApiError do
5
+ describe Usps::Imis::Error do
6
6
  it 'builds Bugsnag metadata' do
7
7
  error = described_class.new('Example', something: :else)
8
8
 
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  ApiResponseStub = Struct.new(:code, :body)
6
6
 
7
- describe Usps::Imis::Error::ResponseError do
7
+ describe Usps::Imis::Errors::ResponseError do
8
8
  let(:error) { described_class.from(response) }
9
9
 
10
10
  describe 'error codes' do
@@ -61,7 +61,7 @@ describe Usps::Imis::Error::ResponseError do
61
61
  let(:response) { ApiResponseStub.new('500', 'Body of the API response error') }
62
62
  let(:warning_text) do
63
63
  <<~WARNING.chomp
64
- Usps::Imis::Error::ResponseError: [INTERNAL_SERVER_ERROR] The iMIS API returned an error.
64
+ Usps::Imis::Errors::ResponseError: [INTERNAL_SERVER_ERROR] The iMIS API returned an error.
65
65
  Body of the API response error
66
66
  WARNING
67
67
  end
@@ -78,7 +78,7 @@ describe Usps::Imis::Error::ResponseError do
78
78
  let(:response) { ApiResponseStub.new('500', response_body) }
79
79
  let(:warning_text) do
80
80
  <<~WARNING.chomp
81
- Usps::Imis::Error::ResponseError: [INTERNAL_SERVER_ERROR] The iMIS API returned an error.
81
+ Usps::Imis::Errors::ResponseError: [INTERNAL_SERVER_ERROR] The iMIS API returned an error.
82
82
  description
83
83
  WARNING
84
84
  end
@@ -95,7 +95,7 @@ describe Usps::Imis::Error::ResponseError do
95
95
  let(:response) { ApiResponseStub.new('500', response_body) }
96
96
  let(:warning_text) do
97
97
  <<~WARNING.chomp
98
- Usps::Imis::Error::ResponseError: [INTERNAL_SERVER_ERROR] The iMIS API returned an error.
98
+ Usps::Imis::Errors::ResponseError: [INTERNAL_SERVER_ERROR] The iMIS API returned an error.
99
99
  #{response_body}
100
100
  WARNING
101
101
  end
@@ -22,8 +22,8 @@ describe Usps::Imis::Mapper do
22
22
 
23
23
  it 'raises for unmapped updates' do
24
24
  expect { api.mapper.update(something: 'anything') }.to raise_error(
25
- Usps::Imis::Error::MapperError,
26
- 'Unrecognized field: "something". ' \
25
+ Usps::Imis::Errors::MapperError,
26
+ %(Mapper does not recognize field: "something".\n) \
27
27
  'Please report what data you are attempting to work with to ITCom leadership.'
28
28
  )
29
29
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Usps::Imis::BusinessObjectMock do
5
+ describe Usps::Imis::Mocks::BusinessObject do
6
6
  let(:mock) { described_class.new(**fields) }
7
7
  let(:fields) { { TotMMS: 2 } }
8
8
 
@@ -0,0 +1,33 @@
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Usps::Imis::Panel::Education do
5
+ describe Usps::Imis::Panels::Education do
6
6
  describe 'api example' do
7
7
  let(:education) { described_class.new }
8
8
 
@@ -23,6 +23,10 @@ describe Usps::Imis::Panel::Education do
23
23
  it 'loads a specific object' do
24
24
  expect(education.get(90737)).to be_a(Hash)
25
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
26
30
  end
27
31
 
28
32
  describe '#get_field' do
@@ -31,6 +35,12 @@ describe Usps::Imis::Panel::Education do
31
35
  end
32
36
  end
33
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
+
34
44
  # rubocop:disable RSpec/ExampleLength
35
45
  it 'interacts with records correctly', :aggregate_failures do
36
46
  new_record = education.create(details)
@@ -51,7 +61,7 @@ describe Usps::Imis::Panel::Education do
51
61
  end
52
62
  expect(patched['Value']).to eq('Online Exams System - Mod2')
53
63
 
54
- expect(education.destroy(ordinal)).to eq('')
64
+ expect(education.destroy(ordinal)).to be(true)
55
65
  end
56
66
  # rubocop:enable RSpec/ExampleLength
57
67
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Usps::Imis::Panel::Vsc do
5
+ describe Usps::Imis::Panels::Vsc do
6
6
  let(:vsc) { described_class.new }
7
7
 
8
8
  let(:details) do
@@ -32,7 +32,7 @@ describe Usps::Imis::Panel::Vsc do
32
32
  updated = update_result['Properties']['$values'].find { it['Name'] == 'Quantity' }
33
33
  expect(updated['Value']['$value']).to eq(43)
34
34
 
35
- expect(vsc.destroy(ordinal)).to eq('')
35
+ expect(vsc.destroy(ordinal)).to be(true)
36
36
  end
37
37
  # rubocop:enable RSpec/ExampleLength
38
38
  end
@@ -13,7 +13,7 @@ describe Usps::Imis::Properties do
13
13
 
14
14
  it 'raises an error for unexpected property types' do
15
15
  expect { builder.send(:wrap, {}) }.to raise_error(
16
- Usps::Imis::Error::ApiError, 'Unexpected property type: {}'
16
+ Usps::Imis::Errors::UnexpectedPropertyTypeError, 'Unexpected property type: {}'
17
17
  )
18
18
  end
19
19
  end
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = Usps::Imis::VERSION
8
8
  s.summary = 'iMIS API Wrapper'
9
9
  s.description = 'A wrapper for the iMIS API.'
10
- s.homepage = 'http://rubygems.org/gems/usps-imis-api'
10
+ s.homepage = 'https://github.com/unitedstatespowersquadrons/imis-api-ruby'
11
11
  s.authors = ['Julian Fiander']
12
12
  s.email = 'jsfiander@gmail.com'
13
13
  s.require_paths = %w[lib]