usps-imis-api 0.6.8 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81e2ba39cba54049cb049ddaa01817fe51e0e1212768359b0a0d5151b7de23f6
4
- data.tar.gz: fcd351bc3eb4ed7325ebb35a74e9609e1437c5c63219ae679a5da036a71c496d
3
+ metadata.gz: 95cf7f953251bafc2de9622adb504b164b64560f6d069f7d2f43add89d138fc6
4
+ data.tar.gz: 10f98facbfe76b78203c6afab20bd4ec1fbe83217a89c582bc28c45942e757a4
5
5
  SHA512:
6
- metadata.gz: 1678dd35cf80cf95741ced1140eb208358f1ccf4ae2ec2da8af5e518feacba53acbf27c3e3afa61d26265bc1f459eb77c7c55b67ad0afefa1f19b35f0f1a314f
7
- data.tar.gz: 4498ecff60bc76446b2e053e9908cadbe2f9a1f095eda8d4d1bcdfca916d9bc2a113d2ee4740faff730547426527ad965ef8e1a44e21fcfe1d0fb1dd975f7798
6
+ metadata.gz: 5921548e9fa41787c2b28a2ab7310afb02d8f4379369974e6165c2af3adc4a92b10e0753448e54bb01232de61114b203e277f36db1133df744c57a2fbcc1bc98
7
+ data.tar.gz: 9a6247a5ddee4672e2fb116e4b18ccff763130d92816e85e228c6a1bdcf7d41ad71df6f504ebebba457741a7ec8d86c1accee105ead4261c5f62a0c06b061885
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- usps-imis-api (0.6.8)
4
+ usps-imis-api (0.6.9)
5
5
  activesupport (~> 8.0)
6
6
 
7
7
  GEM
@@ -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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.6.8'
5
+ VERSION = '0.6.9'
6
6
  end
7
7
  end
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/properties'
27
27
  require_relative 'imis/panel/vsc'
28
28
  require_relative 'imis/panel/education'
29
29
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Usps::Imis::Panel::Properties do
5
+ describe Usps::Imis::Properties do
6
6
  let(:builder) { described_class.new }
7
7
 
8
8
  it 'wraps boolean property values' do
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.8
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/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/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 Properties
9
- # Build the data for a new Properties field
10
- #
11
- def self.build(&) = new.build(&)
12
-
13
- # Build the data for 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' => wrap(value)
34
- }
35
- end
36
-
37
- private
38
-
39
- def wrap(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