API Client
Public Member Functions | Protected Attributes | List of all members
OneCRM\APIClient\Client Class Reference

Public Member Functions

 __construct ($url, Authentication $auth=null)
 
 setAuth (Authentication $auth)
 
 request ($method, $endpoint, array $options=[])
 
 post ($endpoint, $body, $query_params=[])
 
 patch ($endpoint, $body, $query_params=[])
 
 put ($endpoint, $body, $query_params=[])
 
 get ($endpoint, $query_params=[])
 
 delete ($endpoint, $query_params=[])
 
 model ($model_name)
 
 calendar ()
 
 files ()
 
 me ()
 
 serverKey ()
 
 serverVersion ()
 

Protected Attributes

 $url
 
 $auth
 
 $_calendar
 
 $_files
 

Detailed Description

API Client

Constructor & Destructor Documentation

OneCRM\APIClient\Client::__construct (   $url,
Authentication  $auth = null 
)

Constructor

Parameters
$urlURL of API entry point, including api.php, ex. https://demo.1crmcloud.com/api.php
$authOptional instance of Authentication

Member Function Documentation

OneCRM\APIClient\Client::calendar ( )

Creates an instanse of Calendar class to work with events data.

Returns
Instance of Calendar
OneCRM\APIClient\Client::delete (   $endpoint,
  $query_params = [] 
)

Sends a DELETE request to API

Parameters
$endpointAPI endpoint, relative to API URL (ex. /data/Account)
$queryArray with query params appended to the URL ( ex. ['offset' => 20])
Returns
Decoded response from API
Exceptions
Error
OneCRM\APIClient\Client::files ( )

Creates an instanse of Files class to upload and download files.

Returns
Instance of Files
OneCRM\APIClient\Client::get (   $endpoint,
  $query_params = [] 
)

Sends a GET request to API

Parameters
$endpointAPI endpoint, relative to API URL (ex. /data/Account)
$queryArray with query params appended to the URL ( ex. ['offset' => 20])
Returns
Decoded response from API
Exceptions
Error
OneCRM\APIClient\Client::me ( )

Returns information about authenticated user

OneCRM\APIClient\Client::model (   $model_name)

Creates an instanse of Model class to work with data stored in 1CRM database.

Parameters
$model_nameModel name, ex. Account
Returns
Instance of Model
OneCRM\APIClient\Client::patch (   $endpoint,
  $body,
  $query_params = [] 
)

Sends a PATCH request to API

Parameters
$endpointAPI endpoint, relative to API URL (ex. /data/Account/1234)
$bodyRequest body. Must be an array, it will be json-encoded
$queryArray with query params appended to the URL ( ex. ['offset' => 20]). Normally, this is not used
Returns
Decoded response from API
Exceptions
Error
OneCRM\APIClient\Client::post (   $endpoint,
  $body,
  $query_params = [] 
)

Sends a POST request to API

Parameters
$endpointAPI endpoint, relative to API URL (ex. /data/Account)
$bodyRequest body. Must be an array, it will be json-encoded
$queryArray with query params appended to the URL ( ex. ['offset' => 20]). Normally, this is not used
Returns
Decoded response from API
Exceptions
Error
OneCRM\APIClient\Client::put (   $endpoint,
  $body,
  $query_params = [] 
)

Sends a PUT request to API

Parameters
$endpointAPI endpoint, relative to API URL
$bodyRequest body. Must be an array, it will be json-encoded
$queryArray with query params appended to the URL ( ex. ['offset' => 20]). Normally, this is not used
Returns
Decoded response from API
Exceptions
Error
OneCRM\APIClient\Client::request (   $method,
  $endpoint,
array  $options = [] 
)

Sends a request to API

This method is used to send an arbitrary request to 1CRM REST API.

Parameters
$methodHTTP request method (GET, PUT, POST, etc.)
$endpointAPI endpoint, relative to API URL (ex. /data/Account)
$optionsRequest options. Can be any options accepted by GuzzleHttp
Returns
Decoded response from API
Exceptions
Error
OneCRM\APIClient\Client::serverKey ( )

Returns API server's public key

OneCRM\APIClient\Client::serverVersion ( )

Returns information server software version

OneCRM\APIClient\Client::setAuth ( Authentication  $auth)

Sets authentication used for all subsequent API requests


The documentation for this class was generated from the following file: