PHPackages                             crmcarecloud/sdk-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. crmcarecloud/sdk-php

ActiveLibrary

crmcarecloud/sdk-php
====================

5.1.0(9mo ago)03.5k↓46.2%1PHPPHP ^8.1

Since Oct 20Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/crmcarecloud/api-php-sdk)[ Packagist](https://packagist.org/packages/crmcarecloud/sdk-php)[ RSS](/packages/crmcarecloud-sdk-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (21)Used By (0)

CareCloud PHP SDK
=================

[](#carecloud-php-sdk)

This package provides a convenient wrapper around CareCloud PHP Client.

Installation
------------

[](#installation)

You can install this package with composer

```
composer require crmcarecloud/sdk-php:^3.0
```

Client setup
------------

[](#client-setup)

You need to create the client first:

```
use CrmCareCloud\Webservice\RestApi\Client\SDK\CareCloud;
use CrmCareCloud\Webservice\RestApi\Client\SDK\Config;
use CrmCareCloud\Webservice\RestApi\Client\SDK\Data\AuthTypes;
use CrmCareCloud\Webservice\RestApi\Client\SDK\Data\Interfaces;

require_once 'vendor/autoload.php';

$projectUri    = 'https://yourapiurl.com/webservice/rest-api/enterprise-interface/v1.0';
$login         = 'login';
$password      = 'pass';
$externalAppId = 'appId';
$authType      = AuthTypes::BEARER_AUTH;
$interface     = Interfaces::ENTERPRISE;
// Or if using basic auth, just change the AuthType to Basic Auth
// $authType      = AuthTypes::BASIC_AUTH;

$config = new Config( $projectUri, $login, $password, $externalAppId, $authType, $interface );

$careCloud = new CareCloud( $config );
```

Now you can access all the API endpoints from the `$client` object:

```
/**
 * Get information about a specific agreement
 */
// Set Header parameter Accept-Language
$accept_language = 'cs'; //	string | The unique id of the language code by ISO 639-1 Default: cs, en-gb;q=0.8

// Set path parameter
$agreement_id = "81eaeea13b8984a169c490a325"; // string | The unique id of an agreement in CareCloud

try {
    $agreement = $careCloud->agreementsApi()->getAgreement($agreement_id, $accept_language);
    $name      = $agreement->getData()->getName();
    $text      = $agreement->getData()->getText();
} catch (CrmCareCloud\Webservice\RestApi\Client\ApiException $exception) {
    die(var_dump($exception->getResponseBody() ?: $exception->getMessage()));
}
```

Examples
--------

[](#examples)

### Get all customers

[](#get-all-customers)

```
/**
 * Get a list of all customers
 */
// Set Header parameter Accept-Language
$accept_language = 'cs'; //	string | The unique id of the language code by ISO 639-1 Default: cs, en-gb;q=0.8

// Set query parameters
$count               = 100; // integer >= 1 | The number of records to return.
$offset              = 0; // integer | The number of records from a collection to skip.
$sort_field          = 'last_change'; // string | One of the query string parameters for sorting. Response is sorted by the specified field.
$sort_direction      = 'DESC'; // string | Direction of sorting the response list.
$email               = 'happy_customer@crmcarecloud.com'; // string | Search by email
$phone               = '420523828931'; // string | Phone number with international prefix (420000000)
$customer_source_id  = null; // string | The unique id of the customer source. It identifies the system where the customer belongs or the customer account was created
$first_name          = 'John'; // string | Search by first name
$last_name           = 'Smith'; // string | Search by last name
$birthdate           = '1985-02-12'; // string | Customer's date of birth. Possible values are: YYYY-MM-DD / DD.MM.YYYY

// Call endpoint and get data
try {
    $getCustomers  = $careCloud->customersApi()->getCustomers($accept_language, $count, $offset, $sort_field, $sort_direction, $email, $phone, $customer_source_id, $first_name, $last_name, $birthdate);
    $customers     = $getCustomers->getData()->getCustomers();
    $totalItems    = $getCustomers->getData()->getTotalItems();
} catch (CrmCareCloud\Webservice\RestApi\Client\ApiException $exception) {
    die(var_dump($exception->getResponseBody() ?: $exception->getMessage()));
}
```

### Get information about a customer

[](#get-information-about-a-customer)

```
/**
 * Get information about a specific customer account
 */
// Set Header parameter Accept-Language
$accept_language = 'cs'; //	string | The unique id of the language code by ISO 639-1 Default: cs, en-gb;q=0.8

// Set path parameter
$customer_id     = '87af991126405bf8e7dfb36045'; // string | The unique id for the customer

// Call endpoint and get data
try {
    $getCustomer = $careCloud->customersApi()->getCustomer($customer_id, $accept_language);
    $customer    = $getCustomer->getData();
} catch (CrmCareCloud\Webservice\RestApi\Client\ApiException $exception) {
    die(var_dump($exception->getResponseBody() ?: $exception->getMessage()));
}
```

### Update customer

[](#update-customer)

```
/**
 * Update the information on a specific customer account
 */
// Set Header parameter Accept-Language
$accept_language = 'cs'; //	string | The unique id of the language code by ISO 639-1 Default: cs, en-gb;q=0.8

// Set path parameter
$customer_id     = '87af991126405bf8e7dfb36045'; // string | The unique id for the customer

// Set address of customer
$address = new Address();
$address->setAddress1('Old Town Square') // string | Street name of the address
        ->setAddress2('34') // string | Street number (Land registry number)
        ->setAddress3('12') // string | House number
        ->setZip('11000') // string | ZIP code
        ->setCity('Prague 1') // string | City
        ->setCountryCode('cz'); // string | ISO code of the country Possible values de / gb / us / it / cz / etc.

// Set custom agreements of customer
$custom_agreement1 = new CustomAgreements();
$custom_agreement1->setAgreementId('custom_agreement_id') // string | The unique id of the agreement in CareCloud
                 ->setAgreementValue(1); // integer | Value of the specific agreement Possible values: 0 - no, consent canceled / 1 - yes, consent given / 2 - consent not set
$custom_agreement2 = new CustomAgreements();
$custom_agreement2->setAgreementId('second_custom_agreement_id') // string | The unique id of the agreement in CareCloud
                 ->setAgreementValue(1); // integer | Value of the specific agreement Possible values: 0 - no, consent canceled / 1 - yes, consent given / 2 - consent not set

$custom_agreements = [
    $custom_agreement1,
    $custom_agreement2
];

// Set agreement of customer
$agreement = new Agreement();
$agreement->setAgreementGtc(1) // integer | Consent to General Terms & Conditions Possible values: 0 - no, consent canceled / 1 - yes, consent given / 2 - consent not set
          ->setAgreementProfiling(1) // integer | Consent to profiling Possible values: 0 - no, consent canceled / 1 - yes, consent given / 2 - consent not set
          ->setAgreementMarketingCommunication(0) // integer | Consent to marketing communication Possible values: 0 - no, consent canceled / 1 - yes, consent given / 2 - consent not set
          ->setCustomAgreements($custom_agreements);

// Set personal information of customer
$personal_information = new PersonalInformation();
$personal_information->setGender(1) // integer | Gender of the customer Possible values: 1 - male, 2 - female
                     ->setFirstName('John') // string | First name of the customer
                     ->setLastName('Smith') // string | Last name of the customer
                     ->setBirthdate('1985-02-12') // string  | Customer's date of birth (YYYY-MM-DD)
                     ->setEmail('happy_customer@crmcarecloud.com') // string | Email of the customer
                     ->setPhone('420523828931') // string | Phone number of the customer with international prefix (420000000000)
                     ->setLanguageId('cs') // string | The unique id for the language by ISO 639 code
                     ->setStoreId('8bed991c68a4') // string | The unique id for the original customer account store of registration
                     ->setPhotoUrl(null) // string | URL address of the customer photo. If customer has no photo, this parameter is not send
                     ->setAddress($address)
                     ->setAgreement($agreement);

$customer = new Customer();
$customer->setPersonalInformation($personal_information);

// Set customer Social network credentials
$social_network_credentials = new SocialNetworkCredentials();
$social_network_credentials->setSocialNetworkId('twitter') // string | The unique id of the social network
->setSocialNetworkToken('38e123j1jedu12d1jnjqwd'); // string | Social network customer's token

// Set basic information about customer
$body = new CustomersCustomerIdBody();
$body->setCustomer($customer)
    ->setPassword('fO7mrC7spZjr') // string | Password of the customer.
    ->setSocialNetworkCredentials($social_network_credentials);

// Call endpoint and get data
try {
    $putCustomer = $careCloud->customersApi()->putCustomer( $body, $customer_id, $accept_language );
} catch (CrmCareCloud\Webservice\RestApi\Client\ApiException $exception) {
    die(var_dump($exception->getResponseBody() ?: $exception->getMessage()));
}
```

For more examples, check the `Examples` folder.

Extended methods
----------------

[](#extended-methods)

### Assigning a card to a customer

[](#assigning-a-card-to-a-customer)

This method checks if the card is free and not blocked. If everything is OK, it assigns it to the specified customer. Additional information can be added to the card in this method.

```
/**
 * Assigning a free card to a customer
 */
// Set Header parameter Accept-Language
$accept_language = 'cs'; //	string | The unique id of the language code by ISO 639-1 Default: cs, en-gb;q=0.8

// Set method parameters
$card_number  = '1000000000030'; // string | number of the searched card
$customer_id  = '82ab3d112cba4cb26c9b6eafbd'; // string | customer id for assignment to a free card
$valid_from   = '2021-08-01'; // string | set the card validity from (YYYY-MM-DD)
$valid_to     = '2025-08-01'; // string | set the card validity to (YYYY-MM-DD)
$store_id     = null; // string | assign a store id to the card

// Call endpoint and get data
try {
    $assignCard = $careCloud->cardsApi()->putUnassignedCard($card_number, $customer_id, $valid_from, $valid_to, $store_id, $accept_language);
} catch (CrmCareCloud\Webservice\RestApi\Client\ApiException $exception) {
    die(var_dump($exception->getResponseBody() ?: $exception->getMessage()));
}
```

Response: 204 No Content

### Add a new customer

[](#add-a-new-customer)

With this extended method, you can directly assign a card, set the customer's Properties records and Interests records when creating a customer.

If we know the card number it will look up and check availability. If it is available it is assigned to the created customer. If we do not know the number, any available card is assigned.

```
/**
 * Create a new customer with extended method
 */
// Set Header parameter Accept-Language
$accept_language = 'cs'; //	string | The unique id of the language code by ISO 639-1 Default: cs, en-gb;q=0.8

// Set address of new customer
$address = new Address();
$address->setAddress1('Old Town Square') // string | Street name of the address
        ->setAddress2('34') // string | Street number (Land registry number)
        ->setAddress3('12') // string | House number
        ->setZip('11000') // string | ZIP code
        ->setCity('Prague 1') // string | City
        ->setCountryCode('cz'); // string | ISO code of the country Possible values de / gb / us / it / cz / etc.

// Set custom agreements of new customer
$custom_agreement1 = new CustomAgreements();
$custom_agreement1->setAgreementId('custom_agreement_id') // string | The unique id of the agreement in CareCloud
                 ->setAgreementValue(1); // integer | Value of the specific agreement Possible values: 0 - no, consent canceled / 1 - yes, consent given / 2 - consent not set
$custom_agreement2 = new CustomAgreements();
$custom_agreement2->setAgreementId('second_custom_agreement_id') // string | The unique id of the agreement in CareCloud
                 ->setAgreementValue(1); // integer | Value of the specific agreement Possible values: 0 - no, consent canceled / 1 - yes, consent given / 2 - consent not set

$custom_agreements = [
    $custom_agreement1,
    $custom_agreement2
];

// Set agreement of new customer
$agreement = new Agreement();
$agreement->setAgreementGtc(1) // integer | Consent to General Terms & Conditions Possible values: 0 - no, consent canceled / 1 - yes, consent given / 2 - consent not set
          ->setAgreementProfiling(1) // integer | Consent to profiling Possible values: 0 - no, consent canceled / 1 - yes, consent given / 2 - consent not set
          ->setAgreementMarketingCommunication(0) // integer | Consent to marketing communication Possible values: 0 - no, consent canceled / 1 - yes, consent given / 2 - consent not set
          ->setCustomAgreements($custom_agreements);

// Set personal information of new customer
$personal_information = new PersonalInformation();
$personal_information->setGender(1) // integer | Gender of the customer Possible values: 1 - male, 2 - female
                     ->setFirstName('John') // string | First name of the customer
                     ->setLastName('Smith') // string | Last name of the customer
                     ->setBirthdate('1985-02-12') // string  | Customer's date of birth (YYYY-MM-DD)
                     ->setEmail('happy_customer@crmcarecloud.com') // string | Email of the customer
                     ->setPhone('420523828931') // string | Phone number of the customer with international prefix (420000000000)
                     ->setLanguageId('cs') // string | The unique id for the language by ISO 639 code
                     ->setStoreId('8bed991c68a4') // string | The unique id for the original customer account store of registration
                     ->setPhotoUrl(null) // string | URL address of the customer photo. If customer has no photo, this parameter is not send
                     ->setAddress($address)
                     ->setAgreement($agreement);

$customer = new Customer();
$customer->setPersonalInformation($personal_information);

// Set source record of new customer from object (CustomerSourceRecord)
$customer_source = new CustomerSourceRecord();
$customer_source->setCustomerSourceId('8fd73167342d06899c4c015320') // string | The unique id of the customer source. It identifies the system where the customer belongs or the customer account was created
                ->setExternalId('external-id'); // string | The unique external id of the customer. It may be id from the other system

// Set customer Social network credentials
$social_network_credentials = new SocialNetworkCredentials();
$social_network_credentials->setSocialNetworkId('twitter') // string | The unique id of the social network
                           ->setSocialNetworkToken('38e123j1jedu12d1jnjqwd'); // string | Social network customer's token

// Set basic information about new customer
$customerBody = new CustomersBody();
$customerBody->setCustomer($customer)
             ->setCustomerSource($customer_source)
             ->setPassword('fO7mrC7spZjr') // string | Password of the customer.
             ->setAutologin(false) // boolean | If true, password is required and customer is logged in. Otherwise password is optional
             ->setSocialNetworkCredentials($social_network_credentials);

// Set the card information that will be assigned to the customer
$card = new Card();
$card->setCardNumber('1000000000') // string | set card_number if you know it else set card_type_id
     ->setCardTypeId('8bed991c68a470e7aaeffbf048') // string | The unique id for the card type. (Required if we don't know the card number)
     ->setValidFrom('2021-11-01') // string | set the card validity from (YYYY-MM-DD)
     ->setValidTo('2022-11-02') // string | set the card validity to (YYYY-MM-DD)
     ->setStoreId(null); // string | assign a store id to the card

// Set property record
$property_record = new PropertyRecord();
$property_record->setPropertyId('custom_id') // string
                ->setPropertyName('Custom property name') // string
                ->setPropertyValue( 'Some value'); // string or integer or number or object or boolean or (Array of strings or integers or numbers or objects)

$propertyBody = new CustomerIdPropertyrecordsBody();
$propertyBody->setPropertyRecord($property_record);

// Set interest record
$interest_record = new InterestRecord();
$interest_record->setInterestId('81eaeea13b8984a169c490a325') // string | The unique id of the interest
                ->setCustomerId('89ac83ca207a820c62c79bf03a'); // string | The unique id of the customer

$interestBody = new CustomerIdInterestrecordsBody();
$interestBody->setInterestRecord($interest_record);

// Call endpoint and get data
try {
    $newCustomer = $careCloud->customersApi()->postCustomerExtended($customerBody, $card, $propertyBody, $interestBody, $accept_language );
} catch (CrmCareCloud\Webservice\RestApi\Client\ApiException $exception) {
    die(var_dump($exception->getResponseBody() ?: $exception->getMessage()));
}
```

Response

```
Array (
  [customer_id] => ...
  [card_id] => ...
  [property_record_id] => ...
  [interest_record_id] => ...
)
```

### Get all rewards for a specific customer

[](#get-all-rewards-for-a-specific-customer)

The method returns all rewards (Rewards, Vouchers, Campaign products) for a specific customer.

```
/**
 * Get all rewards for a specific customer
 */
// Set Header parameter Accept-Language
$accept_language = 'cs'; //	string | The unique id of the language code by ISO 639-1 Default: cs, en-gb;q=0.8

// Set method parameters
$customer_id       = '8bed991c68a470e7aaeffbf048'; // string | Id of customer
$rewards           = true; // boolean | false - we don't want to get rewards / true - get rewards
$reward_group      = null; // integer | null - all groups / 0 - cash desk reward (party time reward) / 1 - catalog reward
$vouchers          = true; // boolean | false - we don't want to get vouchers / true - get vouchers
$campaign_products = true; // boolean | false - we don't want to get campaign products / true - get campaign products
$is_valid          = null; // boolean | true / false / null - all
$customer_type_id  = null; // By resource customer-types

// Call endpoints and get data
try {
    $allRewards = $careCloud->customersApi()->getAllRewards( $customer_id, $rewards, $reward_group, $vouchers, $campaign_products, $is_valid, $customer_type_id, $accept_language );
    die(print_r($allRewards));
} catch (CrmCareCloud\Webservice\RestApi\Client\ApiException $exception) {
    die(var_dump($exception->getResponseBody() ?: $exception->getMessage()));
}
```

Response

```
Array (
    [rewards] => Array (
            [items] => Array (
                    ...
                )
            [total_items] => 0
        )
)
```

Caching
-------

[](#caching)

The SDK provides a mechanism to easily use any PSR-6 compatible Cache adapter to cache requests to specific endpoints.

### Cache example

[](#cache-example)

We'll use Symfony Cache:

```
composer require symfony/cache
```

Setup the rules:

```
use CrmCareCloud\Webservice\RestApi\Client\SDK\Cache\Rule;
$cache_rules  = [
    new Rule(
        Rule::REQUEST_TYPE_GET, // Request type
        'agreements',  // Path
        400 // TTL
    ),
];
```

Setup the Cache and pass it to the client:

```
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use CrmCareCloud\Webservice\RestApi\Client\SDK\Cache\Cache;
$cache = new Cache(
	new FilesystemAdapter( 'testCache', 0, __DIR__ ), // PSR-6 compatible Cache Pool, in our case Symfony FileAdapter
	$cache_rules
);
$careCloud = new CareCloud( $config, $cache );
```

Now all the `GET` requests to `agreements` endpoints are cached for `400 seconds`. For a complete example check `Examples/Caching.php`.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance58

Moderate activity, may be stable

Popularity23

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~54 days

Recently: every ~75 days

Total

20

Last Release

273d ago

Major Versions

1.9.1 → 2.0.02024-04-19

2.0.0 → 3.0.02024-05-09

3.2.0 → 4.0.02024-10-22

4.3.0 → 5.0.02025-08-18

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7384446?v=4)[František Šitner](/maintainers/sitner)[@sitner](https://github.com/sitner)

---

Top Contributors

[![sitner](https://avatars.githubusercontent.com/u/7384446?v=4)](https://github.com/sitner "sitner (4 commits)")

###  Code Quality

Static AnalysisPHPStan, Rector

Type Coverage Yes

### Embed Badge

![Health badge](/badges/crmcarecloud-sdk-php/health.svg)

```
[![Health](https://phpackages.com/badges/crmcarecloud-sdk-php/health.svg)](https://phpackages.com/packages/crmcarecloud-sdk-php)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[thecodingmachine/graphqlite

Write your GraphQL queries in simple to write controllers (using webonyx/graphql-php).

5723.1M30](/packages/thecodingmachine-graphqlite)[kreait/firebase-bundle

Symfony Bundle for the Firebase Admin SDK

1534.7M2](/packages/kreait-firebase-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[commercetools/commercetools-sdk

The official PHP SDK for the commercetools Composable Commerce APIs

19281.5k](/packages/commercetools-commercetools-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
