RetailCRM API Client

Integration extends AbstractApiResourceGroup

Class Integration

Tags
category

Integration

SuppressWarnings

(PHPMD.CouplingBetweenObjects)

Table of Contents

Methods

edit()  : IntegrationModulesEditResponse
Makes POST "/api/v5/integration-modules/{code}/edit" request.
get()  : IntegrationModulesGetResponse
Makes GET "/api/v5/integration-modules/{code}" request.
updateScopes()  : IntegrationModuleUpdateScopesResponse
Makes POST "/api/v5/integration-modules/{code}/update-scopes" request.

Methods

edit()

Makes POST "/api/v5/integration-modules/{code}/edit" request.

public edit(string $code, IntegrationModulesEditRequest $request) : IntegrationModulesEditResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\Integration\IntegrationModule;
use RetailCrm\Api\Model\Entity\Integration\Integrations;
use RetailCrm\Api\Model\Entity\Integration\Transport\TransportConfiguration;
use RetailCrm\Api\Model\Request\Integration\IntegrationModulesEditRequest;

$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');

$module = new IntegrationModule();
$module->integrations = new Integrations();
$module->integrations->mgTransport = new TransportConfiguration();

$module->clientId = 'e029f3dd545147c6428d12d9524f33b806e9310947430773c6c82719e4c41904';
$module->code = 'mg-fbmessenger';
$module->integrationCode = 'mg-fbmessenger';
$module->name = 'Facebook Messenger';
$module->logo = 'https://mg-tp-fbm-s1.retailcrm.pro/static/fbmessenger_logo.svg';
$module->baseUrl = 'https://mg-tp-fbm-s1.retailcrm.pro/';
$module->actions = ['activity' => '/actions/activity'];
$module->accountUrl = 'https://mg-tp-fbm-s1.retailcrm.pro/settings/clientId';
$module->integrations->mgTransport->webhookUrl = 'https://mg-tp-fbm-s1.retailcrm.pro/webhook/';

try {
    $response = $client->integration->edit('mg-fbmessenger', new IntegrationModulesEditRequest($module));
} catch (ApiExceptionInterface $exception) {
    echo sprintf(
        'Error from RetailCRM API (status code: %d): %s',
        $exception->getStatusCode(),
        $exception->getMessage()
    );

    if (count($exception->getErrorResponse()->errors) > 0) {
        echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
    }

    return;
}

echo 'Info: ' . print_r($response->info, true);
Parameters
$code : string
$request : IntegrationModulesEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
IntegrationModulesEditResponse

get()

Makes GET "/api/v5/integration-modules/{code}" request.

public get(string $code) : IntegrationModulesGetResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');

try {
    $response = $client->integration->get('mg-fbmessenger');
} catch (ApiExceptionInterface $exception) {
    echo sprintf(
        'Error from RetailCRM API (status code: %d): %s',
        $exception->getStatusCode(),
        $exception->getMessage()
    );

    if (count($exception->getErrorResponse()->errors) > 0) {
        echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
    }

    return;
}

echo 'FBMessenger Module: ' . print_r($response->integrationModule, true);
Parameters
$code : string
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
IntegrationModulesGetResponse

updateScopes()

Makes POST "/api/v5/integration-modules/{code}/update-scopes" request.

public updateScopes(string $code, IntegrationModuleUpdateScopesRequest $request) : IntegrationModuleUpdateScopesResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\Integration\IntegrationModule;
use RetailCrm\Api\Model\Entity\Integration\Integrations;
use RetailCrm\Api\Model\Entity\Integration\Transport\TransportConfiguration;
use RetailCrm\Api\Model\Request\Integration\IntegrationModulesEditRequest;

$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');

$requires = [
    'integration_read',
    'integration_write',
];
$request = new IntegrationModuleUpdateScopesRequest($requires);

try {
    $response = $client->integration->edit('test-integration', $request);
} catch (ApiExceptionInterface $exception) {
    echo sprintf(
        'Error from RetailCRM API (status code: %d): %s',
        $exception->getStatusCode(),
        $exception->getMessage()
    );

    if (count($exception->getErrorResponse()->errors) > 0) {
        echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
    }

    return;
}

echo 'Info: ' . print_r($response->info, true);
Parameters
$code : string
$request : IntegrationModuleUpdateScopesRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
IntegrationModuleUpdateScopesResponse

        
On this page

Search results