usps-imis-api 0.7.0 → 0.8.0

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: bc6237ee6d52c0fdfc8cd33809a90600b68a19926490facab194e751b8c983d3
4
- data.tar.gz: f66d10f8a53e2df13e42a96fec6a4fc2cb61d798f80dbe7ddc88cf2f84418277
3
+ metadata.gz: 0e1d3316b4676bae03e67aa927632ec91801a6d703c55049c1b11013a20c3e08
4
+ data.tar.gz: 8199c664875cc57e995d73b3a96ce03cd9de2e5460e7a451553df3bb5ca3ff84
5
5
  SHA512:
6
- metadata.gz: 16b7a7e05c2fa1cb5d3e2de1604a4a06e5d551a650f7ee451662afa7f43b2b1917f0be04a2c3d4af063a18c0b22515d304bcc25afca79e9214e76542d3b39438
7
- data.tar.gz: bfe78effec93b84b65963c54decb29ae114e10231e537ad216d1c3d2b250348474efeb0bd20b5f5759a7b6440eca6b28660a10c94d617c90fa70708c1c85727e
6
+ metadata.gz: 7015ffe22161d1645959004798ed1fde3e65a66db6695dac75ae84db13177a376a37b083f74abdd9092108ba33d9d0f09fcbaaaa845d861d50af237c77c819b2
7
+ data.tar.gz: 940e05eeeeea390c67e207f4ace40c6befed6dbe355efdc38e3fa6d270c35f6bf5c48c3093808c505c2b26e9f452000ecd384e250451bc8263cce84d43a78238
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- usps-imis-api (0.7.0)
4
+ usps-imis-api (0.8.0)
5
5
  activesupport (~> 8.0)
6
6
 
7
7
  GEM
data/Readme.md CHANGED
@@ -77,6 +77,10 @@ You can also manually set the current ID, if you already have it for a given mem
77
77
  api.imis_id = imis_id
78
78
  ```
79
79
 
80
+ #### Without an iMIS ID
81
+
82
+ Running requests without an iMIS ID set will result in query results returned from the API.
83
+
80
84
  ### Business Object and Panel Actions
81
85
 
82
86
  Business Objects and Panels support the following actions.
@@ -91,6 +95,21 @@ To fetch member data, run e.g.:
91
95
  data = api.on('ABC_ASC_Individual_Demog').get
92
96
  ```
93
97
 
98
+ You can also pass in specific field names to filter the returned member data, e.g.:
99
+
100
+ ```ruby
101
+ data = api.on('ABC_ASC_Individual_Demog').get('TotMMS', 'MMS_Updated')
102
+ ```
103
+
104
+ The response from `get` behaves like a Hash, but directly accesses property values by name.
105
+ If you need to access the rest of the underlying data, use the `raw` method:
106
+
107
+ ```ruby
108
+ data = api.on('ABC_ASC_Individual_Demog').get
109
+ data['TotMMS']
110
+ data.raw['EntityTypeName']
111
+ ```
112
+
94
113
  Alias: `read`
95
114
 
96
115
  #### GET Field
@@ -101,8 +120,24 @@ To fetch a specific field from member data, run e.g.:
101
120
  tot_mms = api.on('ABC_ASC_Individual_Demog').get_field('TotMMS')
102
121
  ```
103
122
 
123
+ You can also access fields directly on the Business Object like a Hash:
124
+
125
+ ```ruby
126
+ tot_mms = api.on('ABC_ASC_Individual_Demog')['TotMMS']
127
+ ```
128
+
104
129
  Alias: `fetch`
105
130
 
131
+ #### GET Fields
132
+
133
+ To fetch multiple specific fields from member data, run e.g.:
134
+
135
+ ```ruby
136
+ data = api.on('ABC_ASC_Individual_Demog').get_fields('TotMMS', 'MMS_Updated')
137
+ ```
138
+
139
+ Alias: `fetch_all`
140
+
106
141
  #### PUT Fields
107
142
 
108
143
  To update member data, run e.g.:
@@ -151,8 +186,6 @@ To remove member data, run e.g.:
151
186
  api.on('ABC_ASC_Individual_Demog').delete
152
187
  ```
153
188
 
154
- This returns a blank string on success.
155
-
156
189
  Alias: `destroy`
157
190
 
158
191
  ### QUERY
@@ -194,11 +227,24 @@ vsc = Usps::Imis::Panels::Vsc.new(imis_id: 6374)
194
227
 
195
228
  vsc.get(1417)
196
229
 
230
+ # All of these options are identical
231
+ #
232
+ vsc.get(1417, 'Quantity')
233
+ vsc.get(1417)['Quantity']
234
+ vsc.get[1417, 'Quantity']
235
+ vsc.get(1417).raw['Properties']['$values'].find { it['Name'] == 'Quantity' }['Value']['$value']
197
236
  vsc.get_field(1417, 'Quantity')
198
237
 
199
238
  created = vsc.create(certificate: 'E136924', year: 2024, count: 42)
200
- ordinal = created['Properties']['$values'].find { it['Name'] == 'Ordinal' }['Value']['$value']
201
- # ordinal = created['Identity']['IdentityElements']['$values'][1] # Alternative
239
+
240
+ # Get the Ordinal identifier from the response
241
+ #
242
+ # All of these options are identical
243
+ #
244
+ ordinal = created.ordinal
245
+ ordinal = created['Ordinal']
246
+ ordinal = created.raw['Properties']['$values'].find { it['Name'] == 'Ordinal' }['Value']['$value']
247
+ ordinal = created.raw['Identity']['IdentityElements']['$values'][1] # Value is duplicated here
202
248
 
203
249
  vsc.update(certificate: 'E136924', year: 2024, count: 43, ordinal: ordinal)
204
250
 
@@ -250,12 +296,18 @@ api.with(31092) do
250
296
  # These requests are identical:
251
297
 
252
298
  on('ABC_ASC_Individual_Demog') do
253
- get['Properties']['$values'].find { it['Name'] == 'TotMMS' }['Value']['$value']
254
- end
299
+ get.raw['Properties']['$values'].find { it['Name'] == 'TotMMS' }['Value']['$value']
300
+
301
+ get['TotMMS']
255
302
 
256
- on('ABC_ASC_Individual_Demog') { get_field('TotMMS') }
303
+ get_field('TotMMS')
304
+
305
+ get_fields('TotMMS').first
306
+ end
257
307
 
258
308
  on('ABC_ASC_Individual_Demog').get_field('TotMMS')
309
+
310
+ on('ABC_ASC_Individual_Demog')['TotMMS']
259
311
  end
260
312
 
261
313
  # This request fetches the same data, but leaves the iMIS ID selected
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'requests'
4
+ require_relative 'data'
4
5
 
5
6
  module Usps
6
7
  module Imis
@@ -34,39 +35,44 @@ module Usps
34
35
 
35
36
  # Get a business object for the current member
36
37
  #
37
- # @return [Hash] Response data from the API
38
+ # If +fields+ is provided, will return only those field values
38
39
  #
39
- def get
40
- request = Net::HTTP::Get.new(uri)
41
- result = submit(uri, authorize(request))
42
- JSON.parse(result.body)
43
- end
40
+ # @param fields [String] Field names to return
41
+ #
42
+ # @return [Usps::Imis::Data, Array<Usps::Imis::Data>] Response data from the API
43
+ #
44
+ def get(*fields) = fields.any? ? get_fields(*fields) : raw_object
44
45
  alias read get
45
46
 
46
47
  # Get a single named field from a business object for the current member
47
48
  #
48
- # @param name [String] Field name to return
49
+ # @param field [String] Field name to return
49
50
  #
50
- # @return [Hash] Response data from the API
51
+ # @return Response data field value from the API
51
52
  #
52
- def get_field(name)
53
- values = get['Properties']['$values']
54
- value = values.find { it['Name'] == name }['Value']
53
+ def get_field(field) = raw_object[field]
54
+ alias fetch get_field
55
+ alias [] get_field
55
56
 
56
- value.is_a?(String) ? value : value['$value']
57
+ # Get named fields from a business object for the current member
58
+ #
59
+ # @param names [Array<String>] Field names to return
60
+ #
61
+ # @return [Array] Response data from the API
62
+ #
63
+ def get_fields(*fields)
64
+ values = raw_object
65
+ fields.map { values[it] }
57
66
  end
58
- alias fetch get_field
67
+ alias fetch_all get_fields
59
68
 
60
69
  # Update only specific fields on a business object for the current member
61
70
  #
62
71
  # @param fields [Hash] Conforms to pattern +{ field_key => value }+
63
72
  #
64
- # @return [Hash] Response data from the API
73
+ # @return [Usps::Imis::Data] Response data from the API
65
74
  #
66
- def put_fields(fields)
67
- updated = filter_fields(fields)
68
- put(updated)
69
- end
75
+ def put_fields(fields) = put(filter_fields(fields))
70
76
  alias patch put_fields
71
77
 
72
78
  # Update a business object for the current member
@@ -75,39 +81,25 @@ module Usps
75
81
  #
76
82
  # @param body [Hash] Full raw API object data
77
83
  #
78
- # @return [Hash] Response data from the API
84
+ # @return [Usps::Imis::Data] Response data from the API
79
85
  #
80
- def put(body)
81
- request = Net::HTTP::Put.new(uri)
82
- request.body = JSON.dump(body)
83
- result = submit(uri, authorize(request))
84
- JSON.parse(result.body)
85
- end
86
+ def put(body) = put_object(Net::HTTP::Put.new(uri), body)
86
87
  alias update put
87
88
 
88
89
  # Create a business object for the current member
89
90
  #
90
91
  # @param body [Hash] Full raw API object data
91
92
  #
92
- # @return [Hash] Response data from the API
93
+ # @return [Usps::Imis::Data] Response data from the API
93
94
  #
94
- def post(body)
95
- request = Net::HTTP::Post.new(uri(id: ''))
96
- request.body = JSON.dump(body)
97
- result = submit(uri, authorize(request))
98
- JSON.parse(result.body)
99
- end
95
+ def post(body) = put_object(Net::HTTP::Post.new(uri(id: '')), body)
100
96
  alias create post
101
97
 
102
98
  # Remove a business object for the current member
103
99
  #
104
- # @return [String] Error response body from the API, or empty string on success
100
+ # @return [true] Only on success response (i.e. blank string from the API)
105
101
  #
106
- def delete
107
- request = Net::HTTP::Delete.new(uri)
108
- result = submit(uri, authorize(request))
109
- result.body
110
- end
102
+ def delete = submit(uri, authorize(Net::HTTP::Delete.new(uri))).body == '' # rubocop:disable Naming/PredicateMethod
111
103
  alias destroy delete
112
104
 
113
105
  private
@@ -139,7 +131,7 @@ module Usps
139
131
  JSON.parse(JSON.dump(existing)).tap do |updated|
140
132
  # Preserve the iMIS ID, as well as the Ordinal (if present)
141
133
  updated['Properties']['$values'], properties =
142
- existing['Properties']['$values'].partition { %w[ID Ordinal].include?(it['Name']) }
134
+ existing.raw['Properties']['$values'].partition { %w[ID Ordinal].include?(it['Name']) }
143
135
 
144
136
  # Iterate through all existing fields
145
137
  properties.each do |value|
@@ -159,6 +151,24 @@ module Usps
159
151
  end
160
152
  end
161
153
  end
154
+
155
+ # Get a raw object response from the API
156
+ #
157
+ # Useful for stubbing data in tests
158
+ #
159
+ def raw_object
160
+ request = Net::HTTP::Get.new(uri)
161
+ result = submit(uri, authorize(request))
162
+ Data.from_json(result.body)
163
+ end
164
+
165
+ # Upload an object to the API
166
+ #
167
+ def put_object(request, body)
168
+ request.body = JSON.dump(body)
169
+ result = submit(uri, authorize(request))
170
+ Data.from_json(result.body)
171
+ end
162
172
  end
163
173
  end
164
174
  end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pp'
4
+ require 'stringio'
5
+
6
+ module Usps
7
+ module Imis
8
+ # Convenience wrapper for accessing specific properties within an API data response
9
+ #
10
+ class Data < Hash
11
+ # Load raw API response JSON to access properties
12
+ #
13
+ # @param json [String] Raw API response JSON
14
+ #
15
+ def self.from_json(json) = self[JSON.parse(json)]
16
+
17
+ alias raw to_h
18
+
19
+ # Access the iMIS ID property
20
+ #
21
+ def imis_id = self['ID']
22
+ alias id imis_id
23
+
24
+ # Access the Ordinal identifier property (if present)
25
+ #
26
+ def ordinal = self['Ordinal']
27
+
28
+ # Access an individual property value by name
29
+ #
30
+ def [](property_name)
31
+ property = raw['Properties']['$values'].find { it['Name'] == property_name }
32
+ return if property.nil?
33
+
34
+ value = property['Value']
35
+ value.is_a?(String) ? value : value['$value']
36
+ end
37
+
38
+ def inspect
39
+ stringio = StringIO.new
40
+ PP.pp(self, stringio)
41
+ stringio.string.delete("\n")
42
+ end
43
+
44
+ def pretty_print(pp)
45
+ data = {
46
+ entity_type_name: raw['EntityTypeName'],
47
+ imis_id:,
48
+ ordinal:
49
+ }.compact
50
+
51
+ pp.group(1, "#<#{self.class}", '>') do
52
+ data.each do |key, value|
53
+ pp.breakable
54
+ pp.text "#{key}="
55
+ pp.pp value
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -17,35 +17,46 @@ module Usps
17
17
 
18
18
  # Get a specific object from the Panel
19
19
  #
20
+ # If +fields+ is provided, will return only those field values
21
+ #
22
+ # @param fields [String] Field names to return
23
+ #
20
24
  # @param ordinal [Integer] The ordinal identifier for the desired object
21
25
  #
22
- def get(ordinal)
23
- api.on(business_object, ordinal:).get
24
- end
26
+ # @return [Usps::Imis::Data, Array<Usps::Imis::Data>] Response data from the API
27
+ #
28
+ def get(ordinal, *fields) = api.on(business_object, ordinal:).get(*fields)
25
29
  alias read get
26
30
 
27
31
  # Get a single named field from a Panel for the current member
28
32
  #
29
33
  # @param ordinal [Integer] The ordinal identifier for the desired object
30
- # @param name [String] Field name to return
34
+ # @param field [String] Field name to return
31
35
  #
32
- # @return [Hash] Response data from the API
36
+ # @return Response data field value from the API
33
37
  #
34
- def get_field(ordinal, name)
35
- api.on(business_object, ordinal:).get_field(name)
36
- end
38
+ def get_field(ordinal, field) = api.on(business_object, ordinal:).get_field(field)
37
39
  alias fetch get_field
40
+ alias [] get_field
41
+
42
+ # Get named fields from a Panel for the current member
43
+ #
44
+ # @param ordinal [Integer] The ordinal identifier for the desired object
45
+ # @param fields [Array<String>] Field names to return
46
+ #
47
+ # @return [Array] Response data from the API
48
+ #
49
+ def get_fields(ordinal, *fields) = api.on(business_object, ordinal:).get_fields(*fields)
50
+ alias fetch_all get_fields
38
51
 
39
52
  # Update only specific fields on a Panel for the current member
40
53
  #
41
54
  # @param ordinal [Integer] The ordinal identifier for the desired object
42
55
  # @param fields [Hash] Conforms to pattern +{ field_key => value }+
43
56
  #
44
- # @return [Hash] Response data from the API
57
+ # @return [Usps::Imis::Data] Response data from the API
45
58
  #
46
- def put_fields(ordinal, fields)
47
- api.on(business_object, ordinal:).put_fields(fields)
48
- end
59
+ def put_fields(ordinal, fields) = api.on(business_object, ordinal:).put_fields(fields)
49
60
  alias patch put_fields
50
61
 
51
62
  # Update an existing object in the Panel
@@ -53,27 +64,27 @@ module Usps
53
64
  # @param data [Hash] The record data for the desired object -- including the required
54
65
  # +ordinal+ identifier
55
66
  #
56
- def put(data)
57
- api.on(business_object, ordinal: data[:ordinal]).put(payload(data))
58
- end
67
+ # @return [Usps::Imis::Data] Response data from the API
68
+ #
69
+ def put(data) = api.on(business_object, ordinal: data[:ordinal]).put(payload(data))
59
70
  alias update put
60
71
 
61
72
  # Create a new object in the Panel
62
73
  #
63
74
  # @param data [Hash] The record data for the desired object
64
75
  #
65
- def post(data)
66
- api.on(business_object).post(payload(data))
67
- end
76
+ # @return [Usps::Imis::Data] Response data from the API
77
+ #
78
+ def post(data) = api.on(business_object).post(payload(data))
68
79
  alias create post
69
80
 
70
81
  # Remove a specific object from the Panel
71
82
  #
72
83
  # @param ordinal [Integer] The ordinal identifier for the desired object
73
84
  #
74
- def delete(ordinal)
75
- api.on(business_object, ordinal:).delete
76
- end
85
+ # @return [true] Only on success response (i.e. blank string from the API)
86
+ #
87
+ def delete(ordinal) = api.on(business_object, ordinal:).delete
77
88
  alias destroy delete
78
89
 
79
90
  private
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.7.0'
5
+ VERSION = '0.8.0'
6
6
  end
7
7
  end
@@ -6,28 +6,34 @@ describe Usps::Imis::BusinessObject do
6
6
  let(:business_object) { described_class.new(api, 'Stub') }
7
7
  let(:api) { Usps::Imis::Api.new }
8
8
 
9
- let(:expected) do
10
- {
11
- 'Properties' => {
12
- '$values' => [
13
- { 'Name' => 'ID', 'Value' => { '$value' => '31092' } },
14
- { 'Name' => 'Stub Integer', 'Value' => { '$value' => 43 } },
15
- { 'Name' => 'Stub String', 'Value' => 'other' }
16
- ]
17
- }
18
- }
9
+ before do
10
+ allow(business_object).to receive(:raw_object).and_return(
11
+ Usps::Imis::Data[
12
+ 'Properties' => {
13
+ '$values' => [
14
+ { 'Name' => 'ID', 'Value' => { '$value' => '31092' } },
15
+ { 'Name' => 'Stub Integer', 'Value' => { '$value' => 42 } },
16
+ { 'Name' => 'Stub String', 'Value' => 'something' }
17
+ ]
18
+ }
19
+ ]
20
+ )
19
21
  end
20
22
 
21
- before do
22
- allow(business_object).to receive(:get).and_return({
23
- 'Properties' => {
24
- '$values' => [
25
- { 'Name' => 'ID', 'Value' => { '$value' => '31092' } },
26
- { 'Name' => 'Stub Integer', 'Value' => { '$value' => 42 } },
27
- { 'Name' => 'Stub String', 'Value' => 'something' }
28
- ]
29
- }
30
- })
23
+ describe '#get' do
24
+ it 'returns multiple values' do
25
+ expect(business_object.get('Stub String', 'Stub Integer')).to eq(['something', 42])
26
+ end
27
+
28
+ describe 'delegation to get_fields' do
29
+ before { allow(business_object).to receive(:get_fields).with('Stub String', 'Stub Integer') }
30
+
31
+ it 'delegates to get_fields' do
32
+ business_object.get('Stub String', 'Stub Integer')
33
+
34
+ expect(business_object).to have_received(:get_fields).with('Stub String', 'Stub Integer')
35
+ end
36
+ end
31
37
  end
32
38
 
33
39
  describe '#get_field' do
@@ -40,7 +46,25 @@ describe Usps::Imis::BusinessObject do
40
46
  end
41
47
  end
42
48
 
49
+ describe '#get_fields' do
50
+ it 'returns multiple values' do
51
+ expect(business_object.get_fields('Stub String', 'Stub Integer')).to eq(['something', 42])
52
+ end
53
+ end
54
+
43
55
  describe '#filter_fields' do
56
+ let(:expected) do
57
+ {
58
+ 'Properties' => {
59
+ '$values' => [
60
+ { 'Name' => 'ID', 'Value' => { '$value' => '31092' } },
61
+ { 'Name' => 'Stub Integer', 'Value' => { '$value' => 43 } },
62
+ { 'Name' => 'Stub String', 'Value' => 'other' }
63
+ ]
64
+ }
65
+ }
66
+ end
67
+
44
68
  it 'formats fields correctly' do
45
69
  updated = business_object.send(:filter_fields, 'Stub Integer' => 43, 'Stub String' => 'other')
46
70
 
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Usps::Imis::Data do
6
+ let(:data) do
7
+ described_class[
8
+ 'EntityTypeName' => 'ABC_ASC_Individual_Demog',
9
+ 'Properties' => {
10
+ '$values' => [
11
+ { 'Name' => 'ID', 'Value' => { '$value' => '31092' } },
12
+ { 'Name' => 'Stub Integer', 'Value' => { '$value' => 42 } },
13
+ { 'Name' => 'Stub String', 'Value' => 'something' }
14
+ ]
15
+ }
16
+ ]
17
+ end
18
+
19
+ describe 'missing property' do
20
+ it 'returns nil for missing properties' do
21
+ expect(data['Not Found']).to be_nil
22
+ end
23
+ end
24
+
25
+ describe '#inspect' do
26
+ it 'generates the correct inspect string' do
27
+ expect(data.inspect).to eq('#<Usps::Imis::Data entity_type_name="ABC_ASC_Individual_Demog" imis_id="31092">')
28
+ end
29
+
30
+ context 'with data from a Panel' do
31
+ let(:data) do
32
+ described_class[
33
+ 'EntityTypeName' => 'ABC_ASC_Individual_Demog',
34
+ 'Properties' => {
35
+ '$values' => [
36
+ { 'Name' => 'ID', 'Value' => { '$value' => '31092' } },
37
+ { 'Name' => 'Ordinal', 'Value' => { '$value' => '99' } },
38
+ { 'Name' => 'Stub Integer', 'Value' => { '$value' => 42 } },
39
+ { 'Name' => 'Stub String', 'Value' => 'something' }
40
+ ]
41
+ }
42
+ ]
43
+ end
44
+
45
+ it 'generates the correct inspect string with an ordinal' do
46
+ expect(data.inspect).to eq(
47
+ '#<Usps::Imis::Data entity_type_name="ABC_ASC_Individual_Demog" imis_id="31092" ordinal="99">'
48
+ )
49
+ end
50
+ end
51
+ end
52
+ end
@@ -21,7 +21,11 @@ describe Usps::Imis::Panels::Education do
21
21
 
22
22
  describe '#get' do
23
23
  it 'loads a specific object' do
24
- expect(education.get(90737)).to be_a(Hash)
24
+ expect(education.get(90737)).to be_a(Usps::Imis::Data)
25
+ end
26
+
27
+ it 'returns specific fields' do
28
+ expect(education.get(90737, 'ABC_Product_Code', 'ABC_Other_Code')).to eq(%w[CRS AP])
25
29
  end
26
30
  end
27
31
 
@@ -31,27 +35,27 @@ describe Usps::Imis::Panels::Education do
31
35
  end
32
36
  end
33
37
 
38
+ describe '#get_fields' do
39
+ it 'returns specific fields' do
40
+ expect(education.get_fields(90737, 'ABC_Product_Code', 'ABC_Other_Code')).to eq(%w[CRS AP])
41
+ end
42
+ end
43
+
34
44
  # rubocop:disable RSpec/ExampleLength
35
45
  it 'interacts with records correctly', :aggregate_failures do
36
46
  new_record = education.create(details)
37
- expect(new_record).to be_a(Hash)
47
+ expect(new_record).to be_a(Usps::Imis::Data)
38
48
 
39
- ordinal = new_record['Identity']['IdentityElements']['$values'][1]
49
+ ordinal = new_record.ordinal
40
50
 
41
51
  update_result =
42
52
  education.update(details.merge(source: 'Online Exams System - Modified', ordinal:))
43
- updated = update_result['Properties']['$values'].find do |v|
44
- v['Name'] == 'ABC_Educ_Source_System'
45
- end
46
- expect(updated['Value']).to eq('Online Exams System - Modified')
53
+ expect(update_result['ABC_Educ_Source_System']).to eq('Online Exams System - Modified')
47
54
 
48
55
  put_fields_result = education.put_fields(ordinal, 'ABC_Educ_Source_System' => 'Online Exams System - Mod2')
49
- patched = put_fields_result['Properties']['$values'].find do |v|
50
- v['Name'] == 'ABC_Educ_Source_System'
51
- end
52
- expect(patched['Value']).to eq('Online Exams System - Mod2')
56
+ expect(put_fields_result['ABC_Educ_Source_System']).to eq('Online Exams System - Mod2')
53
57
 
54
- expect(education.destroy(ordinal)).to eq('')
58
+ expect(education.destroy(ordinal)).to be(true)
55
59
  end
56
60
  # rubocop:enable RSpec/ExampleLength
57
61
  end
@@ -17,22 +17,21 @@ describe Usps::Imis::Panels::Vsc do
17
17
 
18
18
  describe '#get' do
19
19
  it 'loads a specific object' do
20
- expect(vsc.get(1433)).to be_a(Hash)
20
+ expect(vsc.get(1433)).to be_a(Usps::Imis::Data)
21
21
  end
22
22
  end
23
23
 
24
24
  # rubocop:disable RSpec/ExampleLength
25
25
  it 'handles new records correctly', :aggregate_failures do
26
26
  new_record = vsc.create(details)
27
- expect(new_record).to be_a(Hash)
27
+ expect(new_record).to be_a(Usps::Imis::Data)
28
28
 
29
- ordinal = new_record['Identity']['IdentityElements']['$values'][1]
29
+ ordinal = new_record.ordinal
30
30
 
31
31
  update_result = vsc.update(details.merge(count: 43, ordinal:))
32
- updated = update_result['Properties']['$values'].find { it['Name'] == 'Quantity' }
33
- expect(updated['Value']['$value']).to eq(43)
32
+ expect(update_result['Quantity']).to eq(43)
34
33
 
35
- expect(vsc.destroy(ordinal)).to eq('')
34
+ expect(vsc.destroy(ordinal)).to be(true)
36
35
  end
37
36
  # rubocop:enable RSpec/ExampleLength
38
37
  end
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = Usps::Imis::VERSION
8
8
  s.summary = 'iMIS API Wrapper'
9
9
  s.description = 'A wrapper for the iMIS API.'
10
- s.homepage = 'http://rubygems.org/gems/usps-imis-api'
10
+ s.homepage = 'https://github.com/unitedstatespowersquadrons/imis-api-ruby'
11
11
  s.authors = ['Julian Fiander']
12
12
  s.email = 'jsfiander@gmail.com'
13
13
  s.require_paths = %w[lib]
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.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander
@@ -45,6 +45,7 @@ files:
45
45
  - lib/usps/imis/api.rb
46
46
  - lib/usps/imis/business_object.rb
47
47
  - lib/usps/imis/config.rb
48
+ - lib/usps/imis/data.rb
48
49
  - lib/usps/imis/error.rb
49
50
  - lib/usps/imis/errors/api_error.rb
50
51
  - lib/usps/imis/errors/config_error.rb
@@ -67,6 +68,7 @@ files:
67
68
  - spec/lib/usps/imis/api_spec.rb
68
69
  - spec/lib/usps/imis/business_object_spec.rb
69
70
  - spec/lib/usps/imis/config_spec.rb
71
+ - spec/lib/usps/imis/data_spec.rb
70
72
  - spec/lib/usps/imis/error_spec.rb
71
73
  - spec/lib/usps/imis/errors/response_error_spec.rb
72
74
  - spec/lib/usps/imis/mapper_spec.rb
@@ -78,7 +80,7 @@ files:
78
80
  - spec/lib/usps/imis_spec.rb
79
81
  - spec/spec_helper.rb
80
82
  - usps-imis-api.gemspec
81
- homepage: http://rubygems.org/gems/usps-imis-api
83
+ homepage: https://github.com/unitedstatespowersquadrons/imis-api-ruby
82
84
  licenses: []
83
85
  metadata:
84
86
  rubygems_mfa_required: 'true'