Class: Jbr::Request
Overview
A lead on a Jobber user's board: work someone asked them for.
Direct Known Subclasses
Constant Summary collapse
- CREATE =
The mutation that opens a request against a client and a property.
<<~GRAPHQL mutation($input: RequestCreateInput!) { requestCreate(input: $input) { request { id property { id } } userErrors { message } } } GRAPHQL
Instance Attribute Summary collapse
-
#client_id ⇒ String?
readonly
The client the request was opened against.
Attributes inherited from Resource
Instance Method Summary collapse
-
#create(params = {}) ⇒ String
Create a lead in Jobber associated to a new or existing client, matched by phone.
Methods inherited from Resource
Constructor Details
This class inherits a constructor from Jbr::Resource
Instance Attribute Details
#client_id ⇒ String? (readonly)
Returns the client the request was opened against.
12 13 14 |
# File 'lib/jbr/request.rb', line 12 def client_id @client_id end |
Instance Method Details
#create(params = {}) ⇒ String
Create a lead in Jobber associated to a new or existing client, matched by phone.
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/jbr/request.rb', line 23 def create(params = {}) client = @oauth.clients.create_with(params).find_or_create_by(phone: params[:phone]) @client_id = client.id @property_id = client.property_id input = { clientId: @client_id, title: params[:title], propertyId: @property_id, assessment: { instructions: params[:instructions] }, } output = @oauth.query CREATE, variables: { input: input } @id = output.dig 'requestCreate', 'request', 'id' self end |