承接 docupike/api-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

docupike/api-client

最新稳定版本:v1.0.0

Composer 安装命令:

composer require docupike/api-client

包简介

PHP API client for docupike

README 文档

README

This is the library to work with docupike cloud Application.

How to install?

Run the following command to require library via composer

composer require docupike/api-client

How to use?

Create the API Client with the authorisation data: url of your docupike instance and the api-token

$api = ApiFactory::create(
        'http://docupike.instance/',
        'your-api-token'
    );

Then you can call the api methods via this object:

$users = $api->user->find();

Using criteria in find requests

If you want to find certain users, objects or entries by specific conditions you can use "Criterias" to do so. See this example, which will find all entries of the general category with titles either like 'example' or 'server' but not exactly 'Server-Prod' (please note the case of 'Server-Prod').

use Docupike\Api\Criteria\AndCriteria;
use Docupike\Api\Criteria\LikeCriteria;
use Docupike\Api\Criteria\NotEqualCriteria;
use Docupike\Api\Criteria\OrCriteria;

$criteria = new OrCriteria([
    new LikeCriteria('cmdb.general.title', 'example'),
    new AndCriteria([
        new LikeCriteria('cmdb.general.title', 'server'),
        new NotEqualCriteria('cmdb.general.title', 'Server-Prod')
    ])
]);

$entries = $api->entry->find('cmdb.general', null, null, ['criteria' => $criteria]);

The criteria can be understood like this:

Find all entries where:

general.title is like 'example'
or (
    general.title is like 'server'
    and general.title is not exactly 'Server-Prod'
)

You can find all available criteria classes in src/Criteria.

How it works?

API uses Guzzle to process the requests to the i-doit API.

Api is a facade that contains the possible API topics: object, category, class, user etc

Every API Topic has methods to work with the given topic: object->create, object->update, object->find etc

Methods have

  • the endpoint to call with the HTTP method
  • response type - what should be the result of the call
  • response schema (to be done) - to make the validation
  • request schema (to be done) - to make the validation

Transport proceeds the request, parses the response to the needed type, handles the errors and throws the corresponding exceptions.

统计信息

  • 总下载量: 5.16k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2022-12-21