usps-imis-api 0.6.15 → 0.6.16

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: 1ece5a19e925e1ef85b9e54b1d8fe7139c4015b0a1fe7ddcb602e172fbb50cab
4
- data.tar.gz: 723eb4ccbf3b0c86c3f309c83d32d2b892420c688fd1f8aa2bfedcc47d61d2a9
3
+ metadata.gz: 9d68eb23f00014bc9cb6173f716084f8eff9cedfc48e70507c07a35fe8e7b207
4
+ data.tar.gz: fda5c7882bc758d9cfdd2889e734ff8c0d319f456e39bf1965f030765ec82a0e
5
5
  SHA512:
6
- metadata.gz: fbca9aeda6a7a4e7fc6701c2767da349ab49e6b9126b36ea0a6225b4c18b2c7970dc22390ddabfbf571411d76b86ab2b37bbde79f471f4b5a3ceba9d271fdd5c
7
- data.tar.gz: 3b09c75a050ad32e8077d9bc07772d91bb37a7e4628734c0159cb05a206f7f9128059532e22e90f014f07041f2ac87d0d37c2d7878845069c1220ec221cb4e69
6
+ metadata.gz: bb42f257b1e4e6c6383dd9b1f37d68e9c89f358f98bfccb09c53190573da28b0259fabe27e12f50c5420daa8f009661e928463c19a48e854abd86b8dd34021f1
7
+ data.tar.gz: a4fb539ef056e6936e1546b303ef8b20bf52a822185063d8b6eabc042eb5b3f2b2fceb5d0cff5959c40ce524175a137dd1821783af7eea495803342c1d065cff
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- usps-imis-api (0.6.15)
4
+ usps-imis-api (0.6.16)
5
5
  activesupport (~> 8.0)
6
6
 
7
7
  GEM
data/Readme.md CHANGED
@@ -77,7 +77,13 @@ 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
- ### GET
80
+ ### Business Object and Panel Actions
81
+
82
+ Business Objects and Panels support the following actions.
83
+
84
+ Panels require passing in the ordinal identifier as an argument, except for `POST`.
85
+
86
+ #### GET
81
87
 
82
88
  To fetch member data, run e.g.:
83
89
 
@@ -87,7 +93,9 @@ api.imis_id = 31092
87
93
  data = api.on('ABC_ASC_Individual_Demog').get
88
94
  ```
89
95
 
90
- ### GET Field
96
+ Alias: `read`
97
+
98
+ #### GET Field
91
99
 
92
100
  To fetch a specific field from member data, run e.g.:
93
101
 
@@ -97,7 +105,9 @@ api.imis_id = 31092
97
105
  tot_mms = api.on('ABC_ASC_Individual_Demog').get_field('TotMMS')
98
106
  ```
99
107
 
100
- ### PUT Fields
108
+ Alias: `fetch`
109
+
110
+ #### PUT Fields
101
111
 
102
112
  To update member data, run e.g.:
103
113
 
@@ -111,7 +121,9 @@ update = api.on('ABC_ASC_Individual_Demog').put_fields(data)
111
121
  This method fetches the current data structure, and filters it down to just what you want to
112
122
  update, to reduce the likelihood of update collisions or type validation failures.
113
123
 
114
- ### PUT
124
+ Alias: `patch`
125
+
126
+ #### PUT
115
127
 
116
128
  To update member data, run e.g.:
117
129
 
@@ -121,9 +133,13 @@ api.imis_id = 31092
121
133
  update = api.on('ABC_ASC_Individual_Demog').put(complete_imis_object)
122
134
  ```
123
135
 
124
- This method requires a complete iMIS data structure.
136
+ This method requires a complete iMIS data structure. However, any properties not included will be
137
+ left unmodified (meaning this also effectively handles `PATCH`, though iMIS does not accept that
138
+ HTTP verb).
139
+
140
+ Alias: `update`
125
141
 
126
- ### POST
142
+ #### POST
127
143
 
128
144
  To create new member data, run e.g.:
129
145
 
@@ -133,7 +149,9 @@ created = api.on('ABC_ASC_Individual_Demog').post(complete_imis_object)
133
149
 
134
150
  This method requires a complete iMIS data structure.
135
151
 
136
- ### DELETE
152
+ Alias: `create`
153
+
154
+ #### DELETE
137
155
 
138
156
  To remove member data, run e.g.:
139
157
 
@@ -145,6 +163,8 @@ api.on('ABC_ASC_Individual_Demog').delete
145
163
 
146
164
  This returns a blank string on success.
147
165
 
166
+ Alias: `destroy`
167
+
148
168
  ### QUERY
149
169
 
150
170
  Run an IQA Query
@@ -187,7 +207,8 @@ vsc.api.imis_id = 6374
187
207
  vsc.get(1417)
188
208
 
189
209
  created = vsc.create(certificate: 'E136924', year: 2024, count: 42)
190
- ordinal = created['Properties']['$values'][1]['Value']['$value']
210
+ ordinal = created['Properties']['$values'].find { it['Name'] == 'Ordinal' }['Value']['$value']
211
+ # ordinal = created['Identity']['IdentityElements']['$values'][1] # Alternative
191
212
 
192
213
  vsc.update(certificate: 'E136924', year: 2024, count: 43, ordinal: ordinal)
193
214
 
data/lib/usps/imis/api.rb CHANGED
@@ -132,15 +132,6 @@ module Usps
132
132
  results
133
133
  end
134
134
 
135
- # An instance of +BusinessObject+, using this instance as its parent +Api+
136
- #
137
- # @param business_object_name [String] Name of the business object
138
- # @param ordinal [Integer] Ordinal to build override ID param of the URL (e.g. used for Panels)
139
- #
140
- def business_object(business_object_name, ordinal: nil)
141
- BusinessObject.new(self, business_object_name, ordinal:)
142
- end
143
-
144
135
  # Run requests as DSL, with specific +BusinessObject+ only maintained for this scope
145
136
  #
146
137
  # If no block is given, this returns the specified +BusinessObject+.
@@ -149,7 +140,7 @@ module Usps
149
140
  # @param ordinal [Integer] Ordinal to build override ID param of the URL (e.g. used for Panels)
150
141
  #
151
142
  def on(business_object_name, ordinal: nil, &)
152
- object = business_object(business_object_name, ordinal:)
143
+ object = BusinessObject.new(self, business_object_name, ordinal:)
153
144
  return object unless block_given?
154
145
 
155
146
  object.instance_eval(&)
@@ -47,7 +47,7 @@ module Usps
47
47
  end
48
48
 
49
49
  updates.map do |business_object_name, field_updates|
50
- api.business_object(business_object_name).put_fields(field_updates)
50
+ api.on(business_object_name).put_fields(field_updates)
51
51
  end
52
52
  end
53
53
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.6.15'
5
+ VERSION = '0.6.16'
6
6
  end
7
7
  end
@@ -56,7 +56,7 @@ describe Usps::Imis::Api do
56
56
  before { api.imis_id = 31092 }
57
57
 
58
58
  it 'sends an update' do
59
- expect(api.business_object('ABC_ASC_Individual_Demog').put_fields('TotMMS' => 15)).to(
59
+ expect(api.on('ABC_ASC_Individual_Demog').put_fields('TotMMS' => 15)).to(
60
60
  be_a(Hash)
61
61
  )
62
62
  end
@@ -78,7 +78,7 @@ describe Usps::Imis::Api do
78
78
  end
79
79
 
80
80
  it 'wraps the error' do
81
- expect { api.business_object('ABC_ASC_Individual_Demog').put_fields('TotMMS' => 15) }.to(
81
+ expect { api.on('ABC_ASC_Individual_Demog').put_fields('TotMMS' => 15) }.to(
82
82
  raise_error(Usps::Imis::Error::ApiError, warning_text)
83
83
  )
84
84
  end
@@ -88,7 +88,7 @@ describe Usps::Imis::Api do
88
88
  describe '#with' do
89
89
  it 'sends an update from put' do
90
90
  expect(
91
- api.with(31092) { business_object('ABC_ASC_Individual_Demog').put_fields('TotMMS' => 15) }
91
+ api.with(31092) { on('ABC_ASC_Individual_Demog').put_fields('TotMMS' => 15) }
92
92
  ).to be_a(Hash)
93
93
  end
94
94
 
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.15
4
+ version: 0.6.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander