carerix/cxrest-client

Client library for easy access to Carerix REST API

v2.4.0 2025-07-10 12:33 UTC

This package is auto-updated.

Last update: 2025-07-14 08:21:43 UTC


README

Client library to access your Carerix application via RESTful API (https://api.carerix.com)

Installation

Recommened way is to install the library using composer:

$ composer require carerix/cxrest-client

Basic usage

Bootstrapping:

use Carerix\Api\Rest\Client;
use Carerix\Api\Rest\Manager;
use Carerix\Api\Rest\Entity;

$client = new Client();

$manager = new Manager($client);
$manager->autoDiscoverEntities();

$manager->setUsername(CUSTOMER_NAME);
$manager->setPassword(API_TOKEN);

Entity::setManager($manager);

Usage:

After entity manager was bootstrapped correctly

use Carerix\Api\Rest\Entity\CREmployee;
use Carerix\Api\Rest\Entity\CRUser;

// get user by ID
$user = CRUser::find(125);

// apply for a job
$params = array('x-cx-pub' => PUBLICATION_ID_GOES_HERE);

$employee = new CREmployee();
$employee
    ->setFirstName('John')
    ->setLastName('Smith');
$employee->apply($params); 

OAuth2 usage

Important

use urn:cx/xmlapi:data:manage as Default scope

  • Copy CLIENT_ID, CLIENT_SECRET

Warning

CLIENT_SECRET will be available to copy only once

  • Copy OpenID Configuration url (from Carerix UI) as CONFIGURATION_URL

  • Configure entity manager to use OAuth2 authorization:

use Carerix\Api\Rest\Client;
use Carerix\Api\Rest\Manager;
use Carerix\Api\Rest\Entity;

$client = new Client();

$manager = new Manager($client);
$manager->autoDiscoverEntities();

$manager->configureOAuth2Auth(CONFIGURATION_URL, CLIENT_ID, CLIENT_SECRET);

Entity::setManager($manager);

Note

After OAuth2 autorization configured usage is the same as Basic usage

Resources

https://help.carerix.com/en/articles/9464648-carerix-rest-api - CxRest Api
https://help.carerix.com/en/articles/9470760-rest-api-methods - CxRestApi methods
https://help.carerix.com/en/articles/9502919-client-setup#h_3411d95f4b - OAuth2 confidential client setup

Important

use urn:cx/xmlapi:data:manage as Default scope

License

All contents of this project is licensed under the MIT license. See LICENSE file for details.

Acknowledgements

This project is highly inspired by Doctrine's (www.doctrine-project.org) implementation of the ActiveRecord pattern and Doctrine REST API Client.