Class: Jbr::Request
Constant Summary collapse
- CREATE =
<<~GRAPHQL.freeze mutation($input: RequestCreateInput!) { requestCreate(input: $input) { request { id } userErrors { message } } } GRAPHQL
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
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 ⇒ Object (readonly)
Returns the value of attribute client_id.
9 10 11 |
# File 'lib/jbr/request.rb', line 9 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.
20 21 22 23 24 25 26 |
# File 'lib/jbr/request.rb', line 20 def create(params = {}) @client_id = @oauth.clients.create_with(params).find_or_create_by(phone: params[:phone]).id input = { clientId: @client_id, title: params[:title], assessment: { instructions: params[:instructions] } } output = @oauth.query CREATE, variables: { input: input } @id = output.dig 'requestCreate', 'request', 'id' self end |