mindee 3.19.0 → 3.19.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: ef56483dc0576b931b3d88b57e4512abd44ea4e216ed29dc1097ada3fa5b00fb
4
- data.tar.gz: 8d4f6c2b99c113439b2332244cd89619189704bc75655121c26ba0122118d539
3
+ metadata.gz: bca81cfda2aa389c5892c16d68e78cb3204a029fe21265180e3de2478a6f8054
4
+ data.tar.gz: 3004a181239a458018f90258efe35940d1c466a890f92d7f221248970a13a3eb
5
5
  SHA512:
6
- metadata.gz: a0461aea7ba2804e36ddc833e1ec24888227484d1ad1f1471b8b8859cfaffc14a94f623672b749fe0f73584c6c215f26d87f2e11cbeb701fc8cc9cf86088ec6f
7
- data.tar.gz: aed38431cddde8abc620cf4701ecf7299929a0216b0a9e717d7ef56732211fb38ae12d093fca8839cbd981c43047f0a87088587c44fc7f4c9ff9f4ae56438f7d
6
+ metadata.gz: a2482ecc51f3259b7ffd0b45c4239ef42ba961a83c8c93bc50fe60503857e033d5397dc41ee3fb1defbcb5320ebb134a6aeba7c8b4ba31fa6255f5c7f95b632c
7
+ data.tar.gz: 6f3d4b075a60c4e9ca8d01b5474568c4799df6584dc777b74489d2228d2c14d0009eca9def8f3ddda7e07527ab6fb79e80b6e9bee996025516a54256b0846b49
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Mindee Ruby API Library Changelog
2
2
 
3
+ ## v3.19.1 - 2025-01-21
4
+ ### Changes
5
+ * :bug: fix extras failing at document level if missing from prediction
6
+
7
+
3
8
  ## v3.19.0 - 2025-01-14
4
9
  ### Changes
5
10
  * :sparkles: add support for US Mail V3
data/README.md CHANGED
@@ -162,6 +162,54 @@ Using the ruby bundler:
162
162
  bundle exec ruby ./bin/mindee.rb invoice path/to/your/file.ext
163
163
  ```
164
164
 
165
+
166
+ ### Enqueue and Parse a Webhook Response
167
+ This is an optional way of handling asynchronous APIs.
168
+
169
+ ```rb
170
+ require 'mindee'
171
+
172
+ # Init a new client
173
+ mindee_client = Mindee::Client.new(api_key: 'my-api-key')
174
+
175
+ # Load a file from disk
176
+ input_source = mindee_client.source_from_path('/path/to/the/file.ext')
177
+
178
+
179
+ # Parse the file
180
+ enqueue_response = mindee_client.enqueue(
181
+ input_source,
182
+ Mindee::Product::InternationalId::InternationalIdV2
183
+ )
184
+
185
+ job_id = enqueue_response.job.id
186
+
187
+ # Load the JSON string sent by the Mindee webhook POST callback.
188
+ # Reading the callback data will vary greatly depending on your HTTP server.
189
+ # This is therefore beyond the scope of this example.
190
+
191
+ local_response = Mindee::Input::LocalResponse.new(request.body.string)
192
+
193
+ # You can also use a File object as the input.
194
+ # FILE_PATH = File.join('path', 'to', 'file.json').freeze
195
+ # local_response = Mindee::Input::LocalResponse.new(FILE_PATH);
196
+
197
+ # Optional: verify the HMAC signature.
198
+ unless local_response.valid_hmac_signature?(my_secret_key, 'invalid signature')
199
+ raise "Invalid HMAC signature!"
200
+ end
201
+
202
+
203
+ # Deserialize the response:
204
+ result = mindee_client.load_prediction(
205
+ Mindee::Product::InternationalId::InternationalIdV2,
206
+ local_response
207
+ )
208
+
209
+ # Print a full summary of the parsed data in RST format
210
+ puts result.document
211
+ ```
212
+
165
213
  ## Further Reading
166
214
 
167
215
  There's more to it than that for those that need more features, or want to
@@ -61,8 +61,7 @@ module Mindee
61
61
  private
62
62
 
63
63
  def inject_full_text_ocr(raw_prediction)
64
- return unless raw_prediction.dig('inference', 'pages') &&
65
- raw_prediction['inference']['pages'][0]['extras']['full_text_ocr']
64
+ return unless raw_prediction.dig('inference', 'pages', 0, 'extras', 'full_text_ocr')
66
65
 
67
66
  full_text_ocr = String.new
68
67
  raw_prediction.dig('inference', 'pages').each do |page|
@@ -3,7 +3,7 @@
3
3
  # Mindee
4
4
  module Mindee
5
5
  # Current version.
6
- VERSION = '3.19.0'
6
+ VERSION = '3.19.1'
7
7
 
8
8
  # Finds and return the current platform.
9
9
  # @return [String]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mindee
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.19.0
4
+ version: 3.19.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mindee, SA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-14 00:00:00.000000000 Z
11
+ date: 2025-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: marcel