-
Notifications
You must be signed in to change notification settings - Fork 0
Opportunity
The opportunity entry point allows you to control the opportunities: list, create or find them.
The list
method retrieves a list of all the opportunities.
use KeapGeek\Keap\Facades\Keap;
Keap::order()->list([
'limit' => ?int,
'offset' => ?int,
'order' => ?string, // ENUM see below
'search_term' => ?string,
'stage_id' => ?int,
'user_id' => ?string,
]);
This method accepts different optional parameters, to query on:
-
contact_id
is the id of the contact. -
limit
is the amount of opportunities to return, it defaults to 1000. -
offset
is the first item that starts the set, it defaults to 0. -
order
is the attribute to order the items by, the possible values are:next_action
,opportunity_name
,contact_name
, ordate_created
. -
search_term
returns all the opportunity that match any of the contact's name, company name, email address or company title. -
stage_id
returns the opportunities at this stage id. -
user_id
returns the opportunities assigned to the user.
It returns an array with all the opportunities that fullfill the criteria.
The list
method retrieves a count of all the opportunities, that match the previously defined conditions.
use KeapGeek\Keap\Facades\Keap;
Keap::order()->count([
'search_term' => ?string,
'stage_id' => ?int,
'user_id' => ?string,
]);
It returns the opportunity model, given the id.
use KeapGeek\Keap\Facades\Keap;
Keap::opportunity()->find(int $opportunity_id);
As a second argument an array of list can be included to return the opportunity model with the available properties which are not included in the default option.
E.g. ['custom_fields']
.
It creates a new opportunity.
use KeapGeek\Keap\Facades\Keap;
Keap::opportunity()->create([
'affiliate_id' => ?int,
'contact_id' => int, //required
'date_created' => ?string,
'estimated_close_string' => ?string,
'include_in_forecast' => ?int,
'next_action_date' => ?string,
'next_action_notes' => ?string,
'opportunity_notes' => ?string,
'opportunity_title' => ?string,
'projected_revenue_high' => ?int,
'projected_revenue_low' => ?int,
'stage_id' => int, //required
'user_id' => ?int,
]);
The contact_id
is the id of the contact, that will be associated with the opportunity.
The date_created
is any Carbon parsable string representing the date and time of the opportunity.
The stage_id
is the id of the stage where to put the opportunity.
The user_id
if not specified, will be assigned to the current authenticated user.
Updates an opportunity with only the values provided in the request.
use KeapGeek\Keap\Facades\Keap;
Keap::opportunity()->update(int $opportunity_id, [
'affiliate_id' => ?int,
'contact_id' => int, //required
'date_created' => ?string,
'estimated_close_string' => ?string,
'include_in_forecast' => ?int,
'next_action_date' => ?string,
'next_action_notes' => ?string,
'opportunity_notes' => ?string,
'opportunity_title' => ?string,
'projected_revenue_high' => ?int,
'projected_revenue_low' => ?int,
'stage_id' => int, //required
'user_id' => ?int,
]);
It returns the opportunity model updated with the included fields. Only the values which are included will be updated.
It replaces all values of a given opportunity.
use KeapGeek\Keap\Facades\Keap;
Keap::opportunity()->replace([
'affiliate_id' => ?int,
'contact_id' => int, //required
'date_created' => ?string,
'estimated_close_string' => ?string,
'id' => ?int,
'include_in_forecast' => ?int,
'next_action_date' => ?string,
'next_action_notes' => ?string,
'opportunity_notes' => ?string,
'opportunity_title' => ?string,
'projected_revenue_high' => ?int,
'projected_revenue_low' => ?int,
'stage_id' => int, //required
'user_id' => ?int,
]);
It returns the opportunity model updated with the included fields. The values which are not included will be overwritten with the default values.
This method returns an array with all the available stages of the sales pipeline.
use KeapGeek\Keap\Facades\Keap;
Keap::opportunity()->pipeline();
The method model
retrieves information about the custom fields and properties on the Keap opportunity model.
use KeapGeek\Keap\Facades\Keap;
Keap::opportunity()->model();
This method will return two arrays:
[
"custom_fields" => [
...
],
"optional_properties" => [string],
]
The response includes an array of custom fields, each representing a custom property set in your Keap dashboard. If these custom fields are configured, the response will return an array containing all custom order properties. Each element in this array is itself an array that includes all options and values configured, depending on the type of field selected.