Class: Jbr::Job

Inherits:
Resource show all
Includes:
Cliental, Itemized, Named, Properted
Defined in:
lib/jbr/job.rb

Overview

Work a Jobber user accepted and scheduled.

Direct Known Subclasses

Mock::Job

Constant Summary

Constants included from Cliental

Cliental::FIELDS, Cliental::SELECTION

Instance Attribute Summary

Attributes inherited from Resource

#id

Instance Method Summary collapse

Methods included from Cliental

#client

Methods included from Itemized

#line_items

Methods included from Named

#name

Methods included from Properted

#property, selection

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Jbr::Resource

Instance Method Details

#completed_atTime?

Returns the job completed time.

Returns:

  • (Time, nil)

    the job completed time



38
# File 'lib/jbr/job.rb', line 38

def completed_at = time 'completedAt'

#created_atTime?

Returns the job opening time.

Returns:

  • (Time, nil)

    the job opening time



32
# File 'lib/jbr/job.rb', line 32

def created_at = time 'createdAt'

#instructionsString?

Returns what the work is, in the words whoever opened the job wrote.

Returns:

  • (String, nil)

    what the work is, in the words whoever opened the job wrote.



10
# File 'lib/jbr/job.rb', line 10

def instructions = @node['instructions']

#quote_idString?

Returns the ID of the quote the job was won with.

Returns:

  • (String, nil)

    the ID of the quote the job was won with.



23
# File 'lib/jbr/job.rb', line 23

def quote_id = @node.dig 'quote', 'id'

#quote_totalFloat?

Returns what the quote the job was won with came to.

Returns:

  • (Float, nil)

    what the quote the job was won with came to.



29
# File 'lib/jbr/job.rb', line 29

def quote_total = @node.dig 'quote', 'amounts', 'total'

#scheduled_atTime?

Returns the job scheduled time.

Returns:

  • (Time, nil)

    the job scheduled time



35
# File 'lib/jbr/job.rb', line 35

def scheduled_at = time 'startAt'

#statusString?

Returns where Jobber files the job in its own workflow.

Returns:

  • (String, nil)

    where Jobber files the job in its own workflow.



20
# File 'lib/jbr/job.rb', line 20

def status = @node['jobStatus']

#summaryString

What the job's lines add up to, each as how many of what: 3 Faucet install and 2 Valve change. The lines say what the work was where a title only says what it was called, so this reads better than one — and falls back to Named#name where the job has no lines, or where the query never asked for them. Never nil and never empty.

Returns:

  • (String)

    the lines as a sentence, or the title, or the ID.



17
# File 'lib/jbr/job.rb', line 17

def summary = line_items.map(&:quantified).to_sentence.presence || name

#titleString?

Returns what the job is called, where whoever opened it named it.

Returns:

  • (String, nil)

    what the job is called, where whoever opened it named it.



7
# File 'lib/jbr/job.rb', line 7

def title = @node['title']

#totalFloat?

Returns what the job comes to.

Returns:

  • (Float, nil)

    what the job comes to.



26
# File 'lib/jbr/job.rb', line 26

def total = @node['total']