Class: Api2Convert::Model::Job
- Inherits:
-
Object
- Object
- Api2Convert::Model::Job
- Defined in:
- lib/api2convert/model/job.rb
Overview
A conversion job — the central API2Convert resource.
#server and #token are needed to upload local files; #output holds the produced files once #completed?. #raw keeps the full decoded response for fields not surfaced as typed attributes.
Instance Attribute Summary collapse
-
#callback ⇒ Object
readonly
Returns the value of attribute callback.
-
#conversion ⇒ Object
readonly
Returns the value of attribute conversion.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Class Method Summary collapse
Instance Method Summary collapse
-
#canceled? ⇒ Boolean
The job was canceled server-side — terminal, and produced no output.
- #completed? ⇒ Boolean
- #failed? ⇒ Boolean
-
#initialize(id:, status:, token:, server:, callback:, conversion:, input:, output:, errors:, warnings:, raw:) ⇒ Job
constructor
A new instance of Job.
-
#terminal? ⇒ Boolean
Finished (completed, failed or canceled) and will not change further.
Constructor Details
#initialize(id:, status:, token:, server:, callback:, conversion:, input:, output:, errors:, warnings:, raw:) ⇒ Job
Returns a new instance of Job.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/api2convert/model/job.rb', line 14 def initialize(id:, status:, token:, server:, callback:, conversion:, input:, output:, errors:, warnings:, raw:) @id = id @status = status @token = token @server = server @callback = callback @conversion = conversion @input = input @output = output @errors = errors @warnings = warnings @raw = raw freeze end |
Instance Attribute Details
#callback ⇒ Object (readonly)
Returns the value of attribute callback.
11 12 13 |
# File 'lib/api2convert/model/job.rb', line 11 def callback @callback end |
#conversion ⇒ Object (readonly)
Returns the value of attribute conversion.
11 12 13 |
# File 'lib/api2convert/model/job.rb', line 11 def conversion @conversion end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
11 12 13 |
# File 'lib/api2convert/model/job.rb', line 11 def errors @errors end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/api2convert/model/job.rb', line 11 def id @id end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
11 12 13 |
# File 'lib/api2convert/model/job.rb', line 11 def input @input end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
11 12 13 |
# File 'lib/api2convert/model/job.rb', line 11 def output @output end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
11 12 13 |
# File 'lib/api2convert/model/job.rb', line 11 def raw @raw end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
11 12 13 |
# File 'lib/api2convert/model/job.rb', line 11 def server @server end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
11 12 13 |
# File 'lib/api2convert/model/job.rb', line 11 def status @status end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
11 12 13 |
# File 'lib/api2convert/model/job.rb', line 11 def token @token end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
11 12 13 |
# File 'lib/api2convert/model/job.rb', line 11 def warnings @warnings end |
Class Method Details
.from_hash(data) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/api2convert/model/job.rb', line 30 def self.from_hash(data) d = Support::Data.as_object(data) new( id: Support::Data.as_str(d["id"]), status: Status.from_hash(d["status"]), token: Support::Data.nullable_str(d["token"]), server: Support::Data.nullable_str(d["server"]), callback: Support::Data.nullable_str(d["callback"]), conversion: Support::Data.map_objects(d["conversion"]) { |x| Conversion.from_hash(x) }, input: Support::Data.map_objects(d["input"]) { |x| InputFile.from_hash(x) }, output: Support::Data.map_objects(d["output"]) { |x| OutputFile.from_hash(x) }, errors: Support::Data.map_objects(d["errors"]) { |x| JobMessage.from_hash(x) }, warnings: Support::Data.map_objects(d["warnings"]) { |x| JobMessage.from_hash(x) }, raw: d ) end |
Instance Method Details
#canceled? ⇒ Boolean
The job was canceled server-side — terminal, and produced no output.
56 57 58 |
# File 'lib/api2convert/model/job.rb', line 56 def canceled? @status.code == JobStatus::CANCELED end |
#completed? ⇒ Boolean
47 48 49 |
# File 'lib/api2convert/model/job.rb', line 47 def completed? @status.code == JobStatus::COMPLETED end |