usps-imis-api 0.6.10 → 0.6.11

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: 5103e3c7de24d79be7d86bfd21883d572d5cc88f6c58509973ab2bcce3d99202
4
- data.tar.gz: 1e96b2dbf536e4205f2fb721ddba91cd2640af1893c30db3d911fea6824b6ea9
3
+ metadata.gz: cd7f53417285bbe15766b1e79e88448807a1e481f13cb20a16d1bfb791a96f15
4
+ data.tar.gz: fb6c040f10270293db091bd20c25de73679de83fd24bf1253cbd50f82e53c1e3
5
5
  SHA512:
6
- metadata.gz: 53fa63489cda9a6dd09401605daf22329cad3a6f2f3313b068eb3ecd339d9ceff518134305601a2591451acdd03723f566096cb2bcc754c90da03d79d32de315
7
- data.tar.gz: df0052735b664cc91e4d4b923b1c7ecffe065acc44d320624cc84e834607f557df7c3c39b04cc95410642de07df665da56700c9d543be3cb0f15e1644bf12f15
6
+ metadata.gz: e65d398030e74648c5c0ceadcc1ab9bd3b94e481d5c20c14761d30e3efa4dcb6a3293e1b4d2d5de2f3678acd8cac80f0051074cff86c99386023e097ce3e2b4e
7
+ data.tar.gz: f436a6c796ffef704e7fd73ceb59e9352b77bb1a35efa0cbf96909e47a3ee7c24fbf4288cbe413941da49e6bf69c8b88aa2a952c0426523ec4ff9b5ae8f2c3df
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- usps-imis-api (0.6.10)
4
+ usps-imis-api (0.6.11)
5
5
  activesupport (~> 8.0)
6
6
 
7
7
  GEM
@@ -4,7 +4,7 @@ module Usps
4
4
  module Imis
5
5
  # Mock data response for testing
6
6
  #
7
- class Mock
7
+ class BusinessObjectMock
8
8
  attr_reader :fields
9
9
 
10
10
  def initialize(**fields)
@@ -18,6 +18,18 @@ module Usps
18
18
  fields.each { |name, value| props.add(name, value) }
19
19
  end
20
20
  end
21
+
22
+ def put_fields(data)
23
+ Usps::Imis::Properties.build do |props|
24
+ fields.merge(data.transform_keys(&:to_s)).each { |name, value| props.add(name, value) }
25
+ end
26
+ end
27
+
28
+ def put(data) = data
29
+
30
+ def post(data) = data
31
+
32
+ def delete = ''
21
33
  end
22
34
  end
23
35
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.6.10'
5
+ VERSION = '0.6.11'
6
6
  end
7
7
  end
data/lib/usps/imis.rb CHANGED
@@ -23,7 +23,7 @@ require_relative 'imis/business_object'
23
23
  require_relative 'imis/api'
24
24
  require_relative 'imis/mapper'
25
25
  require_relative 'imis/properties'
26
- require_relative 'imis/mock'
26
+ require_relative 'imis/business_object_mock'
27
27
  require_relative 'imis/panel/base_panel'
28
28
  require_relative 'imis/panel/vsc'
29
29
  require_relative 'imis/panel/education'
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Usps::Imis::BusinessObjectMock do
6
+ let(:mock) { described_class.new(**fields) }
7
+ let(:fields) { { TotMMS: 2 } }
8
+
9
+ let(:data) do
10
+ Usps::Imis::Properties.build do |props|
11
+ props.add 'TotMMS', 2
12
+ end
13
+ end
14
+
15
+ describe 'get' do
16
+ it 'returns the correct data' do
17
+ expect(mock.get).to eq(data)
18
+ end
19
+ end
20
+
21
+ describe 'get_field' do
22
+ it 'returns the correct field value' do
23
+ expect(mock.get_field('TotMMS')).to eq(2)
24
+ end
25
+ end
26
+
27
+ describe 'put_fields' do
28
+ let(:combined_data) do
29
+ Usps::Imis::Properties.build do |props|
30
+ props.add 'TotMMS', 2
31
+ props.add 'SomethingElse', 'interesting'
32
+ end
33
+ end
34
+
35
+ it 'returns the correct data' do
36
+ expect(mock.put_fields(SomethingElse: 'interesting')).to eq(combined_data)
37
+ end
38
+ end
39
+
40
+ describe 'put' do
41
+ it 'returns the correct data' do
42
+ expect(mock.put(data)).to eq(data)
43
+ end
44
+ end
45
+
46
+ describe 'post' do
47
+ it 'returns the correct data' do
48
+ expect(mock.post(data)).to eq(data)
49
+ end
50
+ end
51
+
52
+ describe 'delete' do
53
+ it 'returns the correct data' do
54
+ expect(mock.delete).to eq('')
55
+ end
56
+ end
57
+ 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.6.10
4
+ version: 0.6.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander
@@ -45,12 +45,12 @@ files:
45
45
  - lib/usps/imis.rb
46
46
  - lib/usps/imis/api.rb
47
47
  - lib/usps/imis/business_object.rb
48
+ - lib/usps/imis/business_object_mock.rb
48
49
  - lib/usps/imis/config.rb
49
50
  - lib/usps/imis/error/api_error.rb
50
51
  - lib/usps/imis/error/mapper_error.rb
51
52
  - lib/usps/imis/error/response_error.rb
52
53
  - lib/usps/imis/mapper.rb
53
- - lib/usps/imis/mock.rb
54
54
  - lib/usps/imis/panel/base_panel.rb
55
55
  - lib/usps/imis/panel/education.rb
56
56
  - lib/usps/imis/panel/vsc.rb
@@ -58,12 +58,12 @@ files:
58
58
  - lib/usps/imis/requests.rb
59
59
  - lib/usps/imis/version.rb
60
60
  - spec/lib/usps/imis/api_spec.rb
61
+ - spec/lib/usps/imis/business_object_mock_spec.rb
61
62
  - spec/lib/usps/imis/business_object_spec.rb
62
63
  - spec/lib/usps/imis/config_spec.rb
63
64
  - spec/lib/usps/imis/error/api_error_spec.rb
64
65
  - spec/lib/usps/imis/error/response_error_spec.rb
65
66
  - spec/lib/usps/imis/mapper_spec.rb
66
- - spec/lib/usps/imis/mock_spec.rb
67
67
  - spec/lib/usps/imis/panel/base_panel_spec.rb
68
68
  - spec/lib/usps/imis/panel/education_spec.rb
69
69
  - spec/lib/usps/imis/panel/vsc_spec.rb
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Usps::Imis::Mock do
6
- let(:mock) { described_class.new(**fields) }
7
- let(:fields) { { TotMMS: 2 } }
8
-
9
- describe 'get' do
10
- it 'returns the correct Properties data' do
11
- expect(mock.get).to eq(
12
- 'Properties' => {
13
- '$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyDataCollection, Asi.Contracts',
14
- '$values' => [
15
- {
16
- '$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts',
17
- 'Name' => 'TotMMS',
18
- 'Value' => {
19
- '$type' => 'System.Int32',
20
- '$value' => 2
21
- }
22
- }
23
- ]
24
- }
25
- )
26
- end
27
- end
28
- end