kanata-php/sdk-util

0.0.4 2022-12-06 02:52 UTC

This package is auto-updated.

Last update: 2024-11-06 06:51:44 UTC


README

This is a helper package to provide tools for SDKs.

Usage

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

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.