Class: ScreenshotFreeAPI::Resources::Jobs
- Inherits:
-
Object
- Object
- ScreenshotFreeAPI::Resources::Jobs
- Defined in:
- lib/screenshotfreeapi/resources/jobs.rb
Overview
Job polling endpoints.
All screenshot requests are asynchronous — the POST endpoints return a jobId immediately. Use these methods to check progress and retrieve results once the job reaches the “completed” state.
Instance Method Summary collapse
-
#initialize(http) ⇒ Jobs
constructor
A new instance of Jobs.
-
#result(job_id) ⇒ Hash
Retrieve the completed result of a job.
-
#status(job_id) ⇒ Hash
Retrieve the current status of a job.
Constructor Details
#initialize(http) ⇒ Jobs
Returns a new instance of Jobs.
11 12 13 |
# File 'lib/screenshotfreeapi/resources/jobs.rb', line 11 def initialize(http) @http = http end |
Instance Method Details
#result(job_id) ⇒ Hash
Retrieve the completed result of a job.
Only available once ‘status` returns “completed”. Raises NotFoundError if the job is not yet done or was not found.
54 55 56 |
# File 'lib/screenshotfreeapi/resources/jobs.rb', line 54 def result(job_id) @http.request(:get, "/jobs/#{job_id}/result") end |
#status(job_id) ⇒ Hash
Retrieve the current status of a job.
29 30 31 |
# File 'lib/screenshotfreeapi/resources/jobs.rb', line 29 def status(job_id) @http.request(:get, "/jobs/#{job_id}/status") end |