usps-imis-api 0.11.26 → 0.11.27
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/lib/usps/imis/blank_object.rb +62 -0
- data/lib/usps/imis/business_object.rb +11 -1
- data/lib/usps/imis/panels/base_panel.rb +13 -47
- data/lib/usps/imis/panels/education.rb +2 -6
- data/lib/usps/imis/panels/vsc.rb +2 -6
- data/lib/usps/imis/properties.rb +13 -3
- data/lib/usps/imis/version.rb +1 -1
- data/lib/usps/imis.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0c955b3a9fbb3332402a055df4c362098cdfb48ccdab24b68d12a11b5400e04d
|
|
4
|
+
data.tar.gz: f5bf791f4fcc5c69f65bdef290f2342537d2b4d0afec5ba9a5a02366dde68d4e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 58459a3b0ecfd22e76e14499767e6fa056eed31a1bbc95c2c84dc97936feb62791df4e4f43b5ac395ec0bfb1f639d51db69e1d3fe439a58c819d661704ac4588
|
|
7
|
+
data.tar.gz: ea91b6a28f59ca29b28a4676367b0b65288e2f4903ab2833a24aa0135f1e90fe305ffab8fe3ba6cd918d1338235ced2d49da4f3a478e9f2cd5511bec9484e676
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'requests'
|
|
4
|
+
require_relative 'data'
|
|
5
|
+
require_relative 'party_data'
|
|
6
|
+
|
|
7
|
+
module Usps
|
|
8
|
+
module Imis
|
|
9
|
+
# Constructor for blank BusinessObject and BasePanel objects
|
|
10
|
+
#
|
|
11
|
+
class BlankObject
|
|
12
|
+
# The parent object
|
|
13
|
+
#
|
|
14
|
+
attr_reader :parent
|
|
15
|
+
|
|
16
|
+
def initialize(parent, ordinal = nil)
|
|
17
|
+
@parent = parent
|
|
18
|
+
@ordinal = ordinal
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Build a blank object for the current iMIS ID
|
|
22
|
+
#
|
|
23
|
+
def build(&) = payload_header.merge(Properties.build(parent.api.imis_id.to_s, @ordinal.to_s, &))
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def identity_type = 'System.Collections.ObjectModel.Collection`1[[System.String, mscorlib]], mscorlib'
|
|
28
|
+
|
|
29
|
+
def payload_header
|
|
30
|
+
{
|
|
31
|
+
'$type' => 'Asi.Soa.Core.DataContracts.GenericEntityData, Asi.Contracts',
|
|
32
|
+
'EntityTypeName' => parent.business_object_name,
|
|
33
|
+
'PrimaryParentEntityTypeName' => 'Party',
|
|
34
|
+
'Identity' => identity,
|
|
35
|
+
'PrimaryParentIdentity' => primary_parent_identity
|
|
36
|
+
}
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def identity
|
|
40
|
+
{
|
|
41
|
+
'$type' => 'Asi.Soa.Core.DataContracts.IdentityData, Asi.Contracts',
|
|
42
|
+
'EntityTypeName' => parent.business_object_name,
|
|
43
|
+
'IdentityElements' => {
|
|
44
|
+
'$type' => identity_type,
|
|
45
|
+
'$values' => [parent.api.imis_id.to_s, @ordinal&.to_s].compact
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def primary_parent_identity
|
|
51
|
+
{
|
|
52
|
+
'$type' => 'Asi.Soa.Core.DataContracts.IdentityData, Asi.Contracts',
|
|
53
|
+
'EntityTypeName' => 'Party',
|
|
54
|
+
'IdentityElements' => {
|
|
55
|
+
'$type' => identity_type,
|
|
56
|
+
'$values' => [parent.api.imis_id.to_s]
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -6,7 +6,8 @@ require_relative 'party_data'
|
|
|
6
6
|
|
|
7
7
|
module Usps
|
|
8
8
|
module Imis
|
|
9
|
-
#
|
|
9
|
+
# Configured accessor for a specific Business Object
|
|
10
|
+
#
|
|
10
11
|
class BusinessObject
|
|
11
12
|
include Requests
|
|
12
13
|
|
|
@@ -136,6 +137,15 @@ module Usps
|
|
|
136
137
|
def delete = submit(uri, authorize(http_delete)).body == '' # rubocop:disable Naming/PredicateMethod
|
|
137
138
|
alias destroy delete
|
|
138
139
|
|
|
140
|
+
# Build a blank object for the current iMIS ID
|
|
141
|
+
#
|
|
142
|
+
def blank_object(&) = BlankObject.new(self).build(&)
|
|
143
|
+
|
|
144
|
+
# Create a business object for the current member, starting with a blank object and building properties
|
|
145
|
+
#
|
|
146
|
+
def post_from_blank(&) = post(blank_object(&))
|
|
147
|
+
alias create_from_blank post_from_blank
|
|
148
|
+
|
|
139
149
|
# Ruby 3.5 instance variable filter
|
|
140
150
|
#
|
|
141
151
|
def instance_variables_to_inspect = instance_variables - %i[@api @logger]
|
|
@@ -30,7 +30,7 @@ module Usps
|
|
|
30
30
|
#
|
|
31
31
|
# @return [Usps::Imis::Data, Array<Usps::Imis::Data>] Response data from the API
|
|
32
32
|
#
|
|
33
|
-
def get(ordinal, *fields) = api.on(
|
|
33
|
+
def get(ordinal, *fields) = api.on(business_object_name, ordinal:).get(*fields)
|
|
34
34
|
alias read get
|
|
35
35
|
|
|
36
36
|
# Get a single named field from a Panel for the current member
|
|
@@ -40,7 +40,7 @@ module Usps
|
|
|
40
40
|
#
|
|
41
41
|
# @return Response data field value from the API
|
|
42
42
|
#
|
|
43
|
-
def get_field(ordinal, field) = api.on(
|
|
43
|
+
def get_field(ordinal, field) = api.on(business_object_name, ordinal:).get_field(field)
|
|
44
44
|
alias fetch get_field
|
|
45
45
|
alias [] get_field
|
|
46
46
|
|
|
@@ -51,7 +51,7 @@ module Usps
|
|
|
51
51
|
#
|
|
52
52
|
# @return [Array] Response data from the API
|
|
53
53
|
#
|
|
54
|
-
def get_fields(ordinal, *fields) = api.on(
|
|
54
|
+
def get_fields(ordinal, *fields) = api.on(business_object_name, ordinal:).get_fields(*fields)
|
|
55
55
|
alias fetch_all get_fields
|
|
56
56
|
|
|
57
57
|
# Update a single named field on a business object for the current member
|
|
@@ -62,7 +62,7 @@ module Usps
|
|
|
62
62
|
#
|
|
63
63
|
# @return [Usps::Imis::Data] Response data from the API
|
|
64
64
|
#
|
|
65
|
-
def put_field(ordinal, field, value) = api.on(
|
|
65
|
+
def put_field(ordinal, field, value) = api.on(business_object_name, ordinal:).put_field(field, value)
|
|
66
66
|
alias []= put_field
|
|
67
67
|
|
|
68
68
|
# Update only specific fields on a Panel for the current member
|
|
@@ -72,7 +72,7 @@ module Usps
|
|
|
72
72
|
#
|
|
73
73
|
# @return [Usps::Imis::Data] Response data from the API
|
|
74
74
|
#
|
|
75
|
-
def put_fields(ordinal, fields) = api.on(
|
|
75
|
+
def put_fields(ordinal, fields) = api.on(business_object_name, ordinal:).put_fields(fields)
|
|
76
76
|
alias patch put_fields
|
|
77
77
|
|
|
78
78
|
# Update an existing object in the Panel
|
|
@@ -82,7 +82,7 @@ module Usps
|
|
|
82
82
|
#
|
|
83
83
|
# @return [Usps::Imis::Data] Response data from the API
|
|
84
84
|
#
|
|
85
|
-
def put(data) = api.on(
|
|
85
|
+
def put(data) = api.on(business_object_name, ordinal: data[:ordinal]).put(payload(data))
|
|
86
86
|
alias update put
|
|
87
87
|
|
|
88
88
|
# Create a new object in the Panel
|
|
@@ -91,7 +91,7 @@ module Usps
|
|
|
91
91
|
#
|
|
92
92
|
# @return [Usps::Imis::Data] Response data from the API
|
|
93
93
|
#
|
|
94
|
-
def post(data) = api.on(
|
|
94
|
+
def post(data) = api.on(business_object_name).post(payload(data))
|
|
95
95
|
alias create post
|
|
96
96
|
|
|
97
97
|
# Remove a specific object from the Panel
|
|
@@ -100,58 +100,24 @@ module Usps
|
|
|
100
100
|
#
|
|
101
101
|
# @return [true] Only on success response (i.e. blank string from the API)
|
|
102
102
|
#
|
|
103
|
-
def delete(ordinal) = api.on(
|
|
103
|
+
def delete(ordinal) = api.on(business_object_name, ordinal:).delete
|
|
104
104
|
alias destroy delete
|
|
105
105
|
|
|
106
|
+
def business_object_name
|
|
107
|
+
raise Errors::PanelUnimplementedError.from(self.class.name, 'business_object_name')
|
|
108
|
+
end
|
|
109
|
+
|
|
106
110
|
# Ruby 3.5 instance variable filter
|
|
107
111
|
#
|
|
108
112
|
def instance_variables_to_inspect = instance_variables - %i[@api @logger]
|
|
109
113
|
|
|
110
114
|
private
|
|
111
115
|
|
|
112
|
-
def business_object
|
|
113
|
-
raise Errors::PanelUnimplementedError.from(self.class.name, 'business_object')
|
|
114
|
-
end
|
|
115
|
-
|
|
116
116
|
def payload(_data)
|
|
117
117
|
raise Errors::PanelUnimplementedError.from(self.class.name, 'payload(data)')
|
|
118
118
|
end
|
|
119
119
|
|
|
120
|
-
def
|
|
121
|
-
{
|
|
122
|
-
'$type' => 'Asi.Soa.Core.DataContracts.GenericEntityData, Asi.Contracts',
|
|
123
|
-
'EntityTypeName' => business_object,
|
|
124
|
-
'PrimaryParentEntityTypeName' => 'Party',
|
|
125
|
-
'Identity' => identity(data[:ordinal]),
|
|
126
|
-
'PrimaryParentIdentity' => primary_parent_identity
|
|
127
|
-
}
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
def identity(ordinal = nil)
|
|
131
|
-
{
|
|
132
|
-
'$type' => 'Asi.Soa.Core.DataContracts.IdentityData, Asi.Contracts',
|
|
133
|
-
'EntityTypeName' => business_object,
|
|
134
|
-
'IdentityElements' => {
|
|
135
|
-
'$type' => identity_type,
|
|
136
|
-
'$values' => [api.imis_id.to_s, ordinal&.to_s].compact
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
def primary_parent_identity
|
|
142
|
-
{
|
|
143
|
-
'$type' => 'Asi.Soa.Core.DataContracts.IdentityData, Asi.Contracts',
|
|
144
|
-
'EntityTypeName' => 'Party',
|
|
145
|
-
'IdentityElements' => {
|
|
146
|
-
'$type' => identity_type,
|
|
147
|
-
'$values' => [api.imis_id.to_s]
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def identity_type = 'System.Collections.ObjectModel.Collection`1[[System.String, mscorlib]], mscorlib'
|
|
153
|
-
|
|
154
|
-
def build_payload(data, &) = payload_header(data).merge(Properties.build(&))
|
|
120
|
+
def build_payload(data, &) = BlankObject.new(self, data[:ordinal]).build(&)
|
|
155
121
|
end
|
|
156
122
|
end
|
|
157
123
|
end
|
|
@@ -6,16 +6,12 @@ module Usps
|
|
|
6
6
|
# Panel for accessing the Educational completions business object
|
|
7
7
|
#
|
|
8
8
|
class Education < BasePanel
|
|
9
|
-
|
|
9
|
+
def business_object_name = 'ABC_ASC_Educ'
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
'ABC_ASC_Educ'
|
|
13
|
-
end
|
|
11
|
+
private
|
|
14
12
|
|
|
15
13
|
def payload(data)
|
|
16
14
|
build_payload(data) do |props|
|
|
17
|
-
props.add 'ID', api.imis_id.to_s
|
|
18
|
-
props.add 'Ordinal', data[:ordinal] if data[:ordinal]
|
|
19
15
|
props.add 'ABC_EDUC_THRU_DATE', data[:thru_date] || '0001-01-01T00:00:00'
|
|
20
16
|
props.add 'ABC_ECertificate', data[:certificate]
|
|
21
17
|
props.add 'ABC_Educ_Description', data[:description]
|
data/lib/usps/imis/panels/vsc.rb
CHANGED
|
@@ -6,16 +6,12 @@ module Usps
|
|
|
6
6
|
# Panel for accessing the annual VSC completed counts business object
|
|
7
7
|
#
|
|
8
8
|
class Vsc < BasePanel
|
|
9
|
-
|
|
9
|
+
def business_object_name = 'ABC_ASC_Vessel_Safety_Checks'
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
'ABC_ASC_Vessel_Safety_Checks'
|
|
13
|
-
end
|
|
11
|
+
private
|
|
14
12
|
|
|
15
13
|
def payload(data)
|
|
16
14
|
build_payload(data) do |props|
|
|
17
|
-
props.add 'ID', api.imis_id.to_s
|
|
18
|
-
props.add 'Ordinal', data[:ordinal] if data[:ordinal]
|
|
19
15
|
props.add 'Source_System', 'Manual ITCom Entry'
|
|
20
16
|
props.add 'ABC_ECertificate', data[:certificate]
|
|
21
17
|
props.add 'Activity_Type', 'VSC'
|
data/lib/usps/imis/properties.rb
CHANGED
|
@@ -7,7 +7,10 @@ module Usps
|
|
|
7
7
|
class Properties
|
|
8
8
|
# Build the data for a new Properties field
|
|
9
9
|
#
|
|
10
|
-
|
|
10
|
+
# @param id [String] iMIS ID to include in the properties before running the block
|
|
11
|
+
# @param ordinal [String] Ordinal to include in the properties before running the block
|
|
12
|
+
#
|
|
13
|
+
def self.build(id = nil, ordinal = nil, &) = new.build(id, ordinal, &)
|
|
11
14
|
|
|
12
15
|
# Wrap value in the API-internal type structure
|
|
13
16
|
#
|
|
@@ -24,7 +27,15 @@ module Usps
|
|
|
24
27
|
|
|
25
28
|
# Build the data for the Properties field
|
|
26
29
|
#
|
|
27
|
-
|
|
30
|
+
# @param id [String] iMIS ID to include in the properties before running the block
|
|
31
|
+
# @param ordinal [String] Ordinal to include in the properties before running the block
|
|
32
|
+
#
|
|
33
|
+
def build(id = nil, ordinal = nil)
|
|
34
|
+
@properties ||= []
|
|
35
|
+
|
|
36
|
+
add('ID', id) if id
|
|
37
|
+
add('Ordinal', ordinal) if ordinal
|
|
38
|
+
|
|
28
39
|
yield(self)
|
|
29
40
|
|
|
30
41
|
{
|
|
@@ -38,7 +49,6 @@ module Usps
|
|
|
38
49
|
# Add an individual property to the field
|
|
39
50
|
#
|
|
40
51
|
def add(name, value)
|
|
41
|
-
@properties ||= []
|
|
42
52
|
@properties << {
|
|
43
53
|
'$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts',
|
|
44
54
|
'Name' => name,
|
data/lib/usps/imis/version.rb
CHANGED
data/lib/usps/imis.rb
CHANGED
|
@@ -22,6 +22,7 @@ require_relative 'imis/config'
|
|
|
22
22
|
require_relative 'imis/error'
|
|
23
23
|
require_relative 'imis/api'
|
|
24
24
|
require_relative 'imis/properties'
|
|
25
|
+
require_relative 'imis/blank_object'
|
|
25
26
|
require_relative 'imis/panels'
|
|
26
27
|
require_relative 'imis/mocks'
|
|
27
28
|
require_relative 'imis/version'
|
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.11.
|
|
4
|
+
version: 0.11.27
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Julian Fiander
|
|
@@ -77,6 +77,7 @@ files:
|
|
|
77
77
|
- lib/usps/imis.rb
|
|
78
78
|
- lib/usps/imis/api.rb
|
|
79
79
|
- lib/usps/imis/base_data.rb
|
|
80
|
+
- lib/usps/imis/blank_object.rb
|
|
80
81
|
- lib/usps/imis/business_object.rb
|
|
81
82
|
- lib/usps/imis/command_line.rb
|
|
82
83
|
- lib/usps/imis/command_line/interface.rb
|