usps-imis-api 0.6.13 → 0.6.14
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 +2 -2
- data/lib/usps/imis/business_object.rb +18 -9
- data/lib/usps/imis/panel/base_panel.rb +34 -6
- data/lib/usps/imis/version.rb +1 -1
- data/spec/lib/usps/imis/panel/education_spec.rb +13 -1
- 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: 05b1b663fab7b4f81c95f105c0c7f667bc2f5b9855b5fd48e5f384ce0adba8dc
|
|
4
|
+
data.tar.gz: '02529c44a577d5e239b3bd306cec0f9f91e53413ef3d921c5564352e8dca3d5f'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e81f01c677aa5a22b1c7c5cfeb6e3119cc1f4387dc2076fec0001032879378f5be3cd562c3ccdd689a5e26e7becb4381a891249c175b025014d78638a36dd03e
|
|
7
|
+
data.tar.gz: 3e3f53303d8316f814cefffb3473ccb8e91c5fbd5146bc94b1701532c006fbf8b0ab905a156bd880e3fe6a2f1c2c4f79528c591df8b6ad6e26cb8cee7ab88346
|
data/Gemfile.lock
CHANGED
data/Readme.md
CHANGED
|
@@ -216,9 +216,9 @@ previous value.
|
|
|
216
216
|
api.with(31092) do
|
|
217
217
|
# These requests are identical:
|
|
218
218
|
|
|
219
|
-
on('ABC_ASC_Individual_Demog') {
|
|
219
|
+
on('ABC_ASC_Individual_Demog') { put_fields('TotMMS' => 15) }
|
|
220
220
|
|
|
221
|
-
on('ABC_ASC_Individual_Demog').
|
|
221
|
+
on('ABC_ASC_Individual_Demog').put_fields('TotMMS' => 15)
|
|
222
222
|
|
|
223
223
|
mapper.update(mm: 15)
|
|
224
224
|
|
|
@@ -39,6 +39,7 @@ module Usps
|
|
|
39
39
|
result = submit(uri, authorize(request))
|
|
40
40
|
JSON.parse(result.body)
|
|
41
41
|
end
|
|
42
|
+
alias read get
|
|
42
43
|
|
|
43
44
|
# Get a single named field from a business object for the current member
|
|
44
45
|
#
|
|
@@ -52,6 +53,7 @@ module Usps
|
|
|
52
53
|
|
|
53
54
|
value.is_a?(String) ? value : value['$value']
|
|
54
55
|
end
|
|
56
|
+
alias fetch get_field
|
|
55
57
|
|
|
56
58
|
# Update only specific fields on a business object for the current member
|
|
57
59
|
#
|
|
@@ -63,6 +65,7 @@ module Usps
|
|
|
63
65
|
updated = filter_fields(fields)
|
|
64
66
|
put(updated)
|
|
65
67
|
end
|
|
68
|
+
alias patch put_fields
|
|
66
69
|
|
|
67
70
|
# Update a business object for the current member
|
|
68
71
|
#
|
|
@@ -76,6 +79,7 @@ module Usps
|
|
|
76
79
|
result = submit(uri, authorize(request))
|
|
77
80
|
JSON.parse(result.body)
|
|
78
81
|
end
|
|
82
|
+
alias update put
|
|
79
83
|
|
|
80
84
|
# Create a business object for the current member
|
|
81
85
|
#
|
|
@@ -89,6 +93,7 @@ module Usps
|
|
|
89
93
|
result = submit(uri, authorize(request))
|
|
90
94
|
JSON.parse(result.body)
|
|
91
95
|
end
|
|
96
|
+
alias create post
|
|
92
97
|
|
|
93
98
|
# Remove a business object for the current member
|
|
94
99
|
#
|
|
@@ -99,6 +104,7 @@ module Usps
|
|
|
99
104
|
result = submit(uri, authorize(request))
|
|
100
105
|
result.body
|
|
101
106
|
end
|
|
107
|
+
alias destroy delete
|
|
102
108
|
|
|
103
109
|
private
|
|
104
110
|
|
|
@@ -127,19 +133,22 @@ module Usps
|
|
|
127
133
|
existing = get
|
|
128
134
|
|
|
129
135
|
JSON.parse(JSON.dump(existing)).tap do |updated|
|
|
136
|
+
# Wipe the array on the duped object
|
|
137
|
+
#
|
|
130
138
|
# The first property is always the iMIS ID again
|
|
131
|
-
|
|
139
|
+
#
|
|
140
|
+
updated['Properties']['$values'] = []
|
|
132
141
|
|
|
133
142
|
# Iterate through all existing fields
|
|
134
143
|
existing['Properties']['$values'].each do |value|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
144
|
+
if fields.keys.include?(value['Name'])
|
|
145
|
+
# Strings are not wrapped in the type definition structure
|
|
146
|
+
new_value = fields[value['Name']]
|
|
147
|
+
if new_value.is_a?(String)
|
|
148
|
+
value['Value'] = new_value
|
|
149
|
+
else
|
|
150
|
+
value['Value']['$value'] = new_value
|
|
151
|
+
end
|
|
143
152
|
end
|
|
144
153
|
|
|
145
154
|
# Add the completed field with the updated value
|
|
@@ -22,31 +22,59 @@ module Usps
|
|
|
22
22
|
def get(ordinal)
|
|
23
23
|
api.on(business_object, ordinal:).get
|
|
24
24
|
end
|
|
25
|
+
alias read get
|
|
25
26
|
|
|
26
|
-
#
|
|
27
|
+
# Get a single named field from a Panel for the current member
|
|
27
28
|
#
|
|
28
|
-
# @param
|
|
29
|
+
# @param ordinal [Integer] The ordinal identifier for the desired object
|
|
30
|
+
# @param name [String] Field name to return
|
|
29
31
|
#
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
# @return [Hash] Response data from the API
|
|
33
|
+
#
|
|
34
|
+
def get_field(ordinal, name)
|
|
35
|
+
api.on(business_object, ordinal:).get_field(name)
|
|
36
|
+
end
|
|
37
|
+
alias fetch get_field
|
|
38
|
+
|
|
39
|
+
# Update only specific fields on a Panel for the current member
|
|
40
|
+
#
|
|
41
|
+
# @param ordinal [Integer] The ordinal identifier for the desired object
|
|
42
|
+
# @param fields [Hash] Conforms to pattern +{ field_key => value }+
|
|
43
|
+
#
|
|
44
|
+
# @return [Hash] Response data from the API
|
|
45
|
+
#
|
|
46
|
+
def put_fields(ordinal, fields)
|
|
47
|
+
api.on(business_object, ordinal:).put_fields(fields)
|
|
32
48
|
end
|
|
49
|
+
alias patch put_fields
|
|
33
50
|
|
|
34
51
|
# Update an existing object in the Panel
|
|
35
52
|
#
|
|
36
53
|
# @param data [Hash] The record data for the desired object -- including the required
|
|
37
54
|
# +ordinal+ identifier
|
|
38
55
|
#
|
|
39
|
-
def
|
|
56
|
+
def put(data)
|
|
40
57
|
api.on(business_object, ordinal: data[:ordinal]).put(payload(data))
|
|
41
58
|
end
|
|
59
|
+
alias update put
|
|
60
|
+
|
|
61
|
+
# Create a new object in the Panel
|
|
62
|
+
#
|
|
63
|
+
# @param data [Hash] The record data for the desired object
|
|
64
|
+
#
|
|
65
|
+
def post(data)
|
|
66
|
+
api.on(business_object).post(payload(data))
|
|
67
|
+
end
|
|
68
|
+
alias create post
|
|
42
69
|
|
|
43
70
|
# Remove a specific object from the Panel
|
|
44
71
|
#
|
|
45
72
|
# @param ordinal [Integer] The ordinal identifier for the desired object
|
|
46
73
|
#
|
|
47
|
-
def
|
|
74
|
+
def delete(ordinal)
|
|
48
75
|
api.on(business_object, ordinal:).delete
|
|
49
76
|
end
|
|
77
|
+
alias destroy delete
|
|
50
78
|
|
|
51
79
|
private
|
|
52
80
|
|
data/lib/usps/imis/version.rb
CHANGED
|
@@ -26,8 +26,14 @@ describe Usps::Imis::Panel::Education do
|
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
+
describe '#get_field' do
|
|
30
|
+
it 'returns a specific field' do
|
|
31
|
+
expect(education.get_field(90737, 'ABC_Product_Code')).to eq('CRS')
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
29
35
|
# rubocop:disable RSpec/ExampleLength
|
|
30
|
-
it '
|
|
36
|
+
it 'interacts with records correctly', :aggregate_failures do
|
|
31
37
|
new_record = education.create(details)
|
|
32
38
|
expect(new_record).to be_a(Hash)
|
|
33
39
|
|
|
@@ -40,6 +46,12 @@ describe Usps::Imis::Panel::Education do
|
|
|
40
46
|
end
|
|
41
47
|
expect(updated['Value']).to eq('Online Exams System - Modified')
|
|
42
48
|
|
|
49
|
+
put_fields_result = education.put_fields(ordinal, 'ABC_Educ_Source_System' => 'Online Exams System - Mod2')
|
|
50
|
+
patched = put_fields_result['Properties']['$values'].find do |v|
|
|
51
|
+
v['Name'] == 'ABC_Educ_Source_System'
|
|
52
|
+
end
|
|
53
|
+
expect(patched['Value']).to eq('Online Exams System - Mod2')
|
|
54
|
+
|
|
43
55
|
expect(education.destroy(ordinal)).to eq('')
|
|
44
56
|
end
|
|
45
57
|
# rubocop:enable RSpec/ExampleLength
|