reliv / axosoft-api
Axosoft API 封装模块
1.6.0
2020-03-24 20:35 UTC
Requires
- php: >=5.4
- guzzlehttp/guzzle: 6.*
Requires (Dev)
- phpunit/phpunit: 4.*
- squizlabs/php_codesniffer: 2.*
README
描述
Axosoft API 的 PHP 封装
开发者
此包包含一个基本框架和类结构,用于封装 AxoSoft(On-Time)的 API。
请帮助我们完成这些 API 类。我们只编写了有限数量的类来满足我们的需求。
如果您想使用 API 库,但缺少所需的 API 类,您可以使用通用类来构建请求。
标准列表调用示例
// Get AxosoftApi from ZF2 service manager $axosoftApi = $this->getServiceLocator()->get('Reliv\AxosoftApi\Service\AxosoftApi'); // Build request $request = new ApiRequestList(); $request->setProjectId(10); $request->setSearchString('search for me'); $request->setSearchField('name'); $request->setPage(1); $request->setPageSize(1); // Get Response $response = $axosoftApi->send($request); // Handle error if ($axosoftApi->hasError($response)) { throw new \Exception('Call Failed.'); } $dataArray = $response->getResponseData(); $someValue = $response->getResponseProperty('somekey');
通用列表调用示例
// Get AxosoftApi from ZF2 service manager $axosoftApi = $this->getServiceLocator()->get('Reliv\AxosoftApi\Service\AxosoftApi'); // Build request $request = new GenericApiRequest('/api/v5/items'); $request->setRequestParameter('project_id', 10); $request->setRequestParameter('search_string', 'search for me'); $request->setRequestParameter('search_field', 'name'); $request->setRequestParameter('page', 1); $request->setRequestParameter('page_size', 1); // Get Response $response = $axosoftApi->send($request); // Handle error if ($axosoftApi->hasError($response)) { throw new \Exception('Call Failed.'); } $dataArray = $response->getResponseData(); $someValue = $response->getResponseProperty('somekey');
待办事项
- 编写剩余的 API 类
- 创建 API 请求验证器
- 可能实现命令模式以简化 API 调用