itk-dev/getorganized-api-client-php

GetOrganized API 的 PHP 客户端

1.2.1 2023-12-18 08:25 UTC

README

安装

composer require itk-dev/getorganized-api-client-php

使用

use ItkDev\GetOrganized\Client;

$client = new Client($username, $password, $webApplicationUrl);

// Get specific service, e.g. tiles or cases

$tilesService = $client->api('tiles');

$tiles = $tilesService->GetTilesNavigation();

服务

为了对 GetOrganized API 端点进行分组,这些端点考虑特定的 GetOrganized 模块或实体,例如瓦片或案例,我们创建了扩展抽象 ItkDev\GetOrganized\Service 类的服务。

示例瓦片服务

<?php

namespace ItkDev\GetOrganized\Service;

use ItkDev\GetOrganized\Service;

class Tiles extends Service
{
    protected function getApiBaseUrl(): string
    {
        return '/_goapi/Administration/';
    }

    public function GetTilesNavigation()
    {
        return $this->getData(
            'GET',
            $this->getApiBaseUrl().__FUNCTION__,
            []
        );
    }
}

开发

测试

docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer install
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest vendor/bin/phpunit

编码规范

以下命令可让您测试代码是否遵循编码规范

docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer install
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer coding-standards-check

通过运行以下命令自动修复一些编码规范问题

docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer coding-standards-apply

代码分析

docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer install
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer code-analysis