https://github.com/kanata-php/sdk-utils
Package to help build API SDKs
https://github.com/kanata-php/sdk-utils
Last synced: 2 days ago
JSON representation
Package to help build API SDKs
- Host: GitHub
- URL: https://github.com/kanata-php/sdk-utils
- Owner: kanata-php
- Created: 2022-10-27T02:33:29.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T02:52:34.000Z (over 3 years ago)
- Last Synced: 2025-08-03T05:17:22.254Z (11 months ago)
- Language: PHP
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Sdk Utilities
This is a helper package to provide tools for SDKs.
## Usage
```php
use KanataSdk\Sdk;
use KanataSdk\Request;
use KanataSdk\Response;
class ExampleSdk extends Sdk
{
public function getResource(): Response
{
return $this->get(
url: $this->options['api-url'] . '/api/resource',
);
}
}
$token = 'some-token-here';
$options = [
'api-url' => 'https://some-url',
];
$exampleSdk = new ExampleSdk($token, $options);
$response = $exampleSdk->getResource();
```
> **Info:** this SDK at this moment expects the API to expect the `Token` at the header `Authorization: Bearer $token` model.
## Installation
```shell
composer require kanata-php/sdk-util
```
## Motivation
The routine of building clients for APIs always goes through the same steps. Some of those are contained in this package.