abbyy-cloud 0.0.5 → 0.0.6
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 +4 -4
- data/.rubocop.yml +7 -13
- data/.travis.yml +1 -1
- data/CHANGELOG.md +11 -0
- data/README.md +29 -0
- data/abbyy-cloud.gemspec +4 -2
- data/lib/abbyy/cloud.rb +14 -26
- data/lib/abbyy/cloud/connection.rb +3 -10
- data/lib/abbyy/cloud/exceptions/response_error.rb +1 -1
- data/lib/abbyy/cloud/models/cost_type.rb +14 -0
- data/lib/abbyy/cloud/models/currency.rb +14 -0
- data/lib/abbyy/cloud/models/direction.rb +0 -1
- data/lib/abbyy/cloud/models/discount.rb +2 -1
- data/lib/abbyy/cloud/models/discount_type.rb +19 -0
- data/lib/abbyy/cloud/models/engine.rb +0 -2
- data/lib/abbyy/cloud/models/error.rb +0 -1
- data/lib/abbyy/cloud/models/file_format.rb +19 -0
- data/lib/abbyy/cloud/models/file_info.rb +33 -0
- data/lib/abbyy/cloud/models/file_link.rb +18 -0
- data/lib/abbyy/cloud/models/file_read_error.rb +20 -0
- data/lib/abbyy/cloud/models/file_read_status.rb +14 -0
- data/lib/abbyy/cloud/models/file_reference.rb +11 -0
- data/lib/abbyy/cloud/models/full_order.rb +46 -0
- data/lib/abbyy/cloud/models/label.rb +14 -0
- data/lib/abbyy/cloud/models/ocr_mode.rb +19 -0
- data/lib/abbyy/cloud/models/ocr_quality.rb +18 -0
- data/lib/abbyy/cloud/models/ocr_settings.rb +16 -0
- data/lib/abbyy/cloud/models/ocr_statistics.rb +13 -0
- data/lib/abbyy/cloud/models/ocr_warning.rb +16 -0
- data/lib/abbyy/cloud/models/ocr_warning_type.rb +29 -0
- data/lib/abbyy/cloud/models/order_statistics.rb +15 -0
- data/lib/abbyy/cloud/models/payment_type.rb +14 -0
- data/lib/abbyy/cloud/models/price.rb +1 -1
- data/lib/abbyy/cloud/models/reading_status.rb +20 -0
- data/lib/abbyy/cloud/models/source_segment.rb +0 -1
- data/lib/abbyy/cloud/models/source_tag.rb +0 -1
- data/lib/abbyy/cloud/models/status.rb +25 -0
- data/lib/abbyy/cloud/models/text_statistics.rb +15 -0
- data/lib/abbyy/cloud/models/transfer_data.rb +0 -3
- data/lib/abbyy/cloud/models/translation.rb +0 -2
- data/lib/abbyy/cloud/models/translation_link.rb +18 -0
- data/lib/abbyy/cloud/models/translation_segment.rb +0 -1
- data/lib/abbyy/cloud/models/translation_type.rb +14 -0
- data/lib/abbyy/cloud/models/unit_price.rb +3 -0
- data/lib/abbyy/cloud/models/unit_type.rb +14 -0
- data/lib/abbyy/cloud/namespaces/files.rb +19 -0
- data/lib/abbyy/cloud/namespaces/orders.rb +17 -0
- data/lib/abbyy/cloud/namespaces/prices.rb +1 -1
- data/lib/abbyy/cloud/operations/base.rb +56 -19
- data/lib/abbyy/cloud/operations/download_file.rb +12 -0
- data/lib/abbyy/cloud/operations/engines.rb +1 -1
- data/lib/abbyy/cloud/operations/find_order.rb +13 -0
- data/lib/abbyy/cloud/operations/prices.rb +1 -1
- data/lib/abbyy/cloud/operations/submit_order.rb +32 -0
- data/lib/abbyy/cloud/operations/translate.rb +1 -1
- data/lib/abbyy/cloud/operations/translate_segments.rb +1 -1
- data/lib/abbyy/cloud/operations/upload_file.rb +22 -0
- data/lib/abbyy/cloud/types.rb +8 -17
- data/spec/feature/abbyy/files_download_spec.rb +57 -0
- data/spec/feature/abbyy/files_upload_spec.rb +129 -0
- data/spec/feature/abbyy/orders_create_spec.rb +245 -0
- data/spec/feature/abbyy/orders_find_spec.rb +116 -0
- data/spec/{abbyy → unit/abbyy}/cloud/connection_spec.rb +1 -1
- data/spec/{abbyy → unit/abbyy}/cloud/models/direction_spec.rb +0 -0
- data/spec/{abbyy → unit/abbyy}/cloud/models/discount_spec.rb +0 -0
- data/spec/{abbyy → unit/abbyy}/cloud/models/engine_spec.rb +0 -0
- data/spec/{abbyy → unit/abbyy}/cloud/models/error_spec.rb +0 -0
- data/spec/unit/abbyy/cloud/models/file_link_spec.rb +51 -0
- data/spec/unit/abbyy/cloud/models/file_reference_spec.rb +24 -0
- data/spec/unit/abbyy/cloud/models/full_order_spec.rb +192 -0
- data/spec/{abbyy → unit/abbyy}/cloud/models/locale_spec.rb +0 -0
- data/spec/unit/abbyy/cloud/models/order_statistics_spec.rb +15 -0
- data/spec/{abbyy → unit/abbyy}/cloud/models/price_spec.rb +0 -8
- data/spec/{abbyy → unit/abbyy}/cloud/models/source_segment_spec.rb +0 -0
- data/spec/{abbyy → unit/abbyy}/cloud/models/source_tag_spec.rb +0 -0
- data/spec/{abbyy → unit/abbyy}/cloud/models/transfer_data_spec.rb +0 -0
- data/spec/unit/abbyy/cloud/models/translation_link_spec.rb +66 -0
- data/spec/{abbyy → unit/abbyy}/cloud/models/translation_segment_spec.rb +0 -0
- data/spec/{abbyy → unit/abbyy}/cloud/models/translation_spec.rb +0 -0
- data/spec/{abbyy → unit/abbyy}/cloud/models/unit_price_spec.rb +0 -0
- data/spec/{abbyy → unit/abbyy}/cloud/response_error_spec.rb +0 -0
- data/spec/{abbyy → unit/abbyy}/cloud/settings_spec.rb +0 -0
- data/spec/{abbyy → unit/abbyy}/cloud_spec.rb +0 -0
- metadata +114 -37
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require_relative "currency"
|
|
2
|
+
require_relative "order_statistics"
|
|
3
|
+
require_relative "label"
|
|
4
|
+
require_relative "locale"
|
|
5
|
+
require_relative "payment_type"
|
|
6
|
+
require_relative "status"
|
|
7
|
+
require_relative "translation_link"
|
|
8
|
+
require_relative "translation_type"
|
|
9
|
+
require_relative "unit_type"
|
|
10
|
+
|
|
11
|
+
class ABBYY::Cloud
|
|
12
|
+
module Models
|
|
13
|
+
class FullOrder < Struct
|
|
14
|
+
attribute :amount, Types::Coercible::Float
|
|
15
|
+
attribute :approval_required, Types::Form::Bool
|
|
16
|
+
attribute :created, Types::Form::Time
|
|
17
|
+
attribute :currency, Types::Currency
|
|
18
|
+
attribute :deadline, Types::Form::Time.optional
|
|
19
|
+
attribute :deleted, Types::Form::Time.optional
|
|
20
|
+
attribute :delivered, Types::Form::Time.optional
|
|
21
|
+
attribute :email, Types::Strict::String
|
|
22
|
+
attribute :from, Types::Locale
|
|
23
|
+
attribute :id, Types::Strict::String
|
|
24
|
+
attribute :is_deleted, Types::Form::Bool
|
|
25
|
+
attribute :is_layout_required, Types::Form::Bool
|
|
26
|
+
attribute :is_manual_estimation, Types::Form::Bool
|
|
27
|
+
attribute :label, Types::Label.optional
|
|
28
|
+
attribute :number, Types::Coercible::Int
|
|
29
|
+
attribute :payment_provider, Types::Strict::String
|
|
30
|
+
attribute :payment_type, Types::PaymentType
|
|
31
|
+
attribute :progress, Types::Coercible::Int
|
|
32
|
+
attribute :started, Types::Form::Time.optional
|
|
33
|
+
attribute :statistics, Types::OrderStatistics
|
|
34
|
+
attribute :status, Types::Status
|
|
35
|
+
attribute :to, Types::FilledArray.member(Types::Locale)
|
|
36
|
+
attribute :translations, Types::Array.member(Types::TranslationLink)
|
|
37
|
+
attribute :type, Types::TranslationType
|
|
38
|
+
attribute :unit_count, Types::Coercible::Int
|
|
39
|
+
attribute :unit_type, Types::UnitType
|
|
40
|
+
attribute :units_count, Types::Hash
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Registers type Types::FullOrder
|
|
44
|
+
Types.register_type FullOrder
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class ABBYY::Cloud
|
|
2
|
+
module Models
|
|
3
|
+
class Label < ::String
|
|
4
|
+
FORMAT = /\A.{1,80}\z/
|
|
5
|
+
|
|
6
|
+
def self.new(string)
|
|
7
|
+
super Types::Strict::String.constrained(format: FORMAT)[string]
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Registers type Types::Label
|
|
12
|
+
Types.register_type Label
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class ABBYY::Cloud
|
|
2
|
+
module Models
|
|
3
|
+
class OcrMode < ::String
|
|
4
|
+
VALUES = %w(
|
|
5
|
+
EditableCopy
|
|
6
|
+
ExactCopy
|
|
7
|
+
FormattedText
|
|
8
|
+
PlainText
|
|
9
|
+
).freeze
|
|
10
|
+
|
|
11
|
+
def self.new(string)
|
|
12
|
+
super Types::Strict::String.constrained(included_in: VALUES)[string]
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Registers type Types::OcrMode
|
|
17
|
+
Types.register_type OcrMode
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class ABBYY::Cloud
|
|
2
|
+
module Models
|
|
3
|
+
class OcrQuality < ::String
|
|
4
|
+
VALUES = %w(
|
|
5
|
+
Fast
|
|
6
|
+
Balanced
|
|
7
|
+
Thorough
|
|
8
|
+
).freeze
|
|
9
|
+
|
|
10
|
+
def self.new(string)
|
|
11
|
+
super Types::Strict::String.constrained(included_in: VALUES)[string]
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Registers type Types::OcrQuality
|
|
16
|
+
Types.register_type OcrQuality
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require_relative "file_format"
|
|
2
|
+
require_relative "ocr_mode"
|
|
3
|
+
require_relative "ocr_quality"
|
|
4
|
+
|
|
5
|
+
class ABBYY::Cloud
|
|
6
|
+
module Models
|
|
7
|
+
class OcrSettings < Struct
|
|
8
|
+
attribute :format, Types::FileFormat
|
|
9
|
+
attribute :mode, Types::OcrMode
|
|
10
|
+
attribute :quality, Types::OcrQuality
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Registers type Types::OcrSettings
|
|
14
|
+
Types.register_type OcrSettings
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class ABBYY::Cloud
|
|
2
|
+
module Models
|
|
3
|
+
class OcrStatistics < Struct
|
|
4
|
+
attribute :exported_pages, Types::Coercible::Int
|
|
5
|
+
attribute :total_characters, Types::Coercible::Int
|
|
6
|
+
attribute :uncertain_characters, Types::Coercible::Int
|
|
7
|
+
attribute :success_part, Types::Coercible::Float
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Registers type Types::OcrStatistics
|
|
11
|
+
Types.register_type OcrStatistics
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require_relative "ocr_warning_type"
|
|
2
|
+
|
|
3
|
+
class ABBYY::Cloud
|
|
4
|
+
module Models
|
|
5
|
+
class OcrWarning < Struct
|
|
6
|
+
attribute :warning_type, Types::OcrWarningType
|
|
7
|
+
attribute :page_number, Types::Coercible::Int
|
|
8
|
+
attribute :dpi, Types::Coercible::Int.optional
|
|
9
|
+
attribute :language_count, Types::Coercible::Int.optional
|
|
10
|
+
attribute :full_warning_message, Types::Strict::String.optional
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Registers type Types::OcrWarning
|
|
14
|
+
Types.register_type OcrWarning
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
class ABBYY::Cloud
|
|
2
|
+
module Models
|
|
3
|
+
class OcrWarningType < ::String
|
|
4
|
+
VALUES = %w(
|
|
5
|
+
BrightnessIsTooHigh
|
|
6
|
+
BrightnessIsTooLow
|
|
7
|
+
ErrorWhenUsingDocumentAuxData
|
|
8
|
+
NoRecognizableBlocksFound
|
|
9
|
+
ProbablyLanguageIsIncorrect
|
|
10
|
+
ResolutionIsLowForTinyTextPhoto
|
|
11
|
+
ResolutionIsLowForTinyTextScanned
|
|
12
|
+
ResolutionIsTooHigh
|
|
13
|
+
ResolutionIsTooLow
|
|
14
|
+
SuspiciousResolution
|
|
15
|
+
TooManyBaseLanguages
|
|
16
|
+
TooManyBaseLanguagesForDetection
|
|
17
|
+
TooManyLanguagesDetected
|
|
18
|
+
UnknownWarning
|
|
19
|
+
).freeze
|
|
20
|
+
|
|
21
|
+
def self.new(string)
|
|
22
|
+
super Types::Strict::String.constrained(included_in: VALUES)[string]
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Registers type Types::OcrWarningType
|
|
27
|
+
Types.register_type OcrWarningType
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require_relative "source_tag"
|
|
2
|
+
|
|
3
|
+
class ABBYY::Cloud
|
|
4
|
+
module Models
|
|
5
|
+
class OrderStatistics < Struct
|
|
6
|
+
attribute :documents_count, Types::Coercible::Int
|
|
7
|
+
attribute :pages_count, Types::Coercible::Int
|
|
8
|
+
attribute :words_count, Types::Coercible::Int
|
|
9
|
+
attribute :chars_count, Types::Coercible::Int
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Registers type Types::OrderStatistics
|
|
13
|
+
Types.register_type OrderStatistics
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class ABBYY::Cloud
|
|
2
|
+
module Models
|
|
3
|
+
class PaymentType < ::String
|
|
4
|
+
VALUES = %w(Manual Balance External).freeze
|
|
5
|
+
|
|
6
|
+
def self.new(string)
|
|
7
|
+
super Types::Strict::String.constrained(included_in: VALUES)[string]
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Registers type Types::PaymentType
|
|
12
|
+
Types.register_type PaymentType
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -7,7 +7,7 @@ class ABBYY::Cloud
|
|
|
7
7
|
# Price details
|
|
8
8
|
class Price < Struct
|
|
9
9
|
attribute :id, Types::Strict::String
|
|
10
|
-
attribute :account_id, Types::Strict::String
|
|
10
|
+
attribute :account_id, Types::Strict::String.optional
|
|
11
11
|
attribute :type, Types::Strict::String
|
|
12
12
|
attribute :from, Types::Locale
|
|
13
13
|
attribute :to, Types::Locale
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class ABBYY::Cloud
|
|
2
|
+
module Models
|
|
3
|
+
class ReadingStatus < ::String
|
|
4
|
+
VALUES = %w(
|
|
5
|
+
New
|
|
6
|
+
Submitted
|
|
7
|
+
InProgress
|
|
8
|
+
Done
|
|
9
|
+
Error
|
|
10
|
+
).freeze
|
|
11
|
+
|
|
12
|
+
def self.new(string)
|
|
13
|
+
super Types::Strict::String.constrained(included_in: VALUES)[string]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Registers type Types::ReadingStatus
|
|
18
|
+
Types.register_type ReadingStatus
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
class ABBYY::Cloud
|
|
2
|
+
module Models
|
|
3
|
+
class Status < ::String
|
|
4
|
+
VALUES = %w(
|
|
5
|
+
New
|
|
6
|
+
Submitted
|
|
7
|
+
PaymentRequired
|
|
8
|
+
Paid
|
|
9
|
+
InProgress
|
|
10
|
+
Done
|
|
11
|
+
Failed
|
|
12
|
+
Accepted
|
|
13
|
+
ReworkRequired
|
|
14
|
+
Canceled
|
|
15
|
+
).freeze
|
|
16
|
+
|
|
17
|
+
def self.new(string)
|
|
18
|
+
super Types::Strict::String.constrained(included_in: VALUES)[string]
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Registers type Types::Status
|
|
23
|
+
Types.register_type Status
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require_relative "source_tag"
|
|
2
|
+
|
|
3
|
+
class ABBYY::Cloud
|
|
4
|
+
module Models
|
|
5
|
+
class TextStatistics < Struct
|
|
6
|
+
attribute :language, Types::Locale
|
|
7
|
+
attribute :pages_count, Types::Coercible::Int
|
|
8
|
+
attribute :words_count, Types::Coercible::Int
|
|
9
|
+
attribute :chars_count, Types::Coercible::Int
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Registers type Types::TextStatistics
|
|
13
|
+
Types.register_type TextStatistics
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require_relative "status"
|
|
2
|
+
require_relative "file_link"
|
|
3
|
+
|
|
4
|
+
class ABBYY::Cloud
|
|
5
|
+
module Models
|
|
6
|
+
class TranslationLink < Struct
|
|
7
|
+
attribute :delivered, Types::Form::Time
|
|
8
|
+
attribute :started, Types::Form::Time
|
|
9
|
+
attribute :progress, Types::Coercible::Int
|
|
10
|
+
attribute :status, Types::Status
|
|
11
|
+
attribute :source_file, Types::FileLink
|
|
12
|
+
attribute :target_file, Types::FileLink
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Registers type Types::TranslationLink
|
|
16
|
+
Types.register_type TranslationLink
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class ABBYY::Cloud
|
|
2
|
+
module Models
|
|
3
|
+
class TranslationType < ::String
|
|
4
|
+
VALUES = %w(mt ht_express ht_professional ht_expert).freeze
|
|
5
|
+
|
|
6
|
+
def self.new(string)
|
|
7
|
+
super Types::Strict::String.constrained(included_in: VALUES)[string]
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Registers type Types::TranslationType
|
|
12
|
+
Types.register_type TranslationType
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class ABBYY::Cloud
|
|
2
|
+
module Models
|
|
3
|
+
class UnitType < ::String
|
|
4
|
+
VALUES = %w(Chars Words Pages Documents).freeze
|
|
5
|
+
|
|
6
|
+
def self.new(string)
|
|
7
|
+
super Types::Strict::String.constrained(included_in: VALUES)[string]
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Registers type Types::UnitType
|
|
12
|
+
Types.register_type UnitType
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require_relative "base"
|
|
2
|
+
|
|
3
|
+
class ABBYY::Cloud
|
|
4
|
+
module Namespaces
|
|
5
|
+
# Namespace for operations with orders
|
|
6
|
+
# @see [https://api.abbyy.cloud/swagger/ui/index#!/File] ABBYY Cloud API
|
|
7
|
+
class Files < Base
|
|
8
|
+
def upload(file, export_format: nil, synthesis_mode: nil, **options)
|
|
9
|
+
options[:exportFormat] = export_format if export_format
|
|
10
|
+
options[:synthesisMode] = synthesis_mode if synthesis_mode
|
|
11
|
+
Operations::UploadFile.new(settings).call(file, **options)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def download(id:, token:)
|
|
15
|
+
Operations::DownloadFile.new(settings).call(id: id, token: token)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require_relative "base"
|
|
2
|
+
|
|
3
|
+
class ABBYY::Cloud
|
|
4
|
+
module Namespaces
|
|
5
|
+
# Namespace for operations with orders
|
|
6
|
+
# @see [https://api.abbyy.cloud/swagger/ui/index#!/Orders] ABBYY Cloud API
|
|
7
|
+
class Orders < Base
|
|
8
|
+
def create(options)
|
|
9
|
+
Operations::SubmitOrder.new(settings).call(options)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def find(id)
|
|
13
|
+
Operations::FindOrder.new(settings).call(id: id)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|