usps-imis-api 0.6.5 → 0.6.7
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/Gemfile.lock +1 -1
- data/lib/usps/imis/panel/base_panel.rb +2 -27
- data/lib/usps/imis/panel/education.rb +12 -12
- data/lib/usps/imis/panel/panel_properties.rb +52 -0
- data/lib/usps/imis/panel/vsc.rb +11 -11
- data/lib/usps/imis/version.rb +1 -1
- data/lib/usps/imis.rb +1 -0
- data/spec/lib/usps/imis/panel/base_panel_spec.rb +0 -6
- data/spec/lib/usps/imis/panel/panel_properties_spec.rb +19 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f44d99329182eff27d60dff25449d91f8d14084f786c5168f93e8e3b672ce6b1
|
|
4
|
+
data.tar.gz: 4a0442ea2b9d0e48315d18eae15185d0e77a213eb4a85f7893e986726012226b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7526619b51b50993ad53b46322d8fedd345058bf0dec8b6ec77dca6794ea8cc5468122f98dda9b93b0bb1049fe75e835ed1cceb35c8f6b7f6507ba64d8c81148
|
|
7
|
+
data.tar.gz: 850744a918e3a273c952d40e4ce8cb6cdfdb18d6c5cca3fd13ba903821b378ab94bf1302fa14e9d7dfe4bf63b3c0899205feb10630d6ceeb4d564c4cc9c6ae2a
|
data/Gemfile.lock
CHANGED
|
@@ -92,34 +92,9 @@ module Usps
|
|
|
92
92
|
}
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
-
def identity_type
|
|
96
|
-
'System.Collections.ObjectModel.Collection`1[[System.String, mscorlib]], mscorlib'
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
def properties(data, &)
|
|
100
|
-
@properties = []
|
|
101
|
-
|
|
102
|
-
instance_eval(&)
|
|
95
|
+
def identity_type = 'System.Collections.ObjectModel.Collection`1[[System.String, mscorlib]], mscorlib'
|
|
103
96
|
|
|
104
|
-
|
|
105
|
-
'Properties' => {
|
|
106
|
-
'$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyDataCollection, Asi.Contracts',
|
|
107
|
-
'$values' => @properties
|
|
108
|
-
}
|
|
109
|
-
)
|
|
110
|
-
ensure
|
|
111
|
-
remove_instance_variable(:@properties)
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
def property(name, value)
|
|
115
|
-
raise Error::ApiError, 'Must be called within a `properties` block' unless defined?(@properties)
|
|
116
|
-
|
|
117
|
-
@properties << {
|
|
118
|
-
'$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts',
|
|
119
|
-
'Name' => name,
|
|
120
|
-
'Value' => value
|
|
121
|
-
}
|
|
122
|
-
end
|
|
97
|
+
def build_payload(data, &) = payload_header(data).merge(PanelProperties.build(&))
|
|
123
98
|
end
|
|
124
99
|
end
|
|
125
100
|
end
|
|
@@ -13,18 +13,18 @@ module Usps
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def payload(data)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
build_payload(data) do |props|
|
|
17
|
+
props.add 'ID', api.imis_id
|
|
18
|
+
props.add 'Ordinal', data[:ordinal] if data[:ordinal]
|
|
19
|
+
props.add 'ABC_EDUC_THRU_DATE', data[:thru_date] || '0001-01-01T00:00:00'
|
|
20
|
+
props.add 'ABC_ECertificate', data[:certificate]
|
|
21
|
+
props.add 'ABC_Educ_Description', data[:description]
|
|
22
|
+
props.add 'ABC_Educ_Effective_Date', data[:effective_date]
|
|
23
|
+
props.add 'ABC_Educ_Source_System', data[:source]
|
|
24
|
+
props.add 'ABC_Educ_Transaction_Date', Time.now
|
|
25
|
+
props.add 'ABC_Other_Code', data[:code]
|
|
26
|
+
props.add 'ABC_Product_Code', data[:type_code]
|
|
27
|
+
props.add 'ABC_TYPE', data[:abc_type_code] || 'EDUC'
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps
|
|
4
|
+
module Imis
|
|
5
|
+
module Panel
|
|
6
|
+
# Constructor for the Properties field for Panel requests
|
|
7
|
+
#
|
|
8
|
+
class PanelProperties
|
|
9
|
+
# Build a new Properties field
|
|
10
|
+
#
|
|
11
|
+
def self.build(&) = new.build(&)
|
|
12
|
+
|
|
13
|
+
# Build the Properties field
|
|
14
|
+
#
|
|
15
|
+
def build
|
|
16
|
+
yield(self)
|
|
17
|
+
|
|
18
|
+
{
|
|
19
|
+
'Properties' => {
|
|
20
|
+
'$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyDataCollection, Asi.Contracts',
|
|
21
|
+
'$values' => @properties
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Add an individual property to the field
|
|
27
|
+
#
|
|
28
|
+
def add(name, value)
|
|
29
|
+
@properties ||= []
|
|
30
|
+
@properties << {
|
|
31
|
+
'$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts',
|
|
32
|
+
'Name' => name,
|
|
33
|
+
'Value' => property_value(value)
|
|
34
|
+
}
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def property_value(value)
|
|
40
|
+
case value
|
|
41
|
+
when String then value
|
|
42
|
+
when Time, DateTime then value.strftime('%Y-%m-%dT%H:%I:%S')
|
|
43
|
+
when Integer then { '$type' => 'System.Int32', '$value' => value }
|
|
44
|
+
when true, false then { '$type' => 'System.Boolean', '$value' => value }
|
|
45
|
+
else
|
|
46
|
+
raise Error::ApiError, "Unexpected property type: #{value.inspect}"
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
data/lib/usps/imis/panel/vsc.rb
CHANGED
|
@@ -13,17 +13,17 @@ module Usps
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def payload(data)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
build_payload(data) do |props|
|
|
17
|
+
props.add 'ID', api.imis_id
|
|
18
|
+
props.add 'Ordinal', data[:ordinal] if data[:ordinal]
|
|
19
|
+
props.add 'Source_System', 'Manual ITCom Entry'
|
|
20
|
+
props.add 'ABC_ECertificate', data[:certificate]
|
|
21
|
+
props.add 'Activity_Type', 'VSC'
|
|
22
|
+
props.add 'Description', 'Vessel Safety Checks'
|
|
23
|
+
props.add 'Effective_Date', "#{data[:year]}-12-01T00:00:00"
|
|
24
|
+
props.add 'Quantity', data[:count]
|
|
25
|
+
props.add 'Thru_Date', "#{data[:year]}-12-31T00:00:00"
|
|
26
|
+
props.add 'Transaction_Date', Time.now
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
end
|
data/lib/usps/imis/version.rb
CHANGED
data/lib/usps/imis.rb
CHANGED
|
@@ -23,6 +23,7 @@ require_relative 'imis/business_object'
|
|
|
23
23
|
require_relative 'imis/api'
|
|
24
24
|
require_relative 'imis/mapper'
|
|
25
25
|
require_relative 'imis/panel/base_panel'
|
|
26
|
+
require_relative 'imis/panel/panel_properties'
|
|
26
27
|
require_relative 'imis/panel/vsc'
|
|
27
28
|
require_relative 'imis/panel/education'
|
|
28
29
|
|
|
@@ -29,10 +29,4 @@ describe Usps::Imis::Panel::BasePanel do
|
|
|
29
29
|
'Usps::Imis::Panel::InvalidPanelWithBusinessObject must implement #payload(data)'
|
|
30
30
|
)
|
|
31
31
|
end
|
|
32
|
-
|
|
33
|
-
it 'does not allow calling property outside of a properties block' do
|
|
34
|
-
expect { described_class.new.send(:property, 'name', 'value') }.to raise_error(
|
|
35
|
-
Usps::Imis::Error::ApiError, 'Must be called within a `properties` block'
|
|
36
|
-
)
|
|
37
|
-
end
|
|
38
32
|
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Usps::Imis::Panel::PanelProperties do
|
|
6
|
+
let(:builder) { described_class.new }
|
|
7
|
+
|
|
8
|
+
it 'handles boolean property values' do
|
|
9
|
+
expect(builder.send(:property_value, 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(:property_value, {}) }.to raise_error(
|
|
16
|
+
Usps::Imis::Error::ApiError, 'Unexpected property type: {}'
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
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.
|
|
4
|
+
version: 0.6.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Julian Fiander
|
|
@@ -52,6 +52,7 @@ files:
|
|
|
52
52
|
- lib/usps/imis/mapper.rb
|
|
53
53
|
- lib/usps/imis/panel/base_panel.rb
|
|
54
54
|
- lib/usps/imis/panel/education.rb
|
|
55
|
+
- lib/usps/imis/panel/panel_properties.rb
|
|
55
56
|
- lib/usps/imis/panel/vsc.rb
|
|
56
57
|
- lib/usps/imis/requests.rb
|
|
57
58
|
- lib/usps/imis/version.rb
|
|
@@ -63,6 +64,7 @@ files:
|
|
|
63
64
|
- spec/lib/usps/imis/mapper_spec.rb
|
|
64
65
|
- spec/lib/usps/imis/panel/base_panel_spec.rb
|
|
65
66
|
- spec/lib/usps/imis/panel/education_spec.rb
|
|
67
|
+
- spec/lib/usps/imis/panel/panel_properties_spec.rb
|
|
66
68
|
- spec/lib/usps/imis/panel/vsc_spec.rb
|
|
67
69
|
- spec/lib/usps/imis_spec.rb
|
|
68
70
|
- spec/spec_helper.rb
|