Class: Hcp::Job

Inherits:
Resource show all
Extended by:
Queryable
Includes:
Scheduled, Statused, Timestamped
Defined in:
lib/hcp/resources/job.rb

Overview

Work a Housecall Pro user accepted: what it is, who it is for, and what it comes to.

Defined Under Namespace

Classes: Appointment, Invoice

Constant Summary collapse

FILTERS =

What a list of jobs may be narrowed by, against the parameters Housecall Pro takes.

{
  scheduled_at: %i[scheduled_start_min scheduled_start_max],
  ends_at: %i[scheduled_end_min scheduled_end_max],
  customer_id: %i[customer_id],
  employee_ids: %i[employee_ids],
  work_status: %i[work_status],
  location_ids: %i[location_ids],
}
MANY =

The conditions Housecall Pro takes more than one of, and refuses one of.

%i[employee_ids work_status location_ids]
SORTS =

What Housecall Pro will put a list of jobs in order of.

%i[created_at updated_at invoice_number id description work_status]
EXPANDS =

What a job brings back beside itself where it is asked to.

%i[attachments appointments]

Constants included from Statused

Statused::STATUSES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Queryable

all, count, expands, filters, find, first, includes, limit, many, order, sorts, where

Methods included from Scheduled

#completed_at, #on_my_way_at, #schedule, #started_at

Methods included from Statused

#rated?, #work_status

Methods included from Timestamped

#created_at, #updated_at

Methods inherited from Resource

amount, attribute, #id, #initialize, timestamp

Constructor Details

This class inherits a constructor from Hcp::Resource

Class Method Details

.keyObject

What Housecall Pro calls a page of them.



30
# File 'lib/hcp/resources/job.rb', line 30

def self.key = 'jobs'

.pathObject

Where Housecall Pro keeps them.



27
# File 'lib/hcp/resources/job.rb', line 27

def self.path = 'jobs'

Instance Method Details

#addressAddress?

Returns where the work happens.

Returns:

  • (Address, nil)

    where the work happens.



56
# File 'lib/hcp/resources/job.rb', line 56

def address = record Address, 'address'

#appointmentsRelation

Returns the visits the job is booked for.

Returns:

  • (Relation)

    the visits the job is booked for.



65
# File 'lib/hcp/resources/job.rb', line 65

def appointments = nested Job::Appointment, 'appointments'

#assigned_employeesArray<Employee>

Returns the pros the job is assigned to.

Returns:

  • (Array<Employee>)

    the pros the job is assigned to.



62
# File 'lib/hcp/resources/job.rb', line 62

def assigned_employees = records Employee, 'assigned_employees'

#canceled_atTime?

Returns:

  • (Time, nil)

    when the customer canceled the job.

  • (Time, nil)

    the moment Housecall Pro answers as canceled_at.



47
# File 'lib/hcp/resources/job.rb', line 47

timestamp :canceled_at

#customerCustomer?

Returns whose job it is.

Returns:



53
# File 'lib/hcp/resources/job.rb', line 53

def customer = record Customer, 'customer'

#descriptionString?

Returns the description, as Housecall Pro answers it.

Returns:

  • (String, nil)

    the description, as Housecall Pro answers it.



33
# File 'lib/hcp/resources/job.rb', line 33

attribute :description

#invoice_numberString?

Returns the invoice_number, as Housecall Pro answers it.

Returns:

  • (String, nil)

    the invoice_number, as Housecall Pro answers it.



32
# File 'lib/hcp/resources/job.rb', line 32

attribute :invoice_number

#invoicesRelation

Returns the invoices raised for the job.

Returns:

  • (Relation)

    the invoices raised for the job.



71
# File 'lib/hcp/resources/job.rb', line 71

def invoices = nested Job::Invoice, 'invoices'

#lead_sourceString?

Returns the lead_source, as Housecall Pro answers it.

Returns:

  • (String, nil)

    the lead_source, as Housecall Pro answers it.



34
# File 'lib/hcp/resources/job.rb', line 34

attribute :lead_source

#line_itemsRelation

Returns what the job is billed as.

Returns:

  • (Relation)

    what the job is billed as.



68
# File 'lib/hcp/resources/job.rb', line 68

def line_items = nested LineItem, 'line_items'

#locked_atTime?

Returns:

  • (Time, nil)

    when the job was locked against further changes.

  • (Time, nil)

    the moment Housecall Pro answers as locked_at.



44
# File 'lib/hcp/resources/job.rb', line 44

timestamp :locked_at

#notesArray<Note>

Returns what the pros wrote on the job.

Returns:

  • (Array<Note>)

    what the pros wrote on the job.



59
# File 'lib/hcp/resources/job.rb', line 59

def notes = records Note, 'notes'

#original_estimate_idString?

Returns:

  • (String, nil)

    the ID of the estimate the job was won with.

  • (String, nil)

    the original_estimate_id, as Housecall Pro answers it.



37
# File 'lib/hcp/resources/job.rb', line 37

attribute :original_estimate_id

#outstanding_balanceBigDecimal?

Returns the outstanding_balance, which Housecall Pro counts in cents.

Returns:

  • (BigDecimal, nil)

    the outstanding_balance, which Housecall Pro counts in cents.



41
# File 'lib/hcp/resources/job.rb', line 41

amount :outstanding_balance

#subtotalBigDecimal?

Returns the subtotal, which Housecall Pro counts in cents.

Returns:

  • (BigDecimal, nil)

    the subtotal, which Housecall Pro counts in cents.



39
# File 'lib/hcp/resources/job.rb', line 39

amount :subtotal

#tagsArray<String>

Returns what the job is tagged with.

Returns:

  • (Array<String>)

    what the job is tagged with.



50
# File 'lib/hcp/resources/job.rb', line 50

def tags = Array(@node['tags'])

#total_amountBigDecimal?

Returns the total_amount, which Housecall Pro counts in cents.

Returns:

  • (BigDecimal, nil)

    the total_amount, which Housecall Pro counts in cents.



40
# File 'lib/hcp/resources/job.rb', line 40

amount :total_amount