Download the PHP package intarocrm/rest-api-client without Composer
On this page you can find all versions of the php package intarocrm/rest-api-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download intarocrm/rest-api-client
More information about intarocrm/rest-api-client
Files in intarocrm/rest-api-client
Package rest-api-client
Short Description PHP client for RetailCRM API
License MIT
Homepage http://www.retailcrm.pro/
Informations about the package rest-api-client
RetailCRM API PHP client
This is the PHP RetailCRM API client. This library allows using of the actual API version.
You can find more info in the documentation.
Table of contents
- Requirements
- Installation
- Usage
- Examples
- Notes
- Documentation
Requirements
- PHP 7.3 and above
- PHP's cURL support
- PHP's JSON support
- Any HTTP client compatible with PSR-18 (covered by the installation instructions).
- Any HTTP factories implementation compatible with PSR-17 (covered by the installation instructions).
- Any HTTP messages implementation compatible with PSR-7 (covered by the installation instructions).
- Other dependencies listed in the
composer.json
(covered by the installation instructions)
Installation
Follow those steps to install the library:
- Download and install Composer package manager.
- Install the library from the Packagist by executing this command:
During the installation you will see this message. Press 'y'
when you do:
After that, you may see a message which will look like this:
Choose [a]lways
by typing a
and pressing Enter.
Note: You should choose 'y'
and [a]lways
if your application is using CI/CD pipeline because the interactive terminal is not available
in that environment which will result in failure during the dependencies installation.
If you chose something else during the installation and API client doesn't work properly - please follow these instructions to fix the problem.
- Include the autoloader if it's not included, or you didn't use Composer before.
Replace path/to/vendor/autoload.php
with the correct path to Composer's autoload.php
.
Note: API client uses php-http/curl-client
and nyholm/psr7
as a PSR-18, PSR-17 and PSR-7 implementation.
You can replace those implementations during installation by installing this library with the implementation of your choice, like this:
More information about that can be found in the documentation.
Usage
Firstly, you should initialize the Client. The easiest way to do this is to use the SimpleClientFactory
:
The client is separated into several resource groups, all of which are accessible through the Client's public properties. You can call API methods from those groups like this:
For example, you can retrieve the customers list:
Or the orders list:
To handle errors you must use two types of exceptions:
RetailCrm\Api\Interfaces\ClientExceptionInterface
for the network or other runtime errors.RetailCrm\Api\Interfaces\ApiExceptionInterface
for the errors from the API.
An example of error handling can be found in the next section of this document.
Each resource group is responsible for the corresponding API section. For example, costs
resource group provide methods
for costs manipulation and loyalty
resource group allows interacting with loyalty programs, accounts, bonuses, etc.
Use annotations to determine which DTOs you need for sending the requests. If annotations are not provided by your IDE - you probably should configure them. It'll ease your work with this (and any other) library a lot.
More information about the usage including examples can be found in the documentation.
Examples
Listing orders:
Fetching a specific order by it's ID:
Creating a new customer:
Creating a task for the user with a specific email:
The error handling in the examples above is good enough for real production usage.
You can safely assume that ApiExceptionInterface
is an error from the API, and ClientExceptionInterface
is a client error
(e.g. network error or any runtime error, use HttpClientException
to catch only PSR-18 client errors).
However, you can implement more complex error handling if you want.
Also, both ApiExceptionInterface
and ClientExceptionInterface
implements __toString()
. This means that you can just
convert those exceptions to string and put the results into logs without any special treatment for the exception data.
More examples can be found in the documentation.
You can use a PSR-14 compatible event dispatcher to receive events from the client. See documentation for details.
Notes
This library uses HTTPlug abstractions. Visit official documentation to learn more about it.
All versions of rest-api-client with dependencies
ext-json Version *
psr/log Version ^1|^2|^3
psr/http-client Version ^1.0
psr/http-message Version ^1.0 || ^2.0
psr/http-message-implementation Version ^1.0
php-http/client-implementation Version ^1.0
php-http/discovery Version ^1.13
doctrine/annotations Version ^1.13|^2.0
liip/serializer Version 2.2.* || 2.6.*
php-http/httplug Version ^2.2
civicrm/composer-compile-plugin Version ^0.20
symfony/console Version ^4.0|^5.0|^6.0|^7.0
psr/event-dispatcher Version ^1.0
neur0toxine/psr.http-client-implementation.php-http-curl Version *
neur0toxine/psr.http-factory-implementation.nyholm Version *
neur0toxine/psr.http-message-implementation.nyholm Version *
psr/cache Version ^1.0 || ^2.0 || ^3.0
symfony/cache Version >=v3.1.0
psr/http-factory Version ^1.1