Skip to content

Ticket API Function

The ticket API Function provides a range of utility methods that enable you to retrieve data according to your specific requirements when working within your custom PHP Snippet or plugin.

Initialization

php
$ticketApi = FluentSupportApi('tickets');

FluentSupportApi('tickets') basically returns FluentSupport\App\Api\Classes\Tickets Model class instance.

Methods

getTickets()

This method will return all available tickets

php
/*
* getTickets method will return all tickets
* @return: object
*/
$tickets = $ticketApi->getTickets();

getTicket($id)

The getTicket method retrieves data for a specific ticket.

php
/*
* getTicket method will return a specific ticket by id
* @param int $id
* @return: object|false
*/
$ticket = $ticketApi->getTicket($id);

addResponse($data, $agentId, $ticketId)

The addResponse method will create a response by agent for a specific ticket.

php
/*
* addResponse method add response to a ticket by agent and ticket ID
* @param array $data
* @param int $agentId
* @param int $ticketId
* @return array|boolean
*/
$data = $ticketApi->addResponse($data, $agentId, $ticketId);

createTicket($data)

The createTicket method will create a new ticket. /*

  • createTicket method will create a new ticket
  • @param array $data
  • @return object| boolean */ $data = $ticketApi->createTicket($data);

## Agents API Function
The Agents API Function offers a variety of utility methods designed for seamless interaction with agent-related operations. Integrate these functions into your custom PHP snippet or plugin to enhance agent-related functionalities.

### Initialization
```php 
$agentsApi = FluentSupportApi('agents');

FluentSupportApi('agents') basically returns FluentSupport\App\Api\Classes\Agents class which has different methods for interacting with Agent Model.

Methods

getAgents()

php
/**
 * Fetches information for all agents.
 * @return FluentSupport\App\Models\Agent|null The agent model or null if not found.
 */
$agents = $agentsApi->getAgents();

getAgent($agentId)

php
/*
* Find a agent by agent_id
* You can find a agent by agent_id
* @return: null or FluentSupport\App\Models\Agent Model
*/
$agent = $agentsApi->getAgent($agentId);

updateAgent($data, $agentId)

php
/**
 * Updates a specific agent by ID.
 *
 * @param array $data The data to update the agent.
 * @param int $agentId The ID of the agent to update.
 * @return FluentSupport\App\Models\Agent|null The updated agent model or null if not found.
 */
$updateAgent = $agentsApi->updateAgent($data, $agentId);

createAgentWithOrWithoutWpUser($data, $createWpUser)

Create an agent with or without a corresponding WordPress user. If $createWpUser is true.

php
/**
 * createAgentWithOrWithoutWpUser method creates a new agent, with or without a corresponding WordPress user.
 * If creating a WordPress user is requested, the process involves first creating the WordPress user,
 * and upon successful creation, proceeds to create a Fluent Support agent.
 *
 * @param array $data - Data for creating the agent.
 * @param bool $createWpUser - Whether to create a corresponding WordPress user.
 * @return mixed - Returns the created agent or null.
 */
$createAgent = $agentsApi->createAgentWithOrWithoutWpUser($data, $createWpUser);

deleteAgent($id)

DeleteAgent method will delete agent by id

getInstance()

If you want to get the basic FluentSupport\App\Models\Agent model, you can achieve it with the following code

php
$agentInstance = FluentSupportApi('agents')->getInstance();

Customer API Function

The Customer API Function offers various utility methods for retrieving data according to your needs within your custom PHP Snippet or plugin.

Initialization

php
$customersApi = FluentSupportApi('customers');

FluentSupportApi('customers') basically returns FluentSupport\App\Api\Classes\Customers Model class instance.

Methods

getCustomers()

This method will return all available customers

php
/*
* getCustomers method will return a all available customers
* @return: object
*/
$customers = $customersApi->getCustomers();

getCustomer($customerId)

The getCustomer method fetches customer data.

php
/*
* getCustomer method will return a specific customer by id
* @param int $customerId 
* @return object|boolean
*/
$customer = $customersApi->getCustomer($customerId);

updateCustomer($data, $agentId)

This method update the customer data

php
/*
 * updateCustomer method will update the specific customer by id
 *
 * @param array $data
 * @param int $customer_id
 * @return object|boolean
 */
$customer = $customersApi->updateCustomer($data, $agentId);

createCustomerWithOrWithoutWpUser($data, $createWpUser)

Create a customer with or without a corresponding WordPress user. If $createWpUser is true.

php
/*
 * createCustomerWithOrWithoutWpUser method creates a new customer, with or without a corresponding WordPress user.
 * If creating a WordPress user is requested, the process involves first creating the WordPress user,
 * and upon successful creation, proceeds to create a Fluent Support agent.
 *
 * @param array $data - Data for creating the agent.
 * @param bool $createWpUser - Whether to create a corresponding WordPress user.
 * @return mixed - Returns the created customer or null.
 */
$createAgent = $agentsApi->createCustomerWithOrWithoutWpUser($data, $createWpUser);

deleteCustomer($id, $withAssociatedData)

DeleteAgent method will delete customer with or without customer tickets and attachments

php
/*
 * deleteCustomer method will delete customer with or without customer tickets and attachments
 * @param int $id
 * @param bool $withAssociatedData | this will delete all tickets and attachments of this customer
 * @return void
 */
$createAgent = $agentsApi->createCustomerWithOrWithoutWpUser($data, $createWpUser);

getInstance()

If you want to get the basic FluentSupport\App\Models\Customer model, you can achieve it with the following code

php
$agentInstance = FluentSupportApi('customers')->getInstance();

Product API Function

The Product API Function provides a range of utility methods that enable you to retrieve data according to your specific requirements when working within your custom PHP Snippet or plugin.

Initialization

php
$productApi = FluentSupportApi('products');

FluentSupportApi('products') basically returns FluentSupport\App\Api\Classes\Products Model class instance.

Methods

getProducts()

This method will return all available products

php
/*
* This method will return all available products
* @return: object
*/
$products = $productApi->getProducts();

getProduct($id)

The getProduct method fetches product data.

php
/*
* getProduct method returns a specific product by id
* @param int $id
* @return: object
*/
$product = $productApi->getCustomer($customerId);

createProduct($data)

This method Creates a new product.

php
/*
* createProduct method creates a new product.
*
* @param array $data The data to create the product.
* @return array|null Returns the created product or null.
*/
$data = $productApi->createProduct($data);

updateProduct($id, $data)

This method will Updates a product by using the product ID.

php
/*
* updateProduct method will update product by id
* @param int $id
* @param array $data
* @return array|null Returns the updated product or null.
*/
$data = $productApi->updateProduct($id, $data);

deleteProduct($id)

This method will delete a product by using the product ID

php
/*
* deleteProduct method will delete product by id
* @param int $id
* @return bool True if the deletion is successful; otherwise, returns false.
*/
$data = $productApi->deleteProduct($id);

Tag API Function

The tag API Function provides a range of utility methods that enable you to retrieve data according to your specific requirements when working within your custom PHP Snippet or plugin.

Initialization

php
$tagApi = FluentSupportApi('tags');

FluentSupportApi('tags') basically returns FluentSupport\App\Api\Classes\Tags Model class instance.

Methods

getTags()

This method will return all available tags

php
/*
* getTags method will returns all available tags
* @return: object
*/
$tags = $tagApi->getTags();

getTag($id)

The getTag method retrieves data for a specific tag.

php
/*
* getTag method returns a specific tag by id
* @param int $id
* @return: object
*/
$tag = $tagApi->getTag($id);

createTag($data)

This method Creates a new tag.

php
/*
* createTag method will create a new tag
*
* @param array $data The data to create the tag.
* @return array|null Returns the created tag or null.
*/
$data = $tagApi->createTag($data);

updateTag($id, $data)

This method will Updates a tag by using the tag ID.

php
/*
* updateTag method will update tag by id
* @param int $id
* @param array $data
* @return array|null Returns the updated tag or null.
*/
$data = $productApi->updateProduct($id, $data);

deleteTag($id)

This method will delete a tag by using the tag ID

php
/*
* deleteTag method will delete tag by id
* @param int $id
* @return bool True if the deletion is successful; otherwise, returns false.
*/
$data = $tagApi->deleteTag($id);