usps-imis-api 0.4.5 → 0.5.0

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: 602e95212148a4087db86d19ff47a8680d8a83a488331129588292150a00b0f2
4
- data.tar.gz: 95ef0ede88acad9e0b66b5ac1b1bce88801604229f6a54b848ca4349fca34536
3
+ metadata.gz: 1febbdb28781a5589ce97b66eb071728aef8b8e81991970854620c9fc128cf54
4
+ data.tar.gz: cc5aeb7ddab766c885d4bb009b1fa9afcdaa8f71d68b56f2e86861c12f8eda72
5
5
  SHA512:
6
- metadata.gz: 8be9f80db96ff34ca7a40f459825a0537a4e1007a1ac6939eefae392133cbdca479b0b11099b0daab2c59690f83b9cfd7a0dfbbb9ed6e0b55090466bc3239f30
7
- data.tar.gz: 7b502a0e9a7f7ce84ae79b17c1a945e2b01680dd7c4a4ff583d08bb6d08db32f6e6537c4c2d05f2e99ffb342cd1d35079119c38d7e750bd075992b59737d1a4f
6
+ metadata.gz: '09fdb03097ef67813356bf1a4378f53827bcacc3c8115fb9128ce0f2a8dcdceb26aafc3296b8132468860906ac3884965c53b4e47729aa8dc0a964a13346717e'
7
+ data.tar.gz: 3703f4325f53afde2c9350c4382d0cbfeb4d53489275c866a1041749ba5324d7833c4a3fe14f11e70bcd3a1729981f2b3b3befcd3a603a5ab5703a03ae6a9cc5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- usps-imis-api (0.4.5)
4
+ usps-imis-api (0.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/usps/imis/api.rb CHANGED
@@ -59,7 +59,7 @@ module Usps
59
59
  result = query(Imis.configuration.imis_id_query_name, { certificate: })
60
60
  @imis_id = result['Items']['$values'][0]['ID']
61
61
  rescue StandardError
62
- raise Error::Api, 'Member not found'
62
+ raise Error::ApiError, 'Member not found'
63
63
  end
64
64
 
65
65
  # Run requests as DSL, with specific iMIS ID only maintained for this scope
@@ -228,7 +228,7 @@ module Usps
228
228
 
229
229
  def submit(uri, request)
230
230
  client(uri).request(request).tap do |result|
231
- raise Error::Response.from(result) unless result.is_a?(Net::HTTPSuccess)
231
+ raise Error::ResponseError.from(result) unless result.is_a?(Net::HTTPSuccess)
232
232
  end
233
233
  end
234
234
 
@@ -25,7 +25,7 @@ module Usps
25
25
  when :development
26
26
  IMIS_ROOT_URL_DEV
27
27
  else
28
- raise Error::Api, "Unexpected API environment: #{environment}"
28
+ raise Error::ApiError, "Unexpected API environment: #{environment}"
29
29
  end
30
30
  end
31
31
 
@@ -5,12 +5,12 @@ module Usps
5
5
  module Error
6
6
  # Base error class for all internal exceptions
7
7
  #
8
- class Api < StandardError
8
+ class ApiError < StandardError
9
9
  # Additional call-specific metadata to pass through to Bugsnag
10
10
  #
11
11
  attr_accessor :metadata
12
12
 
13
- # A new instance of +Error::Api+
13
+ # A new instance of +ApiError+
14
14
  #
15
15
  # @param message [String] The base exception message
16
16
  # @param metadata [Hash] Additional call-specific metadata to pass through to Bugsnag
@@ -5,7 +5,7 @@ module Usps
5
5
  module Error
6
6
  # Exception raised by a +Mapper+
7
7
  #
8
- class Mapper < Api; end
8
+ class MapperError < ApiError; end
9
9
  end
10
10
  end
11
11
  end
@@ -5,7 +5,7 @@ module Usps
5
5
  module Error
6
6
  # Exception raised due to receiving an error response from the API
7
7
  #
8
- class Response < Api
8
+ class ResponseError < ApiError
9
9
  # [Net::HTTPResponse] The response received from the API
10
10
  #
11
11
  attr_reader :response
@@ -14,7 +14,7 @@ module Usps
14
14
  #
15
15
  attr_accessor :metadata
16
16
 
17
- # Create a new instance of +Error::Response+ from an API response
17
+ # Create a new instance of +ResponseError+ from an API response
18
18
  #
19
19
  # @param response [Net::HTTPResponse] The response received from the API
20
20
  #
@@ -22,7 +22,7 @@ module Usps
22
22
  new(nil, response)
23
23
  end
24
24
 
25
- # Create a new instance of +Error::Response+
25
+ # Create a new instance of +ResponseError+
26
26
  #
27
27
  # @param _message Ignored
28
28
  # @param response [Net::HTTPResponse] The response received from the API
@@ -74,7 +74,7 @@ module Usps
74
74
  end
75
75
 
76
76
  raise(
77
- Error::Mapper,
77
+ Error::MapperError,
78
78
  "Unrecognized field: \"#{field_name}\". " \
79
79
  'Please report what data you are attempting to work with to ITCom leadership.'
80
80
  )
@@ -51,11 +51,11 @@ module Usps
51
51
  private
52
52
 
53
53
  def business_object
54
- raise Error::Api, "#{self.class.name} must implement #business_object"
54
+ raise Error::ApiError, "#{self.class.name} must implement #business_object"
55
55
  end
56
56
 
57
57
  def payload(_data)
58
- raise Error::Api, "#{self.class.name} must implement #payload(data)"
58
+ raise Error::ApiError, "#{self.class.name} must implement #payload(data)"
59
59
  end
60
60
  end
61
61
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.4.5'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
data/lib/usps/imis.rb CHANGED
@@ -13,9 +13,9 @@ require 'ext/hash' unless defined?(Rails)
13
13
 
14
14
  # Internal requires
15
15
  require_relative 'imis/config'
16
- require_relative 'imis/error/api'
17
- require_relative 'imis/error/mapper'
18
- require_relative 'imis/error/response'
16
+ require_relative 'imis/error/api_error'
17
+ require_relative 'imis/error/mapper_error'
18
+ require_relative 'imis/error/response_error'
19
19
  require_relative 'imis/api'
20
20
  require_relative 'imis/mapper'
21
21
  require_relative 'imis/panel/base_panel'
@@ -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::Api, 'Member not found'
34
+ Usps::Imis::Error::ApiError, 'Member not found'
35
35
  )
36
36
  end
37
37
  end
@@ -47,7 +47,7 @@ describe Usps::Imis::Api do
47
47
  context 'when receiving a response error' do
48
48
  let(:warning_text) do
49
49
  <<~WARNING.chomp
50
- Usps::Imis::Error::Response: [INTERNAL_SERVER_ERROR] The iMIS API returned an error.
50
+ Usps::Imis::Error::ResponseError: [INTERNAL_SERVER_ERROR] The iMIS API returned an error.
51
51
  Something went wrong
52
52
  WARNING
53
53
  end
@@ -62,7 +62,7 @@ describe Usps::Imis::Api do
62
62
 
63
63
  it 'wraps the error' do
64
64
  expect { api.put_fields('ABC_ASC_Individual_Demog', { 'TotMMS' => 15 }) }.to raise_error(
65
- Usps::Imis::Error::Api, warning_text
65
+ Usps::Imis::Error::ApiError, warning_text
66
66
  )
67
67
  end
68
68
  end
@@ -25,7 +25,7 @@ describe Usps::Imis::Config do
25
25
 
26
26
  it 'raises an error' do
27
27
  expect { config.hostname }.to raise_error(
28
- Usps::Imis::Error::Api, 'Unexpected API environment: nothing'
28
+ Usps::Imis::Error::ApiError, 'Unexpected API environment: nothing'
29
29
  )
30
30
  end
31
31
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Usps::Imis::Error::Api do
5
+ describe Usps::Imis::Error::ApiError 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::Response do
7
+ describe Usps::Imis::Error::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::Response 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::Response: [INTERNAL_SERVER_ERROR] The iMIS API returned an error.
64
+ Usps::Imis::Error::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::Response do
78
78
  let(:response) { ApiResponseStub.new('500', response_body) }
79
79
  let(:warning_text) do
80
80
  <<~WARNING.chomp
81
- Usps::Imis::Error::Response: [INTERNAL_SERVER_ERROR] The iMIS API returned an error.
81
+ Usps::Imis::Error::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::Response do
95
95
  let(:response) { ApiResponseStub.new('500', response_body) }
96
96
  let(:warning_text) do
97
97
  <<~WARNING.chomp
98
- Usps::Imis::Error::Response: [INTERNAL_SERVER_ERROR] The iMIS API returned an error.
98
+ Usps::Imis::Error::ResponseError: [INTERNAL_SERVER_ERROR] The iMIS API returned an error.
99
99
  #{response_body}
100
100
  WARNING
101
101
  end
@@ -22,7 +22,7 @@ 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::Mapper,
25
+ Usps::Imis::Error::MapperError,
26
26
  'Unrecognized field: "something". ' \
27
27
  'Please report what data you are attempting to work with to ITCom leadership.'
28
28
  )
@@ -19,13 +19,13 @@ end
19
19
  describe Usps::Imis::Panel::BasePanel do
20
20
  it 'requires #business_object to be defined' do
21
21
  expect { Usps::Imis::Panel::InvalidPanel.new.get(1) }.to raise_error(
22
- Usps::Imis::Error::Api, 'Usps::Imis::Panel::InvalidPanel must implement #business_object'
22
+ Usps::Imis::Error::ApiError, 'Usps::Imis::Panel::InvalidPanel must implement #business_object'
23
23
  )
24
24
  end
25
25
 
26
26
  it 'requires #payload(data) to be defined' do
27
27
  expect { Usps::Imis::Panel::InvalidPanelWithBusinessObject.new.create({}) }.to raise_error(
28
- Usps::Imis::Error::Api,
28
+ Usps::Imis::Error::ApiError,
29
29
  'Usps::Imis::Panel::InvalidPanelWithBusinessObject must implement #payload(data)'
30
30
  )
31
31
  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.5
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander
@@ -31,9 +31,9 @@ files:
31
31
  - lib/usps/imis.rb
32
32
  - lib/usps/imis/api.rb
33
33
  - lib/usps/imis/config.rb
34
- - lib/usps/imis/error/api.rb
35
- - lib/usps/imis/error/mapper.rb
36
- - lib/usps/imis/error/response.rb
34
+ - lib/usps/imis/error/api_error.rb
35
+ - lib/usps/imis/error/mapper_error.rb
36
+ - lib/usps/imis/error/response_error.rb
37
37
  - lib/usps/imis/mapper.rb
38
38
  - lib/usps/imis/panel/base_panel.rb
39
39
  - lib/usps/imis/panel/education.rb
@@ -41,8 +41,8 @@ files:
41
41
  - lib/usps/imis/version.rb
42
42
  - spec/lib/usps/imis/api_spec.rb
43
43
  - spec/lib/usps/imis/config_spec.rb
44
- - spec/lib/usps/imis/error/api_spec.rb
45
- - spec/lib/usps/imis/error/response_spec.rb
44
+ - spec/lib/usps/imis/error/api_error_spec.rb
45
+ - spec/lib/usps/imis/error/response_error_spec.rb
46
46
  - spec/lib/usps/imis/mapper_spec.rb
47
47
  - spec/lib/usps/imis/panel/base_panel_spec.rb
48
48
  - spec/lib/usps/imis/panel/education_spec.rb