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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cb3b6691433ac4025d4754b093d3843620e13396cdd61995cce7b8b0c330da5
4
- data.tar.gz: a46f9929ea1dd7eabf47eb6364768014807129cf495f84748e6cb8d2cb95aa72
3
+ metadata.gz: ac6724a275018ca6e957f9342236882dde2232e1c6e9cf8f0f11e962e2ae5bb7
4
+ data.tar.gz: 196dc78c0f36f2921e79aba9cfd6157818932f62751475817f0b054cd2decc8d
5
5
  SHA512:
6
- metadata.gz: 2cf22b22ca0e4c99e450e5805a58a841d462e86fd0b61f54c8ec62abb04d7cd875808f80fb078933490af9db7082b8bc6b88a4f3a1855e266c1aefbd76479516
7
- data.tar.gz: b666bb26b1ffd36d48fd968c6eeb20a137d91abdf807013716b297c3a2ccb1a8166bf2b1968b4dd9a85dbf5a9114212d521f4235c050948c907b300227cc4444
6
+ metadata.gz: 6ef1c062d0d887efcb0d9c0884e43df859d992f65546b16de6d359545c6f0fa92bc0d6d533c6dbca212e5fbdd47b1e3d1cd23e7a91b4af304ed4e95199e8cdb1
7
+ data.tar.gz: 1fe0de2b0c8f722afa9159779973ef9491f007dad2667cd18f2e863128d69c487f7a09801fba1c9bb0c0710c002e84396064d0a3a98c725f43b4d75f006ca907
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- usps-imis-api (0.6.5)
4
+ usps-imis-api (0.6.6)
5
5
  activesupport (~> 8.0)
6
6
 
7
7
  GEM
@@ -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', { '$type' => 'System.Int32', '$value' => data[:ordinal] } if data[: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.strftime('%Y-%m-%dT%H:%I:%S')
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'
@@ -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', { '$type' => 'System.Int32', '$value' => data[:ordinal] } if data[: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', { '$type' => 'System.Int32', '$value' => data[:count] }
24
+ property 'Quantity', data[:count]
25
25
  property 'Thru_Date', "#{data[:year]}-12-31T00:00:00"
26
- property 'Transaction_Date', Time.now.strftime('%Y-%m-%dT%H:%M:%S')
26
+ property 'Transaction_Date', Time.now
27
27
  end
28
28
  end
29
29
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.6.5'
5
+ VERSION = '0.6.6'
6
6
  end
7
7
  end
@@ -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
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.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander