Class: Jbr::Job
Overview
Work a Jobber user accepted and scheduled.
Direct Known Subclasses
Constant Summary collapse
- FIND =
The query that reads one job, its quote and its two timestamps.
<<~GRAPHQL query($id: EncodedId!) { job(id: $id) { id quote { id } startAt completedAt } } GRAPHQL
Instance Attribute Summary collapse
-
#quote_id ⇒ String?
readonly
The ID of the quote the job was won with.
Attributes inherited from Resource
Instance Method Summary collapse
-
#completed_at ⇒ Time
The job completed time.
-
#find(id) ⇒ Job?
Itself, or nil when Jobber has no such job.
-
#scheduled_at ⇒ Time
The job scheduled time.
Methods inherited from Resource
Constructor Details
This class inherits a constructor from Jbr::Resource
Instance Attribute Details
#quote_id ⇒ String? (readonly)
Returns the ID of the quote the job was won with.
12 13 14 |
# File 'lib/jbr/job.rb', line 12 def quote_id @quote_id end |
Instance Method Details
#completed_at ⇒ Time
Returns the job completed time.
33 34 35 |
# File 'lib/jbr/job.rb', line 33 def completed_at Time.iso8601(@completed_at) if @completed_at end |
#find(id) ⇒ Job?
Returns itself, or nil when Jobber has no such job.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jbr/job.rb', line 16 def find(id) output = @oauth.query FIND, variables: { id: id } return unless job = output['job'] @id = job['id'] @quote_id = job.dig 'quote', 'id' @scheduled_at = job['startAt'] @completed_at = job['completedAt'] self end |
#scheduled_at ⇒ Time
Returns the job scheduled time.
28 29 30 |
# File 'lib/jbr/job.rb', line 28 def scheduled_at Time.iso8601(@scheduled_at) if @scheduled_at end |