Skip to content

Commit 5fb12bc

Browse files
committed
♻️ minor cleanup
1 parent 213af85 commit 5fb12bc

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

bin/mindee.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050

5151
options = {
5252
api_key: '',
53-
raise_on_error: true,
5453
print_full: false,
5554
}
5655

@@ -95,9 +94,6 @@ def custom_subcommand(options)
9594
opt.separator('')
9695
opt.separator("subcommands: #{DOCUMENTS.keys.join(', ')}")
9796
opt.separator('')
98-
opt.on('-E', '--no-raise-errors', "raise errors behavior") do |v|
99-
options[:raise_on_error] = false
100-
end
10197
opt.on('-f', '--full', "Print the full data, including pages") do |v|
10298
options[:print_full] = true
10399
end
@@ -114,9 +110,7 @@ def custom_subcommand(options)
114110
exit(1)
115111
end
116112

117-
mindee_client = Mindee::Client.new(
118-
api_key: options[:api_key], raise_on_error: options[:raise_on_error]
119-
)
113+
mindee_client = Mindee::Client.new(api_key: options[:api_key])
120114

121115
if command == 'custom'
122116
if ARGV.length != 2

docs/ruby-getting-started.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,20 @@ The following environment variable will set the global API key:
9292
```shell
9393
MINDEE_API_KEY=my-api-key
9494
```
95-
95+
9696
Then in your code:
9797
```ruby
9898
# Init a new client without an API key
9999
mindee_client = Mindee::Client.new
100100
```
101101

102+
### Setting the Request Timeout
103+
The request timeout can be set using an environment variable:
104+
```shell
105+
MINDEE_REQUEST_TIMEOUT=200
106+
```
107+
108+
102109
## Loading a Document File
103110
Before being able to send a document to the API, it must first be loaded.
104111

lib/mindee/client.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,8 @@ def find_doc_config(document_class, endpoint_name, account_name)
102102
# Mindee API Client.
103103
# See: https://developers.mindee.com/docs/
104104
class Client
105-
# @param raise_on_error [Boolean]
106-
def initialize(api_key: '', raise_on_error: true)
107-
@raise_on_error = raise_on_error
105+
# @param api_key [String]
106+
def initialize(api_key: '')
108107
@doc_configs = {}
109108
@api_key = api_key
110109
init_default_endpoints

lib/mindee/http/endpoint.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def initialize(owner, url_name, version, api_key: '')
2727
@owner = owner
2828
@url_name = url_name
2929
@version = version
30-
@request_timeout = ENV.fetch(REQUEST_TIMEOUT_ENV_NAME, TIMEOUT_DEFAULT)
30+
@request_timeout = ENV.fetch(REQUEST_TIMEOUT_ENV_NAME, TIMEOUT_DEFAULT).to_i
3131
@api_key = api_key.nil? || api_key.empty? ? ENV.fetch(API_KEY_ENV_NAME, API_KEY_DEFAULT) : api_key
3232
@url_root = "#{BASE_URL_DEFAULT}/products/#{@owner}/#{@url_name}/v#{@version}"
3333
end

0 commit comments

Comments
 (0)