Class: Uploadcare::Resources::DocumentConversion
- Inherits:
-
BaseResource
- Object
- BaseResource
- Uploadcare::Resources::DocumentConversion
- Defined in:
- lib/uploadcare/resources/document_conversion.rb
Overview
Document conversion resource.
Instance Attribute Summary collapse
-
#converted_groups ⇒ Object
Returns the value of attribute converted_groups.
-
#error ⇒ Object
Returns the value of attribute error.
-
#format ⇒ Object
Returns the value of attribute format.
-
#result ⇒ Object
Returns the value of attribute result.
-
#status ⇒ Object
Returns the value of attribute status.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
Class Method Summary collapse
-
.convert_document(params:, options: {}, client: nil, config: Uploadcare.configuration, request_options: {}) ⇒ Hash
Convert a document to a specified format (class method).
-
.info_for(uuid:, client: nil, config: Uploadcare.configuration, request_options: {}) ⇒ Uploadcare::Resources::DocumentConversion
Fetch document conversion capabilities for a file.
-
.status(token:, client: nil, config: Uploadcare.configuration, request_options: {}) ⇒ Uploadcare::Resources::DocumentConversion
Fetch document conversion status for a job token.
Instance Method Summary collapse
-
#fetch_status(token:, request_options: {}) ⇒ self
Get conversion job status.
-
#info(request_options: {}) ⇒ self
Get document format info and possible conversions.
Instance Attribute Details
#converted_groups ⇒ Object
Returns the value of attribute converted_groups.
7 8 9 |
# File 'lib/uploadcare/resources/document_conversion.rb', line 7 def converted_groups @converted_groups end |
#error ⇒ Object
Returns the value of attribute error.
7 8 9 |
# File 'lib/uploadcare/resources/document_conversion.rb', line 7 def error @error end |
#format ⇒ Object
Returns the value of attribute format.
7 8 9 |
# File 'lib/uploadcare/resources/document_conversion.rb', line 7 def format @format end |
#result ⇒ Object
Returns the value of attribute result.
7 8 9 |
# File 'lib/uploadcare/resources/document_conversion.rb', line 7 def result @result end |
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/uploadcare/resources/document_conversion.rb', line 7 def status @status end |
#uuid ⇒ Object
Returns the value of attribute uuid.
7 8 9 |
# File 'lib/uploadcare/resources/document_conversion.rb', line 7 def uuid @uuid end |
Class Method Details
.convert_document(params:, options: {}, client: nil, config: Uploadcare.configuration, request_options: {}) ⇒ Hash
Convert a document to a specified format (class method).
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/uploadcare/resources/document_conversion.rb', line 31 def self.convert_document(params:, options: {}, client: nil, config: Uploadcare.configuration, request_options: {}) resolved_client = resolve_client(client: client, config: config) paths = Array(params[:uuid]).map do |uuid| "#{uuid}/document/-/format/#{params[:format]}/" end Uploadcare::Result.unwrap( resolved_client.api.rest.document_conversions.convert( paths: paths, options: , request_options: ) ) end |
.info_for(uuid:, client: nil, config: Uploadcare.configuration, request_options: {}) ⇒ Uploadcare::Resources::DocumentConversion
Fetch document conversion capabilities for a file.
64 65 66 67 |
# File 'lib/uploadcare/resources/document_conversion.rb', line 64 def self.info_for(uuid:, client: nil, config: Uploadcare.configuration, request_options: {}) resolved_client = resolve_client(client: client, config: config) new({ 'uuid' => uuid }, resolved_client).info(request_options: ) end |
.status(token:, client: nil, config: Uploadcare.configuration, request_options: {}) ⇒ Uploadcare::Resources::DocumentConversion
Fetch document conversion status for a job token.
52 53 54 55 |
# File 'lib/uploadcare/resources/document_conversion.rb', line 52 def self.status(token:, client: nil, config: Uploadcare.configuration, request_options: {}) resolved_client = resolve_client(client: client, config: config) new({}, resolved_client).fetch_status(token: token, request_options: ) end |
Instance Method Details
#fetch_status(token:, request_options: {}) ⇒ self
Get conversion job status.
74 75 76 77 78 79 80 |
# File 'lib/uploadcare/resources/document_conversion.rb', line 74 def fetch_status(token:, request_options: {}) response = Uploadcare::Result.unwrap( client.api.rest.document_conversions.status(token: token, request_options: ) ) assign_attributes(response) self end |
#info(request_options: {}) ⇒ self
Get document format info and possible conversions.
13 14 15 16 17 18 19 20 21 |
# File 'lib/uploadcare/resources/document_conversion.rb', line 13 def info(request_options: {}) raise ArgumentError, 'uuid is required' if uuid.to_s.empty? response = Uploadcare::Result.unwrap( client.api.rest.document_conversions.info(uuid: uuid, request_options: ) ) assign_attributes(response) self end |