Class: Jbr::Client
Overview
A person a Jobber user works for, and the property the work happens at.
Constant Summary collapse
- LOOKUP =
The query that finds a client by phone, with the properties already on file.
<<~GRAPHQL query($searchTerm: String!) { clientPhones(first: 1, searchTerm: $searchTerm) { nodes { client { id updatedAt clientProperties { nodes { id address { #{Property::SELECTION} } }} } } } } GRAPHQL
- CREATE =
The mutation that opens a client, with a first property when an address is given.
<<~GRAPHQL mutation($input: ClientCreateInput!) { clientCreate(input: $input) { client { id clientProperties(first: 1) { nodes { id } } } userErrors { message } } } GRAPHQL
Instance Attribute Summary collapse
-
#property_id ⇒ String?
readonly
The property the work happens at.
Attributes inherited from Resource
Instance Method Summary collapse
-
#create_with(params = {}) ⇒ Client
Create a client instance with the provided attributes.
-
#find_or_create_by(phone:) ⇒ Client
Reach the client behind a phone number, opening one if Jobber has none.
Methods inherited from Resource
Constructor Details
This class inherits a constructor from Jbr::Resource
Instance Attribute Details
#property_id ⇒ String? (readonly)
Returns the property the work happens at.
24 25 26 |
# File 'lib/jbr/client.rb', line 24 def property_id @property_id end |
Instance Method Details
#create_with(params = {}) ⇒ Client
Create a client instance with the provided attributes.
33 34 35 |
# File 'lib/jbr/client.rb', line 33 def create_with(params = {}) self.tap { @create_params = params } end |
#find_or_create_by(phone:) ⇒ Client
Reach the client behind a phone number, opening one if Jobber has none.
40 41 42 43 |
# File 'lib/jbr/client.rb', line 40 def find_or_create_by(phone:) find_by_phone(phone) || create self end |