usps-imis-api 0.8.0 → 0.8.1

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: 0e1d3316b4676bae03e67aa927632ec91801a6d703c55049c1b11013a20c3e08
4
- data.tar.gz: 8199c664875cc57e995d73b3a96ce03cd9de2e5460e7a451553df3bb5ca3ff84
3
+ metadata.gz: ea2c1c51fb9d73e9aa4dc60f4be57c72443f9d2f4e16fcd8e572af8e1b7c58e6
4
+ data.tar.gz: ffd74ed752fe1cfc9f0c0eaeb166e1d13bf75cf40d0b07bafaa9ce1de5b09c49
5
5
  SHA512:
6
- metadata.gz: 7015ffe22161d1645959004798ed1fde3e65a66db6695dac75ae84db13177a376a37b083f74abdd9092108ba33d9d0f09fcbaaaa845d861d50af237c77c819b2
7
- data.tar.gz: 940e05eeeeea390c67e207f4ace40c6befed6dbe355efdc38e3fa6d270c35f6bf5c48c3093808c505c2b26e9f452000ecd384e250451bc8263cce84d43a78238
6
+ metadata.gz: e3fad87c5d7fa1c3bfa8c0140304b39e7df21d5e9abdc5234a183a1175409c5f42fe8e65f8e53975b127f15004a65aa988d533ce68ed56d3867d470f28353b2b
7
+ data.tar.gz: 872e0e9a73136a6166a5c585c8286d106e3d81758e2eccdbc8f8a1b1fc2d845883680e54323ffbd5902f599cbcc685be611ff1edf62c917d5e42b5ec92ba79ef
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- usps-imis-api (0.8.0)
4
+ usps-imis-api (0.8.1)
5
5
  activesupport (~> 8.0)
6
6
 
7
7
  GEM
data/Readme.md CHANGED
@@ -120,7 +120,7 @@ To fetch a specific field from member data, run e.g.:
120
120
  tot_mms = api.on('ABC_ASC_Individual_Demog').get_field('TotMMS')
121
121
  ```
122
122
 
123
- You can also access fields directly on the Business Object like a Hash:
123
+ You can also access fields directly on the Business Object or Panel like a Hash:
124
124
 
125
125
  ```ruby
126
126
  tot_mms = api.on('ABC_ASC_Individual_Demog')['TotMMS']
@@ -229,9 +229,9 @@ vsc.get(1417)
229
229
 
230
230
  # All of these options are identical
231
231
  #
232
- vsc.get(1417, 'Quantity')
232
+ vsc.get(1417, 'Quantity').first
233
233
  vsc.get(1417)['Quantity']
234
- vsc.get[1417, 'Quantity']
234
+ vsc[1417, 'Quantity']
235
235
  vsc.get(1417).raw['Properties']['$values'].find { it['Name'] == 'Quantity' }['Value']['$value']
236
236
  vsc.get_field(1417, 'Quantity')
237
237
 
@@ -244,7 +244,7 @@ created = vsc.create(certificate: 'E136924', year: 2024, count: 42)
244
244
  ordinal = created.ordinal
245
245
  ordinal = created['Ordinal']
246
246
  ordinal = created.raw['Properties']['$values'].find { it['Name'] == 'Ordinal' }['Value']['$value']
247
- ordinal = created.raw['Identity']['IdentityElements']['$values'][1] # Value is duplicated here
247
+ ordinal = created.raw['Identity']['IdentityElements']['$values'][1].to_i # Value is duplicated here
248
248
 
249
249
  vsc.update(certificate: 'E136924', year: 2024, count: 43, ordinal: ordinal)
250
250
 
data/lib/usps/imis/api.rb CHANGED
@@ -54,7 +54,7 @@ module Usps
54
54
  def imis_id=(id)
55
55
  raise Errors::LockedIdError if lock_imis_id
56
56
 
57
- @imis_id = id&.to_i&.to_s
57
+ @imis_id = id&.to_i
58
58
  end
59
59
 
60
60
  # Convert a member's certificate number into an iMIS ID number
@@ -68,7 +68,7 @@ module Usps
68
68
 
69
69
  begin
70
70
  result = query(Imis.configuration.imis_id_query_name, { certificate: })
71
- @imis_id = result['Items']['$values'][0]['ID']
71
+ @imis_id = result['Items']['$values'][0]['ID'].to_i
72
72
  rescue StandardError
73
73
  raise Errors::NotFoundError, 'Member not found'
74
74
  end
@@ -120,7 +120,7 @@ module Usps
120
120
  return CGI.escape(id) unless id.nil?
121
121
  return CGI.escape("~#{api.imis_id}|#{ordinal}") if ordinal
122
122
 
123
- api.imis_id
123
+ api.imis_id.to_s
124
124
  end
125
125
 
126
126
  # Manually assemble the matching data structure, with fields in the correct order
@@ -18,12 +18,12 @@ module Usps
18
18
 
19
19
  # Access the iMIS ID property
20
20
  #
21
- def imis_id = self['ID']
21
+ def imis_id = self['ID'].to_i
22
22
  alias id imis_id
23
23
 
24
24
  # Access the Ordinal identifier property (if present)
25
25
  #
26
- def ordinal = self['Ordinal']
26
+ def ordinal = self['Ordinal']&.to_i
27
27
 
28
28
  # Access an individual property value by name
29
29
  #
@@ -113,7 +113,7 @@ module Usps
113
113
  'EntityTypeName' => business_object,
114
114
  'IdentityElements' => {
115
115
  '$type' => identity_type,
116
- '$values' => [api.imis_id, ordinal&.to_s].compact
116
+ '$values' => [api.imis_id.to_s, ordinal&.to_s].compact
117
117
  }
118
118
  }
119
119
  end
@@ -124,7 +124,7 @@ module Usps
124
124
  'EntityTypeName' => 'Party',
125
125
  'IdentityElements' => {
126
126
  '$type' => identity_type,
127
- '$values' => [api.imis_id]
127
+ '$values' => [api.imis_id.to_s]
128
128
  }
129
129
  }
130
130
  end
@@ -14,7 +14,7 @@ module Usps
14
14
 
15
15
  def payload(data)
16
16
  build_payload(data) do |props|
17
- props.add 'ID', api.imis_id
17
+ props.add 'ID', api.imis_id.to_s
18
18
  props.add 'Ordinal', data[:ordinal] if data[:ordinal]
19
19
  props.add 'ABC_EDUC_THRU_DATE', data[:thru_date] || '0001-01-01T00:00:00'
20
20
  props.add 'ABC_ECertificate', data[:certificate]
@@ -14,7 +14,7 @@ module Usps
14
14
 
15
15
  def payload(data)
16
16
  build_payload(data) do |props|
17
- props.add 'ID', api.imis_id
17
+ props.add 'ID', api.imis_id.to_s
18
18
  props.add 'Ordinal', data[:ordinal] if data[:ordinal]
19
19
  props.add 'Source_System', 'Manual ITCom Entry'
20
20
  props.add 'ABC_ECertificate', data[:certificate]
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.8.0'
5
+ VERSION = '0.8.1'
6
6
  end
7
7
  end
@@ -17,13 +17,13 @@ describe Usps::Imis::Api do
17
17
  it 'stores the initial imis_id' do
18
18
  api = described_class.new(imis_id: 42)
19
19
 
20
- expect(api.imis_id).to eq('42')
20
+ expect(api.imis_id).to eq(42)
21
21
  end
22
22
  end
23
23
 
24
24
  describe '#imis_id_for' do
25
25
  it 'gets the iMIS ID' do
26
- expect(api.imis_id_for('E231625')).to eq('31092')
26
+ expect(api.imis_id_for('E231625')).to eq(31092)
27
27
  end
28
28
 
29
29
  context 'with a query error' do
@@ -133,7 +133,7 @@ describe Usps::Imis::Api do
133
133
  end
134
134
 
135
135
  expect(result).to be_a(Hash)
136
- expect(api.imis_id).to eq('31092')
136
+ expect(api.imis_id).to eq(31092)
137
137
  end
138
138
 
139
139
  it 'nests on and with', :aggregate_failures do
@@ -24,7 +24,7 @@ describe Usps::Imis::Data do
24
24
 
25
25
  describe '#inspect' do
26
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">')
27
+ expect(data.inspect).to eq('#<Usps::Imis::Data entity_type_name="ABC_ASC_Individual_Demog" imis_id=31092>')
28
28
  end
29
29
 
30
30
  context 'with data from a Panel' do
@@ -44,7 +44,7 @@ describe Usps::Imis::Data do
44
44
 
45
45
  it 'generates the correct inspect string with an ordinal' do
46
46
  expect(data.inspect).to eq(
47
- '#<Usps::Imis::Data entity_type_name="ABC_ASC_Individual_Demog" imis_id="31092" ordinal="99">'
47
+ '#<Usps::Imis::Data entity_type_name="ABC_ASC_Individual_Demog" imis_id=31092 ordinal=99>'
48
48
  )
49
49
  end
50
50
  end
@@ -9,7 +9,7 @@ describe Usps::Imis::Mapper do
9
9
  it 'stores the initial imis_id' do
10
10
  mapper = described_class.new(imis_id: 42)
11
11
 
12
- expect(mapper.api.imis_id).to eq('42')
12
+ expect(mapper.api.imis_id).to eq(42)
13
13
  end
14
14
  end
15
15
 
@@ -64,7 +64,7 @@ describe Usps::Imis::Panels::Education do
64
64
  it 'can initialize with an iMIS ID' do
65
65
  panel = described_class.new(imis_id: 6374)
66
66
 
67
- expect(panel.api.imis_id).to eq('6374')
67
+ expect(panel.api.imis_id).to eq(6374)
68
68
  end
69
69
  end
70
70
  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.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander