odolbeau/dotfile-php

此包已被弃用且不再维护。作者建议使用 tiime-software/dotfile-php 包。

dotfile API 的 PHP 客户端 SDK。

0.1.1 2024-01-11 16:22 UTC

README

查看 dotfile 文档

使用方法

首先,您需要实例化一个 DotfileClient,您可以直接使用您的 API 密钥来完成此操作。

use Dotfile\DotfileClient;

// Create a client directly from your API Key
$client = DotfileClient::createFromApiKey('dotkey.your_key');

您也可以自己创建 HttpClient。

use Dotfile\DotfileClient;
use Symfony\Component\HttpClient\HttpClient;

$httpClient = HttpClient::createForBaseUri('https://api.dotfile.com/v1/', [
    'headers' => [
        'X-DOTFILE-API-KEY' => dotkey.your_key,
        'accept' => 'application/json',
    ],
]);

$client = new DotfileClient($httpClient);

现在您可以使用您的客户端了!

案例

获取所有案例
use Dotfile\Model\Case\CaseAllInput;

$caseAllInput = new CaseAllInput();
$caseAllInput->name = 'I search the case with this name';

$caseList = $client->case->getAll($caseAllInput); // Returns an instance of CaseList

echo count($caseList->data); // Displays the number of items that matched the search
echo $caseList->data[0]->name; // Displays name of the first case if there is at least one

查看 dotfile 文档

创建新案例
use Dotfile\Model\Case\CaseCreated;
use Dotfile\Model\Case\CaseCreateInput;

$input = new CaseCreateInput();
$input->name = 'This is a new case.';

$caseCreated = $client->case->create($input); // Returns an instance of CaseCreated

echo $caseCreated->name; // Displays "This is a new case."

查看 dotfile 文档

获取案例
use Dotfile\Model\Case\CaseDetailed;

$caseId = '39cbd6d5-4da5-4d94-ae71-84895c5e552a';

$caseDetailed = $client->case->get($caseId); // Returns an instance of CaseDetailed

echo $caseDetailed->name; // Displays "This is the name of the case you retrieved."

查看 dotfile 文档

更新案例
use Dotfile\Model\Case\CaseUpdated;
use Dotfile\Model\Case\CaseUpdateInput;

$input = new CaseUpdateInput();
$input->name = 'This is an update for the case.';

$caseId = '39cbd6d5-4da5-4d94-ae71-84895c5e552a';

$caseUpdated = $client->case->update($caseId, $input); // Returns an instance of CaseUpdated

echo $caseUpdated->name; // Displays "This is an update for the case."

查看 dotfile 文档

删除案例
$caseId = '39cbd6d5-4da5-4d94-ae71-84895c5e552a';

$client->case->delete($caseId);

查看 dotfile 文档

获取现有案例中的标签
use Dotfile\Model\Case\CaseTags;

$caseId = '39cbd6d5-4da5-4d94-ae71-84895c5e552a';

$caseTags = $client->case->getTags($caseId); // Returns an instance of CaseTags

echo count($caseTags); // Displays 0 if there is no tag
echo $caseTags->tags[0]->label; // Displays label of the first tag if there is at least one

查看 dotfile 文档

在现有案例中添加标签
use Dotfile\Model\Case\CaseTags;

$caseId = '39cbd6d5-4da5-4d94-ae71-84895c5e552a';
$tags = ['A faire'];

$caseTags = $client->case->addTags($caseId, $tags); // Returns an instance of CaseTags

echo $caseTags->tags[0]->label; // Displays "A faire"

查看 dotfile 文档

在现有案例中删除标签
use Dotfile\Model\Case\CaseTags;

$caseId = '39cbd6d5-4da5-4d94-ae71-84895c5e552a';
$tags = ['A faire'];

$caseTags = $client->case->removeTags($caseId, $tags); // Returns an instance of CaseTags

echo count($caseTags); // Displays 0 if there was one tag
echo $caseTags->tags[0]->label; // Displays one remaining tag's label if there was more than one

查看 dotfile 文档

公司

在案例中创建新公司
use Dotfile\Model\Company\Company;
use Dotfile\Model\Company\CompanyCreateInput;

$input = new CompanyCreateInput();
$input->caseId = 'id-of-the-case';
$input->name = 'This is a new company.';
$input->registrationNumber = '02513194000022';
$input->country = 'FR';

$company = $client->company->create($input); // Returns an instance of Company

echo $company->name; // Displays "This is a new company."

查看 dotfile 文档

个人

在案例中创建新个人
use Dotfile\Model\Individual\Individual;
use Dotfile\Model\Individual\IndividualCreateInput;

$input = new IndividualCreateInput();
$input->caseId = 'id-of-the-case';
$input->roles = [Role::Shareholder];
$input->firstName = 'Rosa';
$input->lastName = 'Parks';

$individual = $client->individual->create($input); // Returns an instance of Individual

echo $individual->firstName; // Displays "Rosa"
echo $individual->lastName; // Displays "Parks"

查看 dotfile 文档

测试

启动所有测试

make test