usps-imis-api 0.6.5 → 0.6.6
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 +12 -1
- data/lib/usps/imis/panel/education.rb +2 -2
- data/lib/usps/imis/panel/vsc.rb +3 -3
- data/lib/usps/imis/version.rb +1 -1
- data/spec/lib/usps/imis/panel/base_panel_spec.rb +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ac6724a275018ca6e957f9342236882dde2232e1c6e9cf8f0f11e962e2ae5bb7
|
|
4
|
+
data.tar.gz: 196dc78c0f36f2921e79aba9cfd6157818932f62751475817f0b054cd2decc8d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6ef1c062d0d887efcb0d9c0884e43df859d992f65546b16de6d359545c6f0fa92bc0d6d533c6dbca212e5fbdd47b1e3d1cd23e7a91b4af304ed4e95199e8cdb1
|
|
7
|
+
data.tar.gz: 1fe0de2b0c8f722afa9159779973ef9491f007dad2667cd18f2e863128d69c487f7a09801fba1c9bb0c0710c002e84396064d0a3a98c725f43b4d75f006ca907
|
data/Gemfile.lock
CHANGED
|
@@ -117,9 +117,20 @@ module Usps
|
|
|
117
117
|
@properties << {
|
|
118
118
|
'$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts',
|
|
119
119
|
'Name' => name,
|
|
120
|
-
'Value' => value
|
|
120
|
+
'Value' => property_value(value)
|
|
121
121
|
}
|
|
122
122
|
end
|
|
123
|
+
|
|
124
|
+
def property_value(value)
|
|
125
|
+
case value
|
|
126
|
+
when String then value
|
|
127
|
+
when Time, DateTime then value.strftime('%Y-%m-%dT%H:%I:%S')
|
|
128
|
+
when Integer then { '$type' => 'System.Int32', '$value' => value }
|
|
129
|
+
when true, false then { '$type' => 'System.Boolean', '$value' => value }
|
|
130
|
+
else
|
|
131
|
+
raise Error::ApiError, "Unexpected property type: #{value.inspect}"
|
|
132
|
+
end
|
|
133
|
+
end
|
|
123
134
|
end
|
|
124
135
|
end
|
|
125
136
|
end
|
|
@@ -15,13 +15,13 @@ module Usps
|
|
|
15
15
|
def payload(data)
|
|
16
16
|
properties(data) do
|
|
17
17
|
property 'ID', api.imis_id
|
|
18
|
-
property 'Ordinal',
|
|
18
|
+
property 'Ordinal', data[:ordinal] if data[:ordinal]
|
|
19
19
|
property 'ABC_EDUC_THRU_DATE', data[:thru_date] || '0001-01-01T00:00:00'
|
|
20
20
|
property 'ABC_ECertificate', data[:certificate]
|
|
21
21
|
property 'ABC_Educ_Description', data[:description]
|
|
22
22
|
property 'ABC_Educ_Effective_Date', data[:effective_date]
|
|
23
23
|
property 'ABC_Educ_Source_System', data[:source]
|
|
24
|
-
property 'ABC_Educ_Transaction_Date', Time.now
|
|
24
|
+
property 'ABC_Educ_Transaction_Date', Time.now
|
|
25
25
|
property 'ABC_Other_Code', data[:code]
|
|
26
26
|
property 'ABC_Product_Code', data[:type_code]
|
|
27
27
|
property 'ABC_TYPE', data[:abc_type_code] || 'EDUC'
|
data/lib/usps/imis/panel/vsc.rb
CHANGED
|
@@ -15,15 +15,15 @@ module Usps
|
|
|
15
15
|
def payload(data)
|
|
16
16
|
properties(data) do
|
|
17
17
|
property 'ID', api.imis_id
|
|
18
|
-
property 'Ordinal',
|
|
18
|
+
property 'Ordinal', data[:ordinal] if data[:ordinal]
|
|
19
19
|
property 'Source_System', 'Manual ITCom Entry'
|
|
20
20
|
property 'ABC_ECertificate', data[:certificate]
|
|
21
21
|
property 'Activity_Type', 'VSC'
|
|
22
22
|
property 'Description', 'Vessel Safety Checks'
|
|
23
23
|
property 'Effective_Date', "#{data[:year]}-12-01T00:00:00"
|
|
24
|
-
property 'Quantity',
|
|
24
|
+
property 'Quantity', data[:count]
|
|
25
25
|
property 'Thru_Date', "#{data[:year]}-12-31T00:00:00"
|
|
26
|
-
property 'Transaction_Date', Time.now
|
|
26
|
+
property 'Transaction_Date', Time.now
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
end
|
data/lib/usps/imis/version.rb
CHANGED
|
@@ -35,4 +35,16 @@ describe Usps::Imis::Panel::BasePanel do
|
|
|
35
35
|
Usps::Imis::Error::ApiError, 'Must be called within a `properties` block'
|
|
36
36
|
)
|
|
37
37
|
end
|
|
38
|
+
|
|
39
|
+
it 'handles boolean property values' do
|
|
40
|
+
expect(described_class.new.send(:property_value, true)).to eq(
|
|
41
|
+
'$type' => 'System.Boolean', '$value' => true
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'raises an error for unexpected property types' do
|
|
46
|
+
expect { described_class.new.send(:property_value, {}) }.to raise_error(
|
|
47
|
+
Usps::Imis::Error::ApiError, 'Unexpected property type: {}'
|
|
48
|
+
)
|
|
49
|
+
end
|
|
38
50
|
end
|