carerix/cxrest-client
最新稳定版本:v2.4.0
Composer 安装命令:
composer require carerix/cxrest-client
包简介
Client library for easy access to Carerix REST API
README 文档
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
- Configure confidential client
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 Configurationurl (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.
统计信息
- 总下载量: 6.42k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-10-19