Skip to content
This repository was archived by the owner on Oct 29, 2025. It is now read-only.
Mike Russell edited this page Aug 10, 2016 · 10 revisions

#Namespace SugarAPI\SDK\Client\

#Interface SugarAPI\SDK\Client\Interfaces\ClientInterface

##Methods ###setServer($server) Set the server property on the Client object. Server property is used to define the API Url Property. ####Arguments

Name Type Description
$server string The server URL where the API resides
####Returns
Type Description
---- -----------
self The current Client Object for method chaining

###setCredentials(array $credentials) Set the Authentication Credentials being used by the Client Object to authenticate to the API ####Arguments

Name Type Description
$credentials array Array of credentials required for the API
####Returns
Type Description
---- -----------
self The current Client Object for method chaining

###login() Login to the API using the configured credentials on the Client and store the authentication token. ####Returns

Type Description
boolean Whether or not Login succeeded
####Exceptions
Type Description
---- -----------
SugarAPI\SDK\Exception\Authentication\AuthenticationException For any errors returned from Login API Endpoint

###logout() Logout of the API, and remove the current authentication token from the Client ####Returns

Type Description
boolean Whether or not the Logout succeeded
####Exceptions
Type Description
---- -----------
SugarAPI\SDK\Exception\Authentication\AuthenticationException For any errors returned from Logout API Endpoint

###refreshToken() Refresh the authentication token used by the client ####Returns

Type Description
boolean Whether or not the Refresh succeeded
####Exceptions
Type Description
---- -----------
SugarAPI\SDK\Exception\Authentication\AuthenticationException For any errors returned from Token Refresh API Endpoint

###registerEndpoint($function,$Endpoint) Register an Endpoint Object to a function/method name on the Client ####Arguments

Name Type Description
$function string The name of the function/method that will be called on the Client Object to initialize the Endpoint
$Endpoint string The full Namespaced Class name of the Endpoint object
####Returns
Type Description
---- -----------
self The current Client Object for method chaining
####Exceptions
Type Description
---- -----------
SugarAPI\SDK\Exception\Endpoint\EndpointException If Endpoint Class does not implement SugarAPI\SDK\Endpoint\Interfaces\EPInterface

###getServer() Get the configured server on the Client ####Returns

Type Description
string The current server property configured on the Client

###getAPIUrl() Get the configured API Url on the Client ####Returns

Type Description
string The current API Url property configured on the Client

###getCredentials() Get the configured credentials on the Client ####Returns

Type Description
array The current authentication credentials configured on the Client

###setToken() Set the authentication token to be used by the Client Object to authenticate requests to the API. Login method should pass token to this method, upon successful authentication to the API ####Arguments

Name Type Description
$token mixed The authentication token to be used by the Client
####Returns
Type Description
---- -----------
self The current Client Object for method chaining

###getToken() Get the configured authentication token on the Client ####Returns

Type Description
array The current authentication token configured on the Client

###authenticated() Check if Client is currently authenticated to the API ####Returns

Type Description
boolean Whether or not the Client is currently authenticated to the API

###::storeToken($token,$client_id) Static method to store an authentication token for later use by the Client object. Default uses Late Static Binding to store a token on the Client Object for subsequent uses of the same Client in the same PHP process ####Arguments

Name Type Description
$token mixed The authentication token for the Client that is to be stored
$client_id string A unique client ID to reference the client and store the token against
####Returns
Type Description
---- -----------
boolean Whether or not storage of the token completed

###::getStoredToken($client_id) Static method to get the stored authentication token for a particular Client ####Arguments

Name Type Description
$client_id string The unique client ID
####Returns
Type Description
---- -----------
mixed Returns NULL if no token is retrieved, otherwise returns the authentication token

###::removeStoredToken($client_id) Static method to remove an authentication token from storage ####Arguments

Name Type Description
$client_id string The unique client ID
####Returns
Type Description
---- -----------
boolean Whether or not removal of the token from storage succeeded

#Abstracts There are two Abstract Clients included in the Rest PHP Client Framework.

| Name | Description | | SugarAPI\SDK\Client\Abstracts\AbstractClient | A generic client implementation, that can be extended and altered for use with any Rest API | | SugarAPI\SDK\Client\Abstracts\AbstractSugarClient | Extends the AbstractClient and implements all required logic to work strictly with the Sugar 7 REST API. Autoload's all of the Endpoint Objects for Sugar's API |

#Implementations There is one included Client implementation with the REST PHP Client.

| Name | Description | | SugarAPI\SDK\SugarAPI | Extends the AbstractSugarClient, for quick use to access any Sugar REST API |

Please see the SugarAPI Client documentation for further instructions on usage.

Clone this wiki locally