Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💥 version 4 #137

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/_publish-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "2.7"
ruby-version: "3.0"
bundler-cache: true

- name: Set credentials
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/_test-code-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
- "3.0"
- "3.1"
- "3.2"
- "3.3"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/_test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ jobs:
- "ubuntu-24.04"
- "macos-latest"
ruby:
- "2.6"
- "2.7"
- "3.0"
- "3.1"
- "3.2"
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/_test-units.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ jobs:
- "ubuntu-22.04"
- "macos-latest"
ruby:
- "2.6"
- "2.7"
- "3.0"
- "3.1"
- "3.2"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ on:

jobs:
test_code_samples:
uses: mindee/mindee-api-ruby/.github/workflows/_test-code-samples.yml@main
uses: mindee/mindee-api-ruby/.github/workflows/_test-code-samples.yml@develop/v4.0.0
secrets: inherit
6 changes: 3 additions & 3 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ on:

jobs:
publish_docs:
uses: mindee/mindee-api-ruby/.github/workflows/_publish-docs.yml@main
uses: mindee/mindee-api-ruby/.github/workflows/_publish-docs.yml@develop/v4.0.0
secrets: inherit
publish_guide:
uses: mindee/mindee-api-ruby/.github/workflows/_publish-guide.yml@main
uses: mindee/mindee-api-ruby/.github/workflows/_publish-guide.yml@develop/v4.0.0
needs: publish_docs
secrets: inherit
publish_code:
uses: mindee/mindee-api-ruby/.github/workflows/_publish-code.yml@main
uses: mindee/mindee-api-ruby/.github/workflows/_publish-code.yml@develop/v4.0.0
secrets: inherit
8 changes: 4 additions & 4 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ on:

jobs:
static_analysis:
uses: mindee/mindee-api-ruby/.github/workflows/_static-analysis.yml@main
uses: mindee/mindee-api-ruby/.github/workflows/_static-analysis.yml@develop/v4.0.0
test_units:
uses: mindee/mindee-api-ruby/.github/workflows/_test-units.yml@main
uses: mindee/mindee-api-ruby/.github/workflows/_test-units.yml@develop/v4.0.0
needs: static_analysis
secrets: inherit
test_integrations:
uses: mindee/mindee-api-ruby/.github/workflows/_test-integrations.yml@main
uses: mindee/mindee-api-ruby/.github/workflows/_test-integrations.yml@develop/v4.0.0
needs: test_units
secrets: inherit
test_code_samples:
uses: mindee/mindee-api-ruby/.github/workflows/_test-code-samples.yml@main
uses: mindee/mindee-api-ruby/.github/workflows/_test-code-samples.yml@develop/v4.0.0
needs: test_units
secrets: inherit
6 changes: 3 additions & 3 deletions .github/workflows/push-main-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ on:

jobs:
static_analysis:
uses: mindee/mindee-api-ruby/.github/workflows/_static-analysis.yml@main
uses: mindee/mindee-api-ruby/.github/workflows/_static-analysis.yml@develop/v4.0.0
test_units:
uses: mindee/mindee-api-ruby/.github/workflows/_test-units.yml@main
uses: mindee/mindee-api-ruby/.github/workflows/_test-units.yml@develop/v4.0.0
needs: static_analysis
secrets: inherit
tag:
uses: mindee/client-lib-actions/.github/workflows/tag-version.yml@main
uses: mindee/client-lib-actions/.github/workflows/tag-version.yml@develop/v4.0.0
needs: test_units
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ AllCops:
- _test.rb
- local_test/*

TargetRubyVersion: 2.6
TargetRubyVersion: 3.0
SuggestExtensions: false

Gemspec/DevelopmentDependencies:
Expand Down
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Quickly and easily connect to Mindee's API services using Ruby.

## Requirements

The following Ruby versions are tested and supported: 2.6, 2.7, 3.0, 3.1, 3.2
The following Ruby versions are tested and supported: 3.0, 3.1, 3.2, 3.3

## Quick Start

Expand Down Expand Up @@ -116,7 +116,9 @@ result = mindee_client.parse(
puts result.document
```

### Custom Documents (docTI & Custom APIs)
### Universal - All Other Documents

The Universal product acts as a catch-all for every and any API if it doesn't have an assigned product name.

```ruby
require 'mindee'
Expand All @@ -133,7 +135,7 @@ input_source = mindee_client.source_from_path('/path/to/the/file.ext')

result = mindee_client.enqueue_and_parse(
input_source,
Mindee::Product::Generated::GeneratedV1,
Mindee::Product::Universal::Universal,
endpoint: endpoint
)

Expand Down Expand Up @@ -225,23 +227,19 @@ There's more to it than that for those that need more features, or want to
customize the experience.

* [Ruby Overview](https://developers.mindee.com/docs/ruby-getting-started)
* [Custom OCR Ruby (Deprecated)](https://developers.mindee.com/docs/ruby-api-builder-ocr)
* [Generated API Ruby](https://developers.mindee.com/docs/ruby-generated-ocr)
* [Universal API Ruby](https://developers.mindee.com/docs/ruby-universal-ocr)
* [Invoice OCR Ruby](https://developers.mindee.com/docs/ruby-invoice-ocr)
* [International Id OCR Ruby](https://developers.mindee.com/docs/ruby-international-id-ocr)
* [Financial Document OCR Ruby](https://developers.mindee.com/docs/ruby-financial-document-ocr)
* [Passport OCR Ruby](https://developers.mindee.com/docs/ruby-passport-ocr)
* [Proof of Address OCR Ruby](https://developers.mindee.com/docs/ruby-proof-of-address-ocr)
* [Receipt OCR Ruby](https://developers.mindee.com/docs/ruby-receipt-ocr)
* [Resume OCR Ruby](https://developers.mindee.com/docs/ruby-resume-ocr)
* [EU License Plate OCR Ruby](https://developers.mindee.com/docs/ruby-eu-license-plate-ocr)
* [EU Driver License OCR Ruby](https://developers.mindee.com/docs/ruby-eu-driver-license-ocr)
* [FR Bank Account Details OCR Ruby](https://developers.mindee.com/docs/ruby-fr-bank-account-details-ocr)
* [FR Bank Statement OCR Ruby](https://developers.mindee.com/docs/ruby-fr-bank-statement-ocr)
* [FR Health Card OCR Ruby](https://developers.mindee.com/docs/ruby-fr-health-card-ocr)
* [FR ID Card OCR Ruby](https://developers.mindee.com/docs/ruby-fr-carte-nationale-didentite-ocr)
* [US Bank Check OCR Ruby](https://developers.mindee.com/docs/ruby-us-bank-check-ocr)
* [US Driver License OCR Ruby](https://developers.mindee.com/docs/ruby-us-driver-license-ocr)
* [US W9 API Ruby](https://developers.mindee.com/docs/ruby-us-w9-ocr)
* [Barcode Reader API Ruby](https://developers.mindee.com/docs/ruby-barcode-reader-ocr)
* [Cropper API Ruby](https://developers.mindee.com/docs/ruby-cropper-ocr)
Expand Down
46 changes: 10 additions & 36 deletions bin/mindee.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,12 @@

options = {}
DOCUMENTS = {
"custom" => {
description: "Custom document type from API builder",
doc_class: Mindee::Product::Custom::CustomV1,
sync: true,
async: false,
},
"generated" => {
description: "Generated document type from API builder",
doc_class: Mindee::Product::Generated::GeneratedV1,
"universal" => {
description: "Universal document type from API builder",
doc_class: Mindee::Product::Universal::Universal,
sync: true,
async: true,
},
"proof-of-address" => {
description: 'Proof of Address',
doc_class: Mindee::Product::ProofOfAddress::ProofOfAddressV1,
sync: true,
async: false,
},
"cropper" => {
description: 'Cropper',
doc_class: Mindee::Product::Cropper::CropperV1,
Expand Down Expand Up @@ -79,12 +67,6 @@
sync: true,
async: false,
},
"eu-driver-license" => {
description: "EU Driver License",
doc_class: Mindee::Product::EU::DriverLicense::DriverLicenseV1,
sync: true,
async: false,
},
"fr-bank-account-details" => {
description: "FR Bank Account Details",
doc_class: Mindee::Product::FR::BankAccountDetails::BankAccountDetailsV2,
Expand Down Expand Up @@ -121,12 +103,6 @@
sync: true,
async: false,
},
"us-driver-license" => {
description: "US Driver License",
doc_class: Mindee::Product::US::DriverLicense::DriverLicenseV1,
sync: true,
async: false,
},
"us-heathcare-card" => {
description: "US Healthcare Card",
doc_class: Mindee::Product::US::HealthcareCard::HealthcareCardV1,
Expand Down Expand Up @@ -154,7 +130,7 @@
on_min_pages: 0,
}

# Initializes custom & generated-specific options
# Initializes universal-specific options
# @param cli_parser [OptionParser]
def custom_subcommand(cli_parser, options)
cli_parser.on('-v [VERSION]', '--version [VERSION]', 'Model version for the API') do |v|
Expand Down Expand Up @@ -183,10 +159,8 @@ def custom_subcommand(cli_parser, options)
opts.on('-F', '--fix-pdf', "Attempts to fix broken PDF files before sending them to the server.") do |v|
options[:fix_pdf] = true
end
if (doc_key != 'custom' && doc_key != 'generated')
opts.banner = "Product: #{doc_value[:description]}. \nUsage: mindee.rb #{doc_key} [options] file"
else
opts.banner = "#{doc_value[:description]}. \nUsage: \nmindee.rb custom [options] endpoint_name file\nor\nmindee.rb generated [options] endpoint_name file"
if doc_key != 'universal'
opts.banner = "#{doc_value[:description]}. \nUsage: \nmindee.rb universal [options] endpoint_name file\nor\nmindee.rb universal [options] endpoint_name file"
custom_subcommand(opts, options)
end
if doc_value[:async]
Expand All @@ -206,13 +180,13 @@ def custom_subcommand(cli_parser, options)
end

command = ARGV.shift
if !DOCUMENTS.include?(command)
unless DOCUMENTS.include?(command)
abort(global_parser.help)
end
doc_class = DOCUMENTS[command][:doc_class]
product_parser[command].parse!

if command == 'custom' || command == 'generated'
if command == 'universal'
if ARGV.length < 2
$stderr.puts "The '#{command}' command requires both ENDPOINT_NAME and file arguments."
abort(product_parser[command].help)
Expand All @@ -229,13 +203,13 @@ def custom_subcommand(cli_parser, options)
end

mindee_client = Mindee::Client.new(api_key: options[:api_key])
if (options[:file_path].start_with?("https://"))
if options[:file_path].start_with?("https://")
input_source = mindee_client.source_from_url(options[:file_path])
else
input_source = mindee_client.source_from_path(options[:file_path], fix_pdf: options[:fix_pdf])
end

if command == 'custom' || command == 'generated'
if command == 'universal'
custom_endpoint = mindee_client.create_endpoint(
endpoint_name: endpoint_name,
account_name: options[:account_name],
Expand Down
33 changes: 0 additions & 33 deletions docs/code_samples/custom_v1.txt

This file was deleted.

2 changes: 1 addition & 1 deletion docs/code_samples/default.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ custom_endpoint = mindee_client.create_endpoint(
# Parse the file
result = mindee_client.parse(
input_source,
Mindee::Product::Generated::GeneratedV1,
Mindee::Product::Universal::Universal,
endpoint: custom_endpoint
)

Expand Down
2 changes: 1 addition & 1 deletion docs/code_samples/default_async.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ custom_endpoint = mindee_client.create_endpoint(
# Parse the file
result = mindee_client.enqueue_and_parse(
input_source,
Mindee::Product::Generated::GeneratedV1,
Mindee::Product::Universal::Universal,
endpoint: custom_endpoint
)

Expand Down
19 changes: 0 additions & 19 deletions docs/code_samples/eu_driver_license_v1.txt

This file was deleted.

19 changes: 0 additions & 19 deletions docs/code_samples/proof_of_address_v1.txt

This file was deleted.

19 changes: 0 additions & 19 deletions docs/code_samples/us_driver_license_v1.txt

This file was deleted.

Loading