FluentSupportApi()
FluentSupportApi($key = null) is the single entry point for all utility API classes below.
/**
* @param string|null $key One of 'agents', 'customers', 'products', 'tags', 'tickets'. Omit to get the raw API container.
* @return mixed
*/
FluentSupportApi($key = null);FluentSupportApi('agents'),FluentSupportApi('customers'),FluentSupportApi('products'),FluentSupportApi('tags'), andFluentSupportApi('tickets')each give you the corresponding API class described below (Agents,Customers,Products,Tags,Tickets).- Calling
FluentSupportApi()with no argument returns the underlying API container object, which exposes the same five keys as properties (e.g.FluentSupportApi()->agents).
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
$ticketApi = FluentSupportApi('tickets');FluentSupportApi('tickets') basically returns FluentSupport\App\Api\Classes\Tickets Model class instance.
Methods
getTickets()
This method will return all available tickets
/*
* getTickets method will return all tickets
* @return: object
*/
$tickets = $ticketApi->getTickets();getTicket($id)
The getTicket method retrieves data for a specific ticket.
/*
* 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.
/*
* 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);Note: $data must include customer_id (an existing customer), title, and content — the call returns false if any of these are missing.
getInstance()
If you want to get the basic FluentSupport\App\Models\Ticket model, you can achieve it with the following code
$ticketInstance = FluentSupportApi('tickets')->getInstance();Other methods
In addition to the methods above, $ticketApi proxies these Ticket model query methods directly, so they can be called on the API instance itself:
$allTickets = $ticketApi->all(); // all tickets, no pagination
$tickets = $ticketApi->get(); // tickets matching any prior query constraints
$ticket = $ticketApi->find($id); // find by ID, or null if not found
$ticket = $ticketApi->first(); // first ticket matching any prior query constraints
$tickets = $ticketApi->paginate(); // same as getTickets()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
$agentsApi = FluentSupportApi('agents');FluentSupportApi('agents') basically returns FluentSupport\App\Api\Classes\Agents class which has different methods for interacting with Agent Model.
Methods
getAgents()
/**
* Fetches a paginated list of all agents.
* @return object Paginated result of FluentSupport\App\Models\Agent records.
*/
$agents = $agentsApi->getAgents();getAgent($agentId)
/*
* 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)
/**
* 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 bool True on success, false if the agent was not found or no ID was given.
*/
$updateAgent = $agentsApi->updateAgent($data, $agentId);createAgentWithOrWithoutWpUser($data, $createWpUser)
Create an agent with or without a corresponding WordPress user. If $createWpUser is true.
/**
* 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)
/**
* Deletes a specific agent by ID.
*
* @param int $id The ID of the agent to delete.
* @return void
*/
$agentsApi->deleteAgent($agentId);getInstance()
If you want to get the basic FluentSupport\App\Models\Agent model, you can achieve it with the following code
$agentInstance = FluentSupportApi('agents')->getInstance();Other methods
In addition to the methods above, $agentsApi proxies these Agent model query methods directly, so they can be called on the API instance itself:
$allAgents = $agentsApi->all(); // all agents, no pagination
$agents = $agentsApi->get(); // agents matching any prior query constraints
$agent = $agentsApi->find($agentId); // find by ID, or null if not found
$agent = $agentsApi->first(); // first agent matching any prior query constraints
$agents = $agentsApi->paginate(); // same as getAgents()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
$customersApi = FluentSupportApi('customers');FluentSupportApi('customers') basically returns FluentSupport\App\Api\Classes\Customers Model class instance.
Methods
getCustomers()
This method will return all available customers
/*
* getCustomers method will return a all available customers
* @return: object
*/
$customers = $customersApi->getCustomers();getCustomer($customerId)
The getCustomer method fetches customer data.
/*
* 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
/*
* 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.
/*
* 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.
*/
$createdCustomer = $customersApi->createCustomerWithOrWithoutWpUser($data, $createWpUser);deleteCustomer($id, $withAssociatedData)
DeleteCustomer method will delete customer with or without customer tickets and attachments
/*
* 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
*/
$customersApi->deleteCustomer($customerId, $withAssociatedData);getInstance()
If you want to get the basic FluentSupport\App\Models\Customer model, you can achieve it with the following code
$agentInstance = FluentSupportApi('customers')->getInstance();Other methods
In addition to the methods above, $customersApi proxies these Customer model query methods directly, so they can be called on the API instance itself:
$allCustomers = $customersApi->all(); // all customers, no pagination
$customers = $customersApi->get(); // customers matching any prior query constraints
$customer = $customersApi->find($customerId); // find by ID, or null if not found
$customer = $customersApi->first(); // first customer matching any prior query constraints
$customers = $customersApi->paginate(); // same as getCustomers()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
$productApi = FluentSupportApi('products');FluentSupportApi('products') basically returns FluentSupport\App\Api\Classes\Products Model class instance.
Methods
getProducts()
This method will return all available products
/*
* This method will return all available products
* @return: object
*/
$products = $productApi->getProducts();getProduct($id)
The getProduct method fetches product data.
/*
* getProduct method returns a specific product by id
* @param int $id
* @return: object
*/
$product = $productApi->getProduct($id);createProduct($data)
This method Creates a new product.
/*
* 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.
/*
* 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
/*
* 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);getInstance()
If you want to get the basic FluentSupport\App\Models\Product model, you can achieve it with the following code
$productInstance = FluentSupportApi('products')->getInstance();Other methods
In addition to the methods above, $productApi proxies these Product model query methods directly, so they can be called on the API instance itself:
$allProducts = $productApi->all(); // all products, no pagination
$products = $productApi->get(); // products matching any prior query constraints
$product = $productApi->find($id); // find by ID, or null if not found
$product = $productApi->first(); // first product matching any prior query constraints
$products = $productApi->paginate(); // same as getProducts()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
$tagApi = FluentSupportApi('tags');FluentSupportApi('tags') basically returns FluentSupport\App\Api\Classes\Tags Model class instance.
Methods
getTags()
This method will return all available tags
/*
* getTags method will returns all available tags
* @return: object
*/
$tags = $tagApi->getTags();getTag($id)
The getTag method retrieves data for a specific tag.
/*
* 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.
/*
* 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.
/*
* updateTag method will update tag by id
* @param int $id
* @param array $data
* @return array|null Returns the updated tag or null.
*/
$data = $tagApi->updateTag($id, $data);deleteTag($id)
This method will delete a tag by using the tag ID
/*
* 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);getInstance()
If you want to get the basic FluentSupport\App\Models\Tag model, you can achieve it with the following code
$tagInstance = FluentSupportApi('tags')->getInstance();Other methods
In addition to the methods above, $tagApi proxies these Tag model query methods directly, so they can be called on the API instance itself:
$allTags = $tagApi->all(); // all tags, no pagination
$tags = $tagApi->get(); // tags matching any prior query constraints
$tag = $tagApi->find($id); // find by ID, or null if not found
$tag = $tagApi->first(); // first tag matching any prior query constraints
$tags = $tagApi->paginate(); // same as getTags()