Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contact getbyemail #19

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
258 changes: 258 additions & 0 deletions src/Deals/Deals.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
<?php

namespace Mediatoolkit\ActiveCampaign\Deals;


use Mediatoolkit\ActiveCampaign\Resource;

/**
* Class Deals
* @package Mediatoolkit\ActiveCampaign\Deals
* @see https://developers.activecampaign.com/reference#deal
*/
class Deals extends Resource
{

/**
* Create a deal
* @see https://developers.activecampaign.com/reference#create-a-deal
*
* @param array $deal
* @return string
*/
public function create(array $deal)
{
$req = $this->client
->getClient()
->post('/api/3/deals', [
'json' => [
'deal' => $deal
]
]);

return $req->getBody()->getContents();
}

/**
* Get a deal by id
* @see https://developers.activecampaign.com/reference#retrieve-a-deal
*
* @param int $id
* @return string
*/
public function get(int $id)
{
$req = $this->client
->getClient()
->get('/api/3/deals/' . $id);

return $req->getBody()->getContents();
}

/**
* Update a deal
* @see https://developers.activecampaign.com/reference#update-a-deal
*
* @param int $id
* @param array $deal
* @return string
*/
public function update(int $id, array $deal)
{
$req = $this->client
->getClient()
->put('/api/3/deals/' . $id, [
'json' => [
'deal' => $deal
]
]);

return $req->getBody()->getContents();
}

/**
* Delete a deal by id
* @see https://developers.activecampaign.com/reference#delete-a-deal
*
* @param int $id
* @return string
*/
public function delete(int $id)
{
$req = $this->client
->getClient()
->delete('/api/3/deals/' . $id);

return $req->getBody()->getContents();
}

/**
* Move deals to another stage
* @see https://developers.activecampaign.com/reference#move-deals-to-another-deal-stage
*
* @param int $id
* @param array $deal
* @return string
*/
public function moveToStage(int $id, array $deal)
{
$req = $this->client
->getClient()
->put('/api/3/dealStages/' . $id . '/deals', [
'json' => [
'deal' => $deal
]
]);

return $req->getBody()->getContents();
}

/**
* Create a deal custom field value
* @see https://developers.activecampaign.com/v3/reference#create-dealcustomfielddata-resource
*
* @param int $deal_id
* @param int $field_id
* @param $field_value
* @return string
*/
public function createCustomFieldValue(int $deal_id, int $field_id, $field_value)
{
$req = $this->client
->getClient()
->post('/api/3/dealCustomFieldData', [
'json' => [
'dealCustomFieldDatum' => [
'dealId' => $deal_id,
'custom_field_id' => $field_id,
'fieldValue' => $field_value
]
]
]);

return $req->getBody()->getContents();
}

/**
* Retrieve a custom field value
* @see https://developers.activecampaign.com/v3/reference#retrieve-a-dealcustomfielddata
* @param int $custom_field_id
* @return string
*/
public function retrieveCustomFieldValue(int $custom_field_id)
{
$req = $this->client
->getClient()
->get('/api/3/dealCustomFieldData/' . $custom_field_id);

return $req->getBody()->getContents();
}

/**
* Update a custom field value
* @see https://developers.activecampaign.com/v3/reference#update-a-dealcustomfielddata-resource
*
* @param int $custom_field_id
* @param $field_value
* @return string
*/
public function updateCustomFieldValue(int $custom_field_id, $field_value)
{
$req = $this->client
->getClient()
->put('/api/3/dealCustomFieldData/' . $custom_field_id, [
'json' => [
'dealCustomFieldDatum' => [
'fieldValue' => $field_value
]
]
]);

return $req->getBody()->getContents();
}

/**
* Delete a custom field value
* @see https://developers.activecampaign.com/v3/reference#retrieve-a-dealcustomfielddata-resource
*
* @param int $custom_field_id
* @return string
*/
public function deleteCustomFieldValue(int $custom_field_id)
{
$req = $this->client
->getClient()
->delete('/api/3/dealCustomFieldData/' . $custom_field_id);

return $req->getBody()->getContents();
}

/**
* List all custom fields
* @see https://developers.activecampaign.com/reference#retrieve-all-dealcustomfielddata-resources
* @param array $query_params
* @return string
*/
public function listAllCustomFields(array $query_params = [])
{
$req = $this->client
->getClient()
->get('/api/3/dealCustomFieldMeta', [
'query' => $query_params
]);

return $req->getBody()->getContents();
}

/**
* List all custom field values
* @see https://developers.activecampaign.com/reference#list-all-custom-field-values
* @param array $query_params
* @return string
*/
public function listAllCustomFieldValues(array $query_params)
{
$req = $this->client
->getClient()
->get('/api/3/dealCustomFieldData', [
'query' => $query_params
]);

return $req->getBody()->getContents();
}

/**
* List all pipelines
* @see https://developers.activecampaign.com/reference#list-all-pipelines
* @param array $query_params
* @return string
*/
public function listAllPipelines(array $query_params = [])
{
$req = $this->client
->getClient()
->get('/api/3/dealGroups', [
'query' => $query_params
]);

return $req->getBody()->getContents();
}

/**
* List all stages
* @see https://developers.activecampaign.com/reference#list-all-deal-stages
* @param array $query_params
* @return string
*/
public function listAllStages(array $query_params = [])
{
$req = $this->client
->getClient()
->get('/api/3/dealStages', [
'query' => $query_params
]);

return $req->getBody()->getContents();
}

}
72 changes: 72 additions & 0 deletions src/Lists/Lists.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

namespace Mediatoolkit\ActiveCampaign\Lists;


use Mediatoolkit\ActiveCampaign\Resource;

/**
* Class Lists
* @package Mediatoolkit\ActiveCampaign\Lists
* @see https://developers.activecampaign.com/reference#lists
*/
class Lists extends Resource
{

/**
* Create a list
* @see https://developers.activecampaign.com/reference#create-new-list
* @param array $list
* @return string
*/
public function create(array $list)
{
$req = $this->client
->getClient()
->post('/api/3/lists', [
'json' => [
'list' => $list
]
]);

return $req->getBody()->getContents();
}

/**
* Retrieve all lists or a list when id is not null
* @see https://developers.activecampaign.com/reference#retrieve-a-list
* @param null $id
* @param array $query_params
* @return string
*/
public function retrieve($id = null, array $query_params = [])
{
$uri = '/api/3/lists';
if (!is_null($id)) {
$uri .= '/' . $id;
}
$req = $this->client
->getClient()
->get($uri, [
'query' => $query_params
]);

return $req->getBody()->getContents();
}

/**
* Delete a list
* @see https://developers.activecampaign.com/reference#delete-a-list
* @param $id
* @return string
*/
public function delete($id)
{
$req = $this->client
->getClient()
->delete('/api/3/lists/' . $id);

return $req->getBody()->getContents();
}

}
Loading