Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kanata-php/sdk-utils

Package to help build API SDKs
https://github.com/kanata-php/sdk-utils

Last synced: 7 days ago
JSON representation

Package to help build API SDKs

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.