Class: Jbr::Quote

Inherits:
Resource show all
Defined in:
lib/jbr/quote.rb

Overview

A price a Jobber user sent to their client.

Direct Known Subclasses

Mock::Quote

Constant Summary collapse

FIND =

The query that reads one quote and the request it came from.

<<~GRAPHQL
  query($id: EncodedId!) {
    quote(id: $id) { id request { id } }
  }
GRAPHQL

Instance Attribute Summary collapse

Attributes inherited from Resource

#id

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Jbr::Resource

Instance Attribute Details

#request_idString? (readonly)

Returns the ID of the request the quote answers.

Returns:

  • (String, nil)

    the ID of the request the quote answers.



12
13
14
# File 'lib/jbr/quote.rb', line 12

def request_id
  @request_id
end

Instance Method Details

#find(id) ⇒ Quote?

Returns itself, or nil when Jobber has no such quote.

Parameters:

  • id (String)

    the Jobber ID of the quote.

Returns:

  • (Quote, nil)

    itself, or nil when Jobber has no such quote.



16
17
18
19
20
21
22
23
# File 'lib/jbr/quote.rb', line 16

def find(id)
  output = @oauth.query FIND, variables: { id: id  }
  return unless quote = output['quote']

  @id = quote['id']
  @request_id = quote.dig 'request', 'id'
  self
end