mindee 5.4.0 → 5.6.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.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.betterleaks.toml +15 -0
  3. data/.editorconfig +1 -1
  4. data/CHANGELOG.md +14 -0
  5. data/CONTRIBUTING.md +88 -0
  6. data/bin/mindee.rb +4 -1
  7. data/bin/v1/products.rb +0 -6
  8. data/bin/v2/parser.rb +40 -45
  9. data/bin/v2/search_commands.rb +100 -0
  10. data/lib/mindee/v1/client.rb +1 -75
  11. data/lib/mindee/v1/http.rb +0 -1
  12. data/lib/mindee/v1/product.rb +0 -3
  13. data/lib/mindee/v2/client.rb +62 -36
  14. data/lib/mindee/v2/client_options/base_product_parameters.rb +162 -0
  15. data/lib/mindee/v2/client_options/base_search_parameters.rb +51 -0
  16. data/lib/mindee/v2/client_options.rb +4 -0
  17. data/lib/mindee/v2/http/mindee_api_v2.rb +59 -78
  18. data/lib/mindee/v2/parsing/search/base_search_response.rb +47 -0
  19. data/lib/mindee/v2/parsing/search/model_webhook.rb +3 -3
  20. data/lib/mindee/v2/parsing/search/pagination_metadata.rb +1 -1
  21. data/lib/mindee/v2/parsing/search/search_models.rb +2 -1
  22. data/lib/mindee/v2/parsing/search/search_rag_document.rb +60 -0
  23. data/lib/mindee/v2/parsing/search/search_rag_documents.rb +39 -0
  24. data/lib/mindee/v2/parsing/search/search_response.rb +2 -29
  25. data/lib/mindee/v2/parsing/search.rb +5 -1
  26. data/lib/mindee/v2/product/base_product.rb +2 -2
  27. data/lib/mindee/v2/product/classification/classification_classifier.rb +5 -5
  28. data/lib/mindee/v2/product/classification/params/classification_parameters.rb +1 -1
  29. data/lib/mindee/v2/product/crop/crop_item.rb +5 -5
  30. data/lib/mindee/v2/product/crop/params/crop_parameters.rb +1 -1
  31. data/lib/mindee/v2/product/extraction/params/extraction_parameters.rb +2 -2
  32. data/lib/mindee/v2/product/ocr/params/ocr_parameters.rb +1 -1
  33. data/lib/mindee/v2/product/split/params/split_parameters.rb +1 -1
  34. data/lib/mindee/v2/product/split/split_range.rb +5 -5
  35. data/lib/mindee/v2/search/models/model_search_parameters.rb +54 -0
  36. data/lib/mindee/v2/search/models/model_search_response.rb +28 -0
  37. data/lib/mindee/v2/search/rag_documents/rag_document_search_parameters.rb +52 -0
  38. data/lib/mindee/v2/search/rag_documents/rag_document_search_response.rb +28 -0
  39. data/lib/mindee/v2/search.rb +6 -0
  40. data/lib/mindee/v2.rb +2 -0
  41. data/lib/mindee/version.rb +1 -1
  42. data/mindee.gemspec +1 -1
  43. data/prek.toml +45 -0
  44. data/sig/custom/net_http.rbs +1 -1
  45. data/sig/mindee/v1/client.rbs +1 -15
  46. data/sig/mindee/v2/client.rbs +11 -4
  47. data/sig/mindee/v2/client_options/base_product_parameters.rbs +41 -0
  48. data/sig/mindee/v2/client_options/base_search_parameters.rbs +19 -0
  49. data/sig/mindee/v2/http/mindee_api_v2.rbs +19 -15
  50. data/sig/mindee/v2/parsing/search/base_search_response.rbs +19 -0
  51. data/sig/mindee/v2/parsing/search/search_rag_document.rbs +23 -0
  52. data/sig/mindee/v2/parsing/search/search_rag_documents.rbs +16 -0
  53. data/sig/mindee/v2/parsing/search/search_response.rbs +4 -9
  54. data/sig/mindee/v2/product/base_product.rbs +3 -3
  55. data/sig/mindee/v2/product/classification/classification_classifier.rbs +1 -1
  56. data/sig/mindee/v2/product/classification/params/classification_parameters/classification_parameters.rbs +1 -1
  57. data/sig/mindee/v2/product/crop/crop_item.rbs +1 -1
  58. data/sig/mindee/v2/product/crop/params/crop_parameters/crop_parameters.rbs +1 -1
  59. data/sig/mindee/v2/product/extraction/params/extraction_parameters.rbs +1 -1
  60. data/sig/mindee/v2/product/ocr/params/ocr_parameters/ocr_parameters.rbs +1 -1
  61. data/sig/mindee/v2/product/split/params/split_parameters/split_parameters.rbs +1 -1
  62. data/sig/mindee/v2/product/split/split_range.rbs +1 -1
  63. data/sig/mindee/v2/search/models/model_search_parameters.rbs +22 -0
  64. data/sig/mindee/v2/search/models/model_search_response.rbs +17 -0
  65. data/sig/mindee/v2/search/rag_documents/rag_document_search_parameters.rbs +22 -0
  66. data/sig/mindee/v2/search/rag_documents/rag_document_search_response.rbs +17 -0
  67. metadata +28 -32
  68. data/.pre-commit-config.yaml +0 -36
  69. data/docs/code_samples/bank_account_details_v1.txt +0 -24
  70. data/docs/code_samples/barcode_reader_v1.txt +0 -24
  71. data/docs/code_samples/idcard_fr_v1.txt +0 -24
  72. data/docs/code_samples/workflow_execution.txt +0 -28
  73. data/lib/mindee/input/base_parameters.rb +0 -156
  74. data/lib/mindee/v1/http/workflow_endpoint.rb +0 -93
  75. data/lib/mindee/v1/product/barcode_reader/barcode_reader_v1.rb +0 -47
  76. data/lib/mindee/v1/product/barcode_reader/barcode_reader_v1_document.rb +0 -47
  77. data/lib/mindee/v1/product/barcode_reader/barcode_reader_v1_page.rb +0 -38
  78. data/lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v1.rb +0 -49
  79. data/lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_document.rb +0 -49
  80. data/lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_page.rb +0 -40
  81. data/lib/mindee/v1/product/fr/id_card/id_card_v1.rb +0 -49
  82. data/lib/mindee/v1/product/fr/id_card/id_card_v1_document.rb +0 -106
  83. data/lib/mindee/v1/product/fr/id_card/id_card_v1_page.rb +0 -57
  84. data/sig/mindee/input/base_parameters.rbs +0 -36
  85. data/sig/mindee/v1/http/workflow_endpoint.rbs +0 -22
  86. data/sig/mindee/v1/product/barcode_reader/barcode_reader_v1.rbs +0 -13
  87. data/sig/mindee/v1/product/barcode_reader/barcode_reader_v1_document.rbs +0 -16
  88. data/sig/mindee/v1/product/barcode_reader/barcode_reader_v1_page.rbs +0 -17
  89. data/sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v1.rbs +0 -15
  90. data/sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_document.rbs +0 -19
  91. data/sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_page.rbs +0 -19
  92. data/sig/mindee/v1/product/fr/id_card/id_card_v1.rbs +0 -15
  93. data/sig/mindee/v1/product/fr/id_card/id_card_v1_document.rbs +0 -26
  94. data/sig/mindee/v1/product/fr/id_card/id_card_v1_page.rbs +0 -20
@@ -1,24 +0,0 @@
1
- #
2
- # Install the Ruby client library by running:
3
- # gem install mindee
4
- #
5
-
6
- require 'mindee'
7
-
8
- # Init a new client
9
- mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key')
10
-
11
- # Load a file from disk
12
- input_source = mindee_client.source_from_path('/path/to/the/file.ext')
13
-
14
- # Parse the file
15
- result = mindee_client.parse(
16
- input_source,
17
- Mindee::V1::Product::FR::BankAccountDetails::BankAccountDetailsV1
18
- )
19
-
20
- # Print a full summary of the parsed data in RST format
21
- puts result.document
22
-
23
- # Print the document-level parsed data
24
- # puts result.document.inference.prediction
@@ -1,24 +0,0 @@
1
- #
2
- # Install the Ruby client library by running:
3
- # gem install mindee
4
- #
5
-
6
- require 'mindee'
7
-
8
- # Init a new client
9
- mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key')
10
-
11
- # Load a file from disk
12
- input_source = mindee_client.source_from_path('/path/to/the/file.ext')
13
-
14
- # Parse the file
15
- result = mindee_client.parse(
16
- input_source,
17
- Mindee::V1::Product::BarcodeReader::BarcodeReaderV1
18
- )
19
-
20
- # Print a full summary of the parsed data in RST format
21
- puts result.document
22
-
23
- # Print the document-level parsed data
24
- # puts result.document.inference.prediction
@@ -1,24 +0,0 @@
1
- #
2
- # Install the Ruby client library by running:
3
- # gem install mindee
4
- #
5
-
6
- require 'mindee'
7
-
8
- # Init a new client
9
- mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key')
10
-
11
- # Load a file from disk
12
- input_source = mindee_client.source_from_path('/path/to/the/file.ext')
13
-
14
- # Parse the file
15
- result = mindee_client.parse(
16
- input_source,
17
- Mindee::V1::Product::FR::IdCard::IdCardV1
18
- )
19
-
20
- # Print a full summary of the parsed data in RST format
21
- puts result.document
22
-
23
- # Print the document-level parsed data
24
- # puts result.document.inference.prediction
@@ -1,28 +0,0 @@
1
- #
2
- # Install the Ruby client library by running:
3
- # gem install mindee
4
- #
5
-
6
- require 'mindee'
7
-
8
- workflow_id = 'workflow-id'
9
-
10
- # Init a new client
11
- mindee_client = Mindee::V1::Client.new
12
-
13
- # Load a file from disk
14
- input_source = mindee_client.source_from_path('path/to/my/file.ext')
15
-
16
- # Send the file to the workflow
17
- result = mindee_client.execute_workflow(
18
- input_source,
19
- workflow_id,
20
- # options: { # Optionally, you can provide the following parameters:
21
- # document_alias: 'my-document-alias', # Potential alias for the document
22
- # priority: Mindee::V1::Parsing::Common::ExecutionPriority::LOW, # Priority of the execution
23
- # rag: true # Whether to enable Retrieval-Augmented Generation
24
- # }
25
- )
26
-
27
- # Print the execution's ID to make sure it worked
28
- puts result.execution.id
@@ -1,156 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mindee
4
- module Input
5
- # Base class for parameters accepted by all V2 endpoints.
6
- class BaseParameters
7
- # @return [String] ID of the model (required).
8
- attr_reader :model_id
9
-
10
- # @return [String, nil] Optional alias for the file.
11
- attr_reader :file_alias
12
-
13
- # @return [Array<String>, nil] Optional list of Webhooks IDs to propagate the API response to.
14
- attr_reader :webhook_ids
15
-
16
- # @return [PollingOptions] Options for polling. Set only if having timeout issues.
17
- attr_reader :polling_options
18
-
19
- # @return [Boolean, nil] Whether to close the file after parsing.
20
- attr_reader :close_file
21
-
22
- # @param [String] model_id ID of the model
23
- # @param [String, nil] file_alias File alias, if applicable.
24
- # @param [Array<String>, nil] webhook_ids List of webhook IDs to propagate the API response to.
25
- # @param [Hash, PollingOptions, nil] polling_options Options for polling. Set only if having timeout issues.
26
- # @param [Boolean, nil] close_file Whether to close the file after parsing.
27
- def initialize(
28
- model_id,
29
- file_alias: nil,
30
- webhook_ids: nil,
31
- polling_options: nil,
32
- close_file: true
33
- )
34
- raise Error::MindeeInputError, 'Model ID is required.' if model_id.empty? || model_id.nil?
35
-
36
- @model_id = model_id
37
- @file_alias = file_alias
38
- @webhook_ids = webhook_ids || []
39
- @polling_options = get_clean_polling_options(polling_options)
40
- @close_file = close_file.nil? || close_file
41
- end
42
-
43
- # Sets polling options after normalizing hash inputs.
44
- # @param [Hash, PollingOptions, nil] polling_options
45
- # @return [PollingOptions]
46
- def polling_options=(polling_options)
47
- @polling_options = get_clean_polling_options(polling_options)
48
- end
49
-
50
- # @return [String] Slug for the endpoint.
51
- def self.slug
52
- if self == BaseParameters
53
- raise NotImplementedError, 'Cannot access `slug` directly on the BaseParameters class.'
54
- end
55
-
56
- ''
57
- end
58
-
59
- # @return [String] Slug for the endpoint.
60
- def slug
61
- self.class.slug
62
- end
63
-
64
- # Load from a hash
65
- # @param [Hash] params Parameters to provide as a hash.
66
- # @return [BaseParameters]
67
- def self.from_hash(params: {})
68
- load_from_hash(params: params)
69
- new(
70
- params[:model_id],
71
- file_alias: params[:file_alias],
72
- webhook_ids: params[:webhook_ids],
73
- polling_options: params[:polling_options],
74
- close_file: params[:close_file]
75
- )
76
- end
77
-
78
- # Loads a prediction from a Hash.
79
- # @param [Hash] params Parameters to provide as a hash.
80
- # @return [Hash]
81
- def self.load_from_hash(params: {})
82
- params.transform_keys!(&:to_sym)
83
-
84
- if params.empty? || params[:model_id].nil? || params[:model_id].empty?
85
- raise Error::MindeeInputError, 'Model ID is required.'
86
- end
87
-
88
- polling_options_input = params.fetch(:page_options, PollingOptions.new)
89
- if polling_options_input.is_a?(Hash)
90
- polling_options_input = polling_options_input.transform_keys(&:to_sym)
91
- PollingOptions.new(
92
- initial_delay_sec: polling_options_input.fetch(:initial_delay_sec, 2.0),
93
- delay_sec: polling_options_input.fetch(:delay_sec, 1.5),
94
- max_retries: polling_options_input.fetch(:max_retries, 80)
95
- )
96
- end
97
- params
98
- end
99
-
100
- # Appends base form data to the provided array.
101
- # @param [Array] form_data Array of form fields
102
- # @return [Array]
103
- def append_form_data(form_data)
104
- form_data.push(['alias', @file_alias]) if @file_alias
105
- webhook_ids = @webhook_ids || []
106
- form_data.push(['webhook_ids', webhook_ids.join(',')]) unless @webhook_ids.nil? || webhook_ids.empty?
107
- form_data
108
- end
109
-
110
- # Validates the parameters for async auto-polling
111
- def validate_async_params
112
- min_delay_sec = 1
113
- min_initial_delay_sec = 1
114
- min_retries = 2
115
-
116
- if @polling_options.delay_sec < min_delay_sec
117
- raise ArgumentError,
118
- "Cannot set auto-poll delay to less than #{min_delay_sec} second(s)"
119
- end
120
- if @polling_options.initial_delay_sec < min_initial_delay_sec
121
- raise ArgumentError,
122
- "Cannot set initial parsing delay to less than #{min_initial_delay_sec} second(s)"
123
- end
124
- return unless @polling_options.max_retries < min_retries
125
-
126
- raise ArgumentError,
127
- "Cannot set auto-poll retries to less than #{min_retries}"
128
- end
129
-
130
- private
131
-
132
- # Cleans a proper polling options object potentially from a hash.
133
- # @param [Hash, PollingOptions, nil] polling_options Polling options.
134
- # @return [PollingOptions] Valid polling options object.
135
- def get_clean_polling_options(polling_options)
136
- return PollingOptions.new if polling_options.is_a?(PollingOptions)
137
-
138
- if polling_options.is_a?(Hash)
139
- polling_options = polling_options.transform_keys(&:to_sym)
140
- output_polling_options = PollingOptions.new(
141
- initial_delay_sec: polling_options.fetch(:initial_delay_sec, 2.0),
142
- delay_sec: polling_options.fetch(:delay_sec, 1.5),
143
- max_retries: polling_options.fetch(:max_retries, 80)
144
- )
145
- else
146
- output_polling_options = if polling_options.is_a?(PollingOptions)
147
- polling_options || PollingOptions.new
148
- else
149
- PollingOptions.new
150
- end
151
- end
152
- output_polling_options
153
- end
154
- end
155
- end
156
- end
@@ -1,93 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'json'
4
- require 'net/http'
5
- require_relative '../../http/http_error_handler'
6
-
7
- module Mindee
8
- module V1
9
- module HTTP
10
- # Handles the routing for workflow calls.
11
- class WorkflowEndpoint
12
- # @return [String]
13
- attr_reader :api_key
14
- # @return [Integer]
15
- attr_reader :request_timeout
16
- # @return [String]
17
- attr_reader :url
18
-
19
- def initialize(workflow_id, api_key: '')
20
- @request_timeout = ENV.fetch(REQUEST_TIMEOUT_ENV_NAME, TIMEOUT_DEFAULT).to_i
21
- @api_key = api_key.nil? || api_key.empty? ? ENV.fetch(API_KEY_ENV_NAME, API_KEY_DEFAULT) : api_key
22
- base_url = ENV.fetch(BASE_URL_ENV_NAME, BASE_URL_DEFAULT)
23
- @url = "#{base_url.chomp('/')}/workflows/#{workflow_id}/executions"
24
- end
25
-
26
- # Sends a document to the workflow.
27
- # @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
28
- # @param opts [WorkflowOptions] Options to configure workflow execution behavior.
29
- # @return [Array]
30
- def execute_workflow(input_source, opts)
31
- check_api_key
32
- response = workflow_execution_req_post(input_source, opts)
33
- if response.nil?
34
- raise Mindee::Error::MindeeHTTPError.new(
35
- { code: 0, details: 'Server response was nil.', message: 'Unknown error.' }, @url, 0
36
- )
37
- end
38
-
39
- hashed_response = JSON.parse(response.body, object_class: Hash)
40
- return [hashed_response, response.body] if Mindee::HTTP::ResponseValidation.valid_async_response?(response)
41
-
42
- Mindee::HTTP::ResponseValidation.clean_request!(response)
43
- error = Mindee::HTTP::ErrorHandler.handle_error(@url_name, response)
44
- raise error
45
- end
46
-
47
- # @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
48
- # @param opts [WorkflowOptions] Options to configure workflow execution behavior.
49
- # @return [Net::HTTPResponse, nil]
50
- def workflow_execution_req_post(input_source, opts)
51
- uri = URI(@url)
52
- params = {} # : Hash[String | Symbol, untyped]
53
- params[:full_text_ocr] = 'true' if opts.full_text
54
- params[:rag] = 'true' if opts.rag
55
- uri.query = URI.encode_www_form(params) if params.any?
56
-
57
- headers = {
58
- 'Authorization' => "Token #{@api_key}",
59
- 'User-Agent' => USER_AGENT,
60
- }
61
- req = Net::HTTP::Post.new(uri, headers)
62
- form_data = [] # : Array[untyped]
63
- if input_source.is_a?(Mindee::Input::Source::URLInputSource)
64
- form_data.push ['document', input_source.url]
65
- else
66
- form_data.push ['document', *input_source.read_contents(close: opts.close_file)]
67
- end
68
- form_data.push ['alias', opts.document_alias] if opts.document_alias
69
- form_data.push ['public_url', opts.public_url] if opts.public_url
70
- form_data.push ['priority', opts.priority.to_s] if opts.priority
71
-
72
- req.set_form(form_data, 'multipart/form-data')
73
- req['Transfer-Encoding'] = 'chunked'
74
-
75
- response = nil
76
- Net::HTTP.start(uri.hostname, uri.port, use_ssl: true, read_timeout: @request_timeout) do |http|
77
- response = http.request(req)
78
- end
79
- response
80
- end
81
-
82
- # Checks API key
83
- def check_api_key
84
- return unless @api_key.nil? || @api_key.empty?
85
-
86
- raise Error::MindeeConfigurationError, "Missing API key. Check your Client Configuration.\n" \
87
- "You can set this using the '#{HTTP::API_KEY_ENV_NAME}'" \
88
- 'environment variable.'
89
- end
90
- end
91
- end
92
- end
93
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../../parsing'
4
- require_relative 'barcode_reader_v1_document'
5
- require_relative 'barcode_reader_v1_page'
6
-
7
- module Mindee
8
- module V1
9
- module Product
10
- # Barcode Reader module.
11
- module BarcodeReader
12
- # Barcode Reader API version 1 inference prediction.
13
- class BarcodeReaderV1 < Mindee::V1::Parsing::Common::Inference
14
- @endpoint_name = 'barcode_reader'
15
- @endpoint_version = '1'
16
- @has_async = false
17
- @has_sync = true
18
-
19
- # @param prediction [Hash]
20
- def initialize(prediction)
21
- super
22
- @prediction = BarcodeReaderV1Document.new(prediction['prediction'], nil)
23
- @pages = []
24
- prediction['pages'].each do |page|
25
- @pages.push(BarcodeReaderV1Page.new(page))
26
- end
27
- end
28
-
29
- class << self
30
- # Name of the endpoint for this product.
31
- # @return [String]
32
- attr_reader :endpoint_name
33
- # Version for this product.
34
- # @return [String]
35
- attr_reader :endpoint_version
36
- # Whether this product has access to an asynchronous endpoint.
37
- # @return [bool]
38
- attr_reader :has_async
39
- # Whether this product has access to synchronous endpoint.
40
- # @return [bool]
41
- attr_reader :has_sync
42
- end
43
- end
44
- end
45
- end
46
- end
47
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../../parsing'
4
-
5
- module Mindee
6
- module V1
7
- module Product
8
- module BarcodeReader
9
- # Barcode Reader API version 1.0 document data.
10
- class BarcodeReaderV1Document < Mindee::V1::Parsing::Common::Prediction
11
- include Mindee::V1::Parsing::Standard
12
-
13
- # List of decoded 1D barcodes.
14
- # @return [Array<Mindee::V1::Parsing::Standard::StringField>]
15
- attr_reader :codes_1d
16
- # List of decoded 2D barcodes.
17
- # @return [Array<Mindee::V1::Parsing::Standard::StringField>]
18
- attr_reader :codes_2d
19
-
20
- # @param prediction [Hash]
21
- # @param page_id [Integer, nil]
22
- def initialize(prediction, page_id)
23
- super
24
- @codes_1d = [] # : Array[Parsing::Standard::StringField]
25
- prediction['codes_1d'].each do |item|
26
- @codes_1d.push(Parsing::Standard::StringField.new(item, page_id))
27
- end
28
- @codes_2d = [] # : Array[Parsing::Standard::StringField]
29
- prediction['codes_2d'].each do |item|
30
- @codes_2d.push(Parsing::Standard::StringField.new(item, page_id))
31
- end
32
- end
33
-
34
- # @return [String]
35
- def to_s
36
- codes_1d = @codes_1d.join("\n #{' ' * 13}")
37
- codes_2d = @codes_2d.join("\n #{' ' * 13}")
38
- out_str = String.new
39
- out_str << "\n:Barcodes 1D: #{codes_1d}".rstrip
40
- out_str << "\n:Barcodes 2D: #{codes_2d}".rstrip
41
- out_str[1..].to_s
42
- end
43
- end
44
- end
45
- end
46
- end
47
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../../parsing'
4
- require_relative 'barcode_reader_v1_document'
5
-
6
- module Mindee
7
- module V1
8
- module Product
9
- module BarcodeReader
10
- # Barcode Reader API version 1.0 page data.
11
- class BarcodeReaderV1Page < Mindee::V1::Parsing::Common::Page
12
- # @param prediction [Hash]
13
- def initialize(prediction)
14
- super
15
- @prediction = if prediction['prediction'].empty?
16
- nil
17
- else
18
- BarcodeReaderV1PagePrediction.new(
19
- prediction['prediction'],
20
- prediction['id']
21
- )
22
- end
23
- end
24
- end
25
-
26
- # Barcode Reader V1 page prediction.
27
- class BarcodeReaderV1PagePrediction < BarcodeReaderV1Document
28
- # @return [String]
29
- def to_s
30
- out_str = String.new
31
- out_str << "\n#{super}"
32
- out_str
33
- end
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../../../parsing'
4
- require_relative 'bank_account_details_v1_document'
5
- require_relative 'bank_account_details_v1_page'
6
-
7
- module Mindee
8
- module V1
9
- module Product
10
- module FR
11
- # Bank Account Details module.
12
- module BankAccountDetails
13
- # Bank Account Details API version 1 inference prediction.
14
- class BankAccountDetailsV1 < Mindee::V1::Parsing::Common::Inference
15
- @endpoint_name = 'bank_account_details'
16
- @endpoint_version = '1'
17
- @has_async = false
18
- @has_sync = true
19
-
20
- # @param prediction [Hash]
21
- def initialize(prediction)
22
- super
23
- @prediction = BankAccountDetailsV1Document.new(prediction['prediction'], nil)
24
- @pages = []
25
- prediction['pages'].each do |page|
26
- @pages.push(BankAccountDetailsV1Page.new(page))
27
- end
28
- end
29
-
30
- class << self
31
- # Name of the endpoint for this product.
32
- # @return [String]
33
- attr_reader :endpoint_name
34
- # Version for this product.
35
- # @return [String]
36
- attr_reader :endpoint_version
37
- # Whether this product has access to an asynchronous endpoint.
38
- # @return [bool]
39
- attr_reader :has_async
40
- # Whether this product has access to synchronous endpoint.
41
- # @return [bool]
42
- attr_reader :has_sync
43
- end
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../../../parsing'
4
-
5
- module Mindee
6
- module V1
7
- module Product
8
- module FR
9
- module BankAccountDetails
10
- # Bank Account Details API version 1.0 document data.
11
- class BankAccountDetailsV1Document < Mindee::V1::Parsing::Common::Prediction
12
- include Mindee::V1::Parsing::Standard
13
-
14
- # The name of the account holder as seen on the document.
15
- # @return [Mindee::V1::Parsing::Standard::StringField]
16
- attr_reader :account_holder_name
17
- # The International Bank Account Number (IBAN).
18
- # @return [Mindee::V1::Parsing::Standard::StringField]
19
- attr_reader :iban
20
- # The bank's SWIFT Business Identifier Code (BIC).
21
- # @return [Mindee::V1::Parsing::Standard::StringField]
22
- attr_reader :swift
23
-
24
- # @param prediction [Hash]
25
- # @param page_id [Integer, nil]
26
- def initialize(prediction, page_id)
27
- super
28
- @account_holder_name = Parsing::Standard::StringField.new(
29
- prediction['account_holder_name'],
30
- page_id
31
- )
32
- @iban = Parsing::Standard::StringField.new(prediction['iban'], page_id)
33
- @swift = Parsing::Standard::StringField.new(prediction['swift'], page_id)
34
- end
35
-
36
- # @return [String]
37
- def to_s
38
- out_str = String.new
39
- out_str << "\n:IBAN: #{@iban}".rstrip
40
- out_str << "\n:Account Holder's Name: #{@account_holder_name}".rstrip
41
- out_str << "\n:SWIFT Code: #{@swift}".rstrip
42
- out_str[1..].to_s
43
- end
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../../../parsing'
4
- require_relative 'bank_account_details_v1_document'
5
-
6
- module Mindee
7
- module V1
8
- module Product
9
- module FR
10
- module BankAccountDetails
11
- # Bank Account Details API version 1.0 page data.
12
- class BankAccountDetailsV1Page < Mindee::V1::Parsing::Common::Page
13
- # @param prediction [Hash]
14
- def initialize(prediction)
15
- super
16
- @prediction = if prediction['prediction'].empty?
17
- nil
18
- else
19
- BankAccountDetailsV1PagePrediction.new(
20
- prediction['prediction'],
21
- prediction['id']
22
- )
23
- end
24
- end
25
- end
26
-
27
- # Bank Account Details V1 page prediction.
28
- class BankAccountDetailsV1PagePrediction < BankAccountDetailsV1Document
29
- # @return [String]
30
- def to_s
31
- out_str = String.new
32
- out_str << "\n#{super}"
33
- out_str
34
- end
35
- end
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../../../parsing'
4
- require_relative 'id_card_v1_document'
5
- require_relative 'id_card_v1_page'
6
-
7
- module Mindee
8
- module V1
9
- module Product
10
- module FR
11
- # Carte Nationale d'Identité module.
12
- module IdCard
13
- # Carte Nationale d'Identité API version 1 inference prediction.
14
- class IdCardV1 < Mindee::V1::Parsing::Common::Inference
15
- @endpoint_name = 'idcard_fr'
16
- @endpoint_version = '1'
17
- @has_async = false
18
- @has_sync = true
19
-
20
- # @param prediction [Hash]
21
- def initialize(prediction)
22
- super
23
- @prediction = IdCardV1Document.new(prediction['prediction'], nil)
24
- @pages = []
25
- prediction['pages'].each do |page|
26
- @pages.push(IdCardV1Page.new(page))
27
- end
28
- end
29
-
30
- class << self
31
- # Name of the endpoint for this product.
32
- # @return [String]
33
- attr_reader :endpoint_name
34
- # Version for this product.
35
- # @return [String]
36
- attr_reader :endpoint_version
37
- # Whether this product has access to an asynchronous endpoint.
38
- # @return [bool]
39
- attr_reader :has_async
40
- # Whether this product has access to synchronous endpoint.
41
- # @return [bool]
42
- attr_reader :has_sync
43
- end
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end