usps-imis-api 0.6.7 → 0.6.9
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/Readme.md +1 -1
- data/lib/usps/imis/panel/base_panel.rb +1 -1
- data/lib/usps/imis/properties.rb +50 -0
- data/lib/usps/imis/version.rb +1 -1
- data/lib/usps/imis.rb +1 -1
- data/spec/lib/usps/imis/{panel/panel_properties_spec.rb → properties_spec.rb} +4 -4
- metadata +3 -3
- data/lib/usps/imis/panel/panel_properties.rb +0 -52
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 95cf7f953251bafc2de9622adb504b164b64560f6d069f7d2f43add89d138fc6
|
|
4
|
+
data.tar.gz: 10f98facbfe76b78203c6afab20bd4ec1fbe83217a89c582bc28c45942e757a4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5921548e9fa41787c2b28a2ab7310afb02d8f4379369974e6165c2af3adc4a92b10e0753448e54bb01232de61114b203e277f36db1133df744c57a2fbcc1bc98
|
|
7
|
+
data.tar.gz: 9a6247a5ddee4672e2fb116e4b18ccff763130d92816e85e228c6a1bdcf7d41ad71df6f504ebebba457741a7ec8d86c1accee105ead4261c5f62a0c06b061885
|
data/Gemfile.lock
CHANGED
data/Readme.md
CHANGED
|
@@ -94,7 +94,7 @@ module Usps
|
|
|
94
94
|
|
|
95
95
|
def identity_type = 'System.Collections.ObjectModel.Collection`1[[System.String, mscorlib]], mscorlib'
|
|
96
96
|
|
|
97
|
-
def build_payload(data, &) = payload_header(data).merge(
|
|
97
|
+
def build_payload(data, &) = payload_header(data).merge(Properties.build(&))
|
|
98
98
|
end
|
|
99
99
|
end
|
|
100
100
|
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps
|
|
4
|
+
module Imis
|
|
5
|
+
# Constructor for the Properties field
|
|
6
|
+
#
|
|
7
|
+
class Properties
|
|
8
|
+
# Build the data for a new Properties field
|
|
9
|
+
#
|
|
10
|
+
def self.build(&) = new.build(&)
|
|
11
|
+
|
|
12
|
+
# Build the data for the Properties field
|
|
13
|
+
#
|
|
14
|
+
def build
|
|
15
|
+
yield(self)
|
|
16
|
+
|
|
17
|
+
{
|
|
18
|
+
'Properties' => {
|
|
19
|
+
'$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyDataCollection, Asi.Contracts',
|
|
20
|
+
'$values' => @properties
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Add an individual property to the field
|
|
26
|
+
#
|
|
27
|
+
def add(name, value)
|
|
28
|
+
@properties ||= []
|
|
29
|
+
@properties << {
|
|
30
|
+
'$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts',
|
|
31
|
+
'Name' => name,
|
|
32
|
+
'Value' => wrap(value)
|
|
33
|
+
}
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def wrap(value)
|
|
39
|
+
case value
|
|
40
|
+
when String then value
|
|
41
|
+
when Time, DateTime then value.strftime('%Y-%m-%dT%H:%I:%S')
|
|
42
|
+
when Integer then { '$type' => 'System.Int32', '$value' => value }
|
|
43
|
+
when true, false then { '$type' => 'System.Boolean', '$value' => value }
|
|
44
|
+
else
|
|
45
|
+
raise Error::ApiError, "Unexpected property type: #{value.inspect}"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
data/lib/usps/imis/version.rb
CHANGED
data/lib/usps/imis.rb
CHANGED
|
@@ -22,8 +22,8 @@ require_relative 'imis/requests'
|
|
|
22
22
|
require_relative 'imis/business_object'
|
|
23
23
|
require_relative 'imis/api'
|
|
24
24
|
require_relative 'imis/mapper'
|
|
25
|
+
require_relative 'imis/properties'
|
|
25
26
|
require_relative 'imis/panel/base_panel'
|
|
26
|
-
require_relative 'imis/panel/panel_properties'
|
|
27
27
|
require_relative 'imis/panel/vsc'
|
|
28
28
|
require_relative 'imis/panel/education'
|
|
29
29
|
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
|
-
describe Usps::Imis::
|
|
5
|
+
describe Usps::Imis::Properties do
|
|
6
6
|
let(:builder) { described_class.new }
|
|
7
7
|
|
|
8
|
-
it '
|
|
9
|
-
expect(builder.send(:
|
|
8
|
+
it 'wraps boolean property values' do
|
|
9
|
+
expect(builder.send(:wrap, true)).to eq(
|
|
10
10
|
'$type' => 'System.Boolean', '$value' => true
|
|
11
11
|
)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
it 'raises an error for unexpected property types' do
|
|
15
|
-
expect { builder.send(:
|
|
15
|
+
expect { builder.send(:wrap, {}) }.to raise_error(
|
|
16
16
|
Usps::Imis::Error::ApiError, 'Unexpected property type: {}'
|
|
17
17
|
)
|
|
18
18
|
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.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Julian Fiander
|
|
@@ -52,8 +52,8 @@ 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
|
|
56
55
|
- lib/usps/imis/panel/vsc.rb
|
|
56
|
+
- lib/usps/imis/properties.rb
|
|
57
57
|
- lib/usps/imis/requests.rb
|
|
58
58
|
- lib/usps/imis/version.rb
|
|
59
59
|
- spec/lib/usps/imis/api_spec.rb
|
|
@@ -64,8 +64,8 @@ files:
|
|
|
64
64
|
- spec/lib/usps/imis/mapper_spec.rb
|
|
65
65
|
- spec/lib/usps/imis/panel/base_panel_spec.rb
|
|
66
66
|
- spec/lib/usps/imis/panel/education_spec.rb
|
|
67
|
-
- spec/lib/usps/imis/panel/panel_properties_spec.rb
|
|
68
67
|
- spec/lib/usps/imis/panel/vsc_spec.rb
|
|
68
|
+
- spec/lib/usps/imis/properties_spec.rb
|
|
69
69
|
- spec/lib/usps/imis_spec.rb
|
|
70
70
|
- spec/spec_helper.rb
|
|
71
71
|
- usps-imis-api.gemspec
|
|
@@ -1,52 +0,0 @@
|
|
|
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
|