定制 keestash/php-sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

keestash/php-sdk

最新稳定版本:0.0.2

Composer 安装命令:

composer require keestash/php-sdk

包简介

SDK for interacting with Keestash

README 文档

README

Keestash SDK is a collection of code that makes it easier to interact with Keestash instances. The basic idea is to configure the SDK once and create, update, delete resources on a remote Keestash server easily.

The SDK is still under development. The service classes are added as needed. If you need something, please open a pull request or open a support ticket.

Installation

Use the package manager composer to install Keestash SDK.

composer install keestash/sdk

Usage

First, you need to implement the \Keestash\Sdk\Service\Api\ApiCredentialsInterface interface in order to provide the API URL and credentials to the SDK. The API URL needs to be there for all requests sending to Keestash whereas the user hash and user token are not necessarily need to present.

class ApiCredentialsProvider implements \Keestash\Sdk\Login\Entity\ApiCredentialsInterface {

    public function getApiUrl(): string
    {
        return 'your-keestash.server/api.php';
    }

    public function getUserToken(): ?string
    {
        return <userToken>;
    }

    public function getUserHash(): ?string
    {
        return <userHash>;
    }
}

After providing the URL to your Keestash instance, you can call the login endpoint

$keestashClient = new \Keestash\Sdk\Client\KeestashClient(
    new GuzzleHttp\Client(),
    new ApiCredentialsProvider()
);

$login = new \Keestash\Sdk\Login\Login($keestashClient);
$data = $login->login(<username>, <password>);
var_dump($data);

The login endpoint returns a user hash and token in case of success. You need these for all authenticated requests to Keestash. Make sure that your class implementing \Keestash\Sdk\Service\Api\ApiCredentialsInterface uses the returned values for all subsequent requests.

require __DIR__ . '/vendor/autoload.php';

// create credential
$c = new \Keestash\Sdk\PasswordManager\Entity\Credential(
    'test-password',
    'theusername',
    'topsecret',
    'root',
    'https://keestash.com'
);

$credential = new \Keestash\Sdk\PasswordManager\Credential\Credential($keestashClient);
$credential->create($c);

// create folder
$folder = new \Keestash\Sdk\PasswordManager\Folder\Folder($keestashClient);
$folder->create(new \Keestash\Sdk\PasswordManager\Entity\Folder('test-folder', 'root'));

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

AGPLv3

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: AGPL-3.0-or-later
  • 更新时间: 2023-06-24