This repository was archived by the owner on Mar 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Allow multiple formats and options #8
Open
mmangino
wants to merge
5
commits into
andrusha:master
Choose a base branch
from
elevatedrails:allow_multiple_formats_and_options
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| class OCRSDK::Promise < OCRSDK::AbstractEntity | ||
| include OCRSDK::Verifiers::Status | ||
|
|
||
| attr_reader :task_id, :status, :result_url, :estimate_processing_time | ||
| attr_reader :task_id, :status, :result_urls, :estimate_processing_time | ||
|
|
||
| def self.from_response(xml_string) | ||
| OCRSDK::Promise.new(nil).parse_response xml_string | ||
|
|
@@ -26,7 +26,7 @@ def parse_response(xml_string) | |
| end | ||
|
|
||
| @status = status_to_sym task['status'] | ||
| @result_url = task['resultUrl'] | ||
| @result_urls = [task['resultUrl'], task['resultUrl2'], task['resultUrl3']] | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so now it's always going to return 3 results? this seems like a breaking change to me
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, not at all. The result method still returns the first result so as not to break the api. There are result2 and result3 methods to match the terms in the API. I'm not a huge fan of them, but it matches the ocrsdk api and doesn't break anything. |
||
| @registration_time = DateTime.parse task['registrationTime'] | ||
| @estimate_processing_time = task['estimatedProcessingTime'].to_i | ||
|
|
||
|
|
@@ -55,9 +55,21 @@ def processing? | |
| end | ||
|
|
||
| def result(retry_sleep=OCRSDK.config.retry_wait_time) | ||
| result_with_number(0, retry_sleep) | ||
| end | ||
|
|
||
| def result2(retry_sleep=OCRSDK.config.retry_wait_time) | ||
| result_with_number(1, retry_sleep) | ||
| end | ||
|
|
||
| def result3(retry_sleep=OCRSDK.config.retry_wait_time) | ||
| result_with_number(2, retry_sleep) | ||
| end | ||
|
|
||
| def result_with_number(number, retry_sleep) | ||
| raise OCRSDK::ProcessingFailed if failed? | ||
| retryable tries: OCRSDK.config.number_or_retries, on: OCRSDK::NetworkError, sleep: retry_sleep do | ||
| api_get_result | ||
| api_get_result(number) | ||
| end | ||
| end | ||
|
|
||
|
|
@@ -82,8 +94,8 @@ def api_update_status | |
| raise OCRSDK::NetworkError | ||
| end | ||
|
|
||
| def api_get_result | ||
| RestClient.get @result_url.to_s | ||
| def api_get_result(result_number=0) | ||
| RestClient.get @result_urls[result_number].to_s | ||
| rescue RestClient::ExceptionWithResponse | ||
| raise OCRSDK::NetworkError | ||
| end | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| meow2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| meow3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what kind of options you're going to pass here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mostly pass "readBarcodes" => false