combodo/itop-client-bundle

symfony的iTop rest客户端组件

安装: 3

依赖项: 0

建议者: 0

安全性: 0

星标: 2

关注者: 6

分支: 0

开放问题: 3

类型:symfony-bundle

2.1.0 2022-04-26 12:02 UTC

README

symfony的iTop rest客户端组件

此组件帮助您消费iTop rest webservices

安装

步骤 1:下载组件

打开命令行,进入您的项目目录,并执行以下命令以下载此组件的最新稳定版本

$ composer require combodo/itop-client-bundle

此命令要求您已全局安装Composer,如Composer文档中的安装章节所述。

步骤 2:配置itop服务器

# app/config/config.yml
combodo_itop_client:
    servers:
        itop_server_foo:
            base_url:  "%it_combodo.base_url%"
            auth_user: "%it_combodo.auth_user%"
            auth_pwd:  "%it_combodo.auth_pwd%"
            extra_headers: "%it_combodo.extra_headers%"

此组件将创建一个名为itop_client.rest_client.itop_server_foo的服务,您可以在代码中使用此服务。

步骤 3:开始使用

每个操作都遵循在otop文档中提供的结构:遵循以下结构:https://www.itophub.io/wiki/page?id=latest%3Aadvancedtopics%3Arest_json#operationcore_create

您可以使用服务容器或通过在服务构造函数中添加Combodo\ItopClientBundle\RestClient\RestClient $foo来使用服务注入。

use Combodo\ItopClientBundle\RestClient\RequestOperation\Core\RequestOperationCoreCreate;
use Combodo\ItopClientBundle\RestClient\RestClient;

class Foo
{
    /**
     * @var RestClient
     */
    private $client;
    public function __construct(RestClient $client) 
    {    
        $this->client = $client;
    }

    public function bar()
    {
        $operation = new RequestOperationCoreCreate(
            'Class',
            'id',
            'my comment',
            [
                'title'             => 'foo',
                'description'       => 'bar',
                'caller_email'      => 'boris.vian@example.com',
            ]
        );
        
        $this->client->executeOperation($operation);
    }    
}