usps-imis-api 0.3.1.pre.7 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3703bda0677f381f22e23fc1647fe4b663afe0e500ec2c768f4b2cd1f2448156
4
- data.tar.gz: a49bc9912e15692011220fd979161ca2e252708cdc51103d1b205660b859855d
3
+ metadata.gz: 363b03cdc0a93fdde0cf8409874723a07501191f271a23994a2a657ef82ccb2f
4
+ data.tar.gz: 1daa873de5c75094cc755cd9dec593b899388edf337036cb9e53949c4f15c191
5
5
  SHA512:
6
- metadata.gz: 28f1d40bd52b7cab202bbf40421fdb4dbbe2bc7cbd24ce9b881a4888acc5539600e9bc4a4b58334212caaf11d10ed0d64c16fa88a890cc4c008d2189ce63703d
7
- data.tar.gz: fa6c9f0d21c9850726456f46e865568995f7f2d6ce01939f41cbe395cad1766c0fb19a0b9978714707ebcc43d13ac6c538cbecaa9802dab06c8d49759cc8e2e0
6
+ metadata.gz: f795e80baefffaa7a7dad8f18945c1b388b311419ab5bff7bc4de138647b9cdbe2c893ae82675248c36b8c76662394a2feb51312d0321e0b26ebd0d145b7d28d
7
+ data.tar.gz: 742ec65ee15fb91082173f398b9fac89859f78ec32b041ca7332ab5e0fa5a44dd325d91af4e8cecfc04f64f3dc6617de22d078583e9c53e61dc527ebeb1969b9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- usps-imis-api (0.3.1.pre.6)
4
+ usps-imis-api (0.3.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Usps
4
+ module Imis
5
+ module Panel
6
+ class BasePanel
7
+ attr_reader :api
8
+
9
+ def initialize(api = nil)
10
+ @api = api || Api.new
11
+ end
12
+
13
+ def get(ordinal)
14
+ api.get(business_object, url_id: "~#{api.imis_id}|#{ordinal}")
15
+ end
16
+
17
+ def create(data)
18
+ api.post(business_object, payload(data), url_id: '')
19
+ end
20
+
21
+ def update(data)
22
+ api.put(business_object, payload(data), url_id: "~#{api.imis_id}|#{data[:ordinal]}")
23
+ end
24
+
25
+ def destroy(ordinal)
26
+ api.delete(business_object, url_id: "~#{api.imis_id}|#{ordinal}")
27
+ end
28
+
29
+ private
30
+
31
+ def business_object
32
+ raise "#{self.class.name} must implement #business_object"
33
+ end
34
+
35
+ def payload(_data)
36
+ raise "#{self.class.name} must implement #payload(data)"
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Usps
4
+ module Imis
5
+ module Panel
6
+ class Education < BasePanel
7
+ private
8
+
9
+ def business_object
10
+ 'ABC_ASC_Educ'
11
+ end
12
+
13
+ # rubocop:disable Metrics/MethodLength
14
+ def payload(data)
15
+ identity_type =
16
+ 'System.Collections.ObjectModel.Collection`1[[System.String, mscorlib]], mscorlib'
17
+
18
+ {
19
+ '$type' => 'Asi.Soa.Core.DataContracts.GenericEntityData, Asi.Contracts',
20
+ 'EntityTypeName' => 'ABC_ASC_EDUC',
21
+ 'PrimaryParentEntityTypeName' => 'Party',
22
+ 'Identity' => {
23
+ '$type' => 'Asi.Soa.Core.DataContracts.IdentityData, Asi.Contracts',
24
+ 'EntityTypeName' => 'ABC_ASC_EDUC',
25
+ 'IdentityElements' => {
26
+ '$type' => identity_type,
27
+ '$values' => [api.imis_id, data[:ordinal]&.to_s].compact
28
+ }
29
+ },
30
+ 'PrimaryParentIdentity' => {
31
+ '$type' => 'Asi.Soa.Core.DataContracts.IdentityData, Asi.Contracts',
32
+ 'EntityTypeName' => 'Party',
33
+ 'IdentityElements' => {
34
+ '$type' => identity_type,
35
+ '$values' => [api.imis_id]
36
+ }
37
+ },
38
+ 'Properties' => {
39
+ '$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyDataCollection, Asi.Contracts',
40
+ '$values' => [
41
+ {
42
+ '$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts',
43
+ 'Name' => 'ID',
44
+ 'Value' => api.imis_id
45
+ },
46
+ (
47
+ if data[:ordinal]
48
+ {
49
+ '$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts',
50
+ 'Name' => 'Ordinal',
51
+ 'Value' => {
52
+ '$type' => 'System.Int32',
53
+ '$value' => data[:ordinal]
54
+ }
55
+ }
56
+ end
57
+ ),
58
+ {
59
+ "$type" => "Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts",
60
+ "Name" => "ABC_EDUC_THRU_DATE",
61
+ "Value" => (data[:thru_date] || "0001-01-01T00:00:00")
62
+ },
63
+ {
64
+ "$type" => "Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts",
65
+ "Name" => "ABC_ECertificate",
66
+ "Value" => data[:certificate]
67
+ },
68
+ {
69
+ "$type" => "Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts",
70
+ "Name" => "ABC_Educ_Description",
71
+ "Value" => data[:description]
72
+ },
73
+ {
74
+ "$type" => "Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts",
75
+ "Name" => "ABC_Educ_Effective_Date",
76
+ "Value" => data[:effective_date]
77
+ },
78
+ {
79
+ "$type" => "Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts",
80
+ "Name" => "ABC_Educ_Source_System",
81
+ "Value" => data[:source]
82
+ },
83
+ {
84
+ "$type" => "Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts",
85
+ "Name" => "ABC_Educ_Transaction_Date",
86
+ "Value" => Time.now.strftime('%Y-%m-%dT%H:%I:%S')
87
+ },
88
+ {
89
+ "$type" => "Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts",
90
+ "Name" => "ABC_Other_Code",
91
+ "Value" => data[:code]
92
+ },
93
+ {
94
+ "$type" => "Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts",
95
+ "Name" => "ABC_Product_Code",
96
+ "Value" => data[:type_code]
97
+ },
98
+ {
99
+ "$type" => "Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts",
100
+ "Name" => "ABC_TYPE",
101
+ "Value" => (data[:abc_type_code] || "EDUC")
102
+ }
103
+ ].compact
104
+ }
105
+ }
106
+ end
107
+ # rubocop:enable Metrics/MethodLength
108
+ end
109
+ end
110
+ end
111
+ end
@@ -3,29 +3,7 @@
3
3
  module Usps
4
4
  module Imis
5
5
  module Panel
6
- class Vsc
7
- attr_reader :api
8
-
9
- def initialize(api = nil)
10
- @api = api || Api.new
11
- end
12
-
13
- def get(ordinal)
14
- api.get(business_object, url_id: "~#{api.imis_id}|#{ordinal}")
15
- end
16
-
17
- def create(data)
18
- api.post(business_object, payload(data), url_id: '')
19
- end
20
-
21
- def update(data)
22
- api.put(business_object, payload(data), url_id: "~#{api.imis_id}|#{data[:ordinal]}")
23
- end
24
-
25
- def destroy(ordinal)
26
- api.delete(business_object, url_id: "~#{api.imis_id}|#{ordinal}")
27
- end
28
-
6
+ class Vsc < BasePanel
29
7
  private
30
8
 
31
9
  def business_object
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.3.1-7'
5
+ VERSION = '0.3.1'
6
6
  end
7
7
  end
data/lib/usps/imis.rb CHANGED
@@ -15,7 +15,7 @@ require_relative 'imis/error/api'
15
15
  require_relative 'imis/error/mapper'
16
16
  require_relative 'imis/api'
17
17
  require_relative 'imis/mapper'
18
- # require_relative 'imis/panel/base_panel'
18
+ require_relative 'imis/panel/base_panel'
19
19
  require_relative 'imis/panel/vsc'
20
20
  require_relative 'imis/panel/education'
21
21
 
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Usps::Imis::Panel::Education do
6
+ let(:education) { described_class.new }
7
+
8
+ let(:details) do
9
+ {
10
+ certificate: 'E136924',
11
+ description: 'Marine Navigation',
12
+ effective_date: Time.now.strftime('%Y-%m-%dT00:00:00'),
13
+ source: 'Online Exams System',
14
+ code: 'MN',
15
+ type_code: 'CRS'
16
+
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(Hash)
25
+ end
26
+ end
27
+
28
+ # rubocop:disable RSpec/ExampleLength
29
+ it 'handles new records correctly', :aggregate_failures do
30
+ new_record = education.create(details)
31
+ expect(new_record).to be_a(Hash)
32
+
33
+ ordinal = new_record['Properties']['$values'][1]['Value']['$value']
34
+
35
+ update_result = education.update(details.merge(source: 'Online Exams System - Modified', ordinal: ordinal))
36
+ updated = update_result['Properties']['$values'].find { |v| v['Name'] == 'ABC_Educ_Source_System' }
37
+ expect(updated['Value']).to eq('Online Exams System - Modified')
38
+
39
+ expect(education.destroy(ordinal)).to eq('')
40
+ end
41
+ # rubocop:enable RSpec/ExampleLength
42
+ 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.3.1.pre.7
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander
@@ -33,10 +33,13 @@ files:
33
33
  - lib/usps/imis/error/api.rb
34
34
  - lib/usps/imis/error/mapper.rb
35
35
  - lib/usps/imis/mapper.rb
36
+ - lib/usps/imis/panel/base_panel.rb
37
+ - lib/usps/imis/panel/education.rb
36
38
  - lib/usps/imis/panel/vsc.rb
37
39
  - lib/usps/imis/version.rb
38
40
  - spec/lib/usps/imis/api_spec.rb
39
41
  - spec/lib/usps/imis/mapper_spec.rb
42
+ - spec/lib/usps/imis/panel/education_spec.rb
40
43
  - spec/lib/usps/imis/panel/vsc_spec.rb
41
44
  - spec/spec_helper.rb
42
45
  - usps-imis-api.gemspec