Class: Jbr::Client

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

Constant Summary collapse

LOOKUP =
<<~GRAPHQL.freeze
  query($searchTerm: String!) {
    clientPhones(searchTerm: $searchTerm) { nodes { client { id updatedAt } } }
  }
GRAPHQL
CREATE =
<<~GRAPHQL.freeze
  mutation($input: ClientCreateInput!) {
    clientCreate(input: $input) { client { id } userErrors { message } }
  }
GRAPHQL

Instance Attribute Summary

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 Method Details

#create_with(params = {}) ⇒ Client

Create a client instance with the provided attributes.

Parameters:

  • params (Hash) (defaults to: {})

    the attributes of the client

Options Hash (params):

  • :first_name (String)

    the client’s first name

  • :last_name (String)

    the client’s last name

  • :phone (String)

    the client’s phone number

  • :email (<String, nil>)

    the client’s email address

Returns:



22
23
24
# File 'lib/jbr/client.rb', line 22

def create_with(params = {})
  self.tap { @create_params = params }
end

#find_or_create_by(phone:) ⇒ Object



26
27
28
29
# File 'lib/jbr/client.rb', line 26

def find_or_create_by(phone:)
  find_by_phone(phone) || create
  self
end