Class: Jbr::Client
Overview
A person a Jobber user works for, and the property the work happens at.
Direct Known Subclasses
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
-
#company_name ⇒ String?
The business the client is, where the client is a business.
-
#create_with(params = {}) ⇒ Client
Create a client instance with the provided attributes.
-
#email ⇒ String?
The address to write to.
-
#find_or_create_by(phone:) ⇒ Client
Reach the client behind a phone number, opening one if Jobber has none.
-
#first_name ⇒ String?
What the client is called.
- #last_name ⇒ Object
-
#name ⇒ String
Jobber files nobody without one name or the other, so there is always one to call them.
-
#phone ⇒ String?
The number to reach them on, without its country code.
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
#company_name ⇒ String?
Returns the business the client is, where the client is a business.
32 |
# File 'lib/jbr/client.rb', line 32 def company_name = @node['companyName'] |
#create_with(params = {}) ⇒ Client
Create a client instance with the provided attributes.
52 53 54 |
# File 'lib/jbr/client.rb', line 52 def create_with(params = {}) self.tap { @create_params = params } end |
#email ⇒ String?
Returns the address to write to.
39 |
# File 'lib/jbr/client.rb', line 39 def email = @node['email'] |
#find_or_create_by(phone:) ⇒ Client
Reach the client behind a phone number, opening one if Jobber has none.
59 60 61 62 |
# File 'lib/jbr/client.rb', line 59 def find_or_create_by(phone:) find_by_phone(phone) || create self end |
#first_name ⇒ String?
Returns what the client is called.
27 |
# File 'lib/jbr/client.rb', line 27 def first_name = @node['firstName'] |
#last_name ⇒ Object
29 |
# File 'lib/jbr/client.rb', line 29 def last_name = @node['lastName'] |
#name ⇒ String
Jobber files nobody without one name or the other, so there is always one to call them.
36 |
# File 'lib/jbr/client.rb', line 36 def name = first_name || company_name |