ocolin / tarana-tcs
PHP Rest client for Tarana TSC API
Requires
- php: ^8.3
- guzzlehttp/guzzle: ^7.10
- ocolin/global-type: ^2.0
Requires (Dev)
- ocolin/easyenv: ^3.0
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^13.0
This package is auto-updated.
Last update: 2026-04-03 23:24:58 UTC
README
What is it?
This is a lightweight PHP REST client for the Tarana TCS API services.
Requirements
- PHP >=8.3
- guzzlehttp/guzzle ^7.10
- ocolin/global-type ^2.0
Installation
composer require ocolin/tarana-tcs
Configuration
Configuration can be done either through environment settings or constructor arguments. Only properties are needed for configuration. Your API token and the URL of the TSC server. The TSC hostname is also optional as Tarana's API is sell established. However, should that ever change, the hostname can be configured.
Configuration Properties
| Environment | Argument | type | Description |
|---|---|---|---|
| TARANA_TCS_API_TOKEN | $token | string | API Key assigned by Tarana |
| TARANA_TCS_API_HOST | $host | string | Tarana TSC hostname |
| -- | $options | array|object | Optional guzzle properties |
Environment Variables
// Manual for demonstration $_ENV['TARANA_TCS_API_TOKEN'] = 'abcdefg'; $_ENV['TARANA_TCS_API_HOST'] = 'https://api.tcs.taranawireless.com'; $taranaTCS = new Ocolin\TaranaTCS\TaranaTCS();
Constructor Arguments
$taranaTCS = new Ocolin\TaranaTCS\TaranaTCS( host: 'https://api.tcs.taranawireless.com', token: 'abcdefg' );
Options
Optional guzzle parameters can be set using the options argument.
$taranaTcs = new Ocolin\TaranaTCS\TaranaTCS( options: [ 'verify' => false ] );
HTTP Defaults
| Option | Default | Description |
|---|---|---|
| timeout | 20 | Seconds to give HTTP attempt |
| verify | true | Verify SSL credentials |
Response
The client returns a response object with the payload as well as HTTP data. Tarana TCS returns an object with a property for data, and a property for error on all calls. This client body payload will be either the error content or data content depending on whether the call was successful or not.
| Parameter | Type | Description |
|---|---|---|
| status | integer | HTTP status code |
| statusMessage | string | HTTP status message |
| headers | array | HTTP response headers |
| body | object | TSC payload. Data or error content |
Path interpolation
The TSC client will interpolate any path variable tokens with value in any matching keys or properties in the $query parameter. See the GET method example to see a path token being replaced.
Method functions
GET
Get a resource(s)
// End point will be /v2/network/radios/abcdefg $output = $taranaTCS->get( endpoint: '/v2/network/radios/{serialNumber}', query: [ 'serialNumber' => 'abcdefg' ] );
POST
Create a resource.
$output = $taranaTCS->post( endpoint: '/v1/network/regions', body: [ 'name' => 'RegionName' ] );
PATCH
Update a resource.
$output = $taranaTCS->patch( endpoint: '/v1/network/regions/{regionName}', query: [ 'regionName' => 'RegionName' ], body: [ 'notes' => 'My new notes' ] );
PUT
Complete update of resource.
$output = $taranaTCS->put( endpoint: '/v1/users/{email}', query: [ 'email' => 'email@address.com' ], body: [ ... ] );
DELETE
Remove resource
$output = $taranaTCS->delete( endpoint: '/v1/users/{email}', query: [ 'email' => 'email@address.com' ] );
REQUEST
Generic HTTP request function.
$output = $taranaTCS->request( endpoint: '/v1/network/regions/{regionName}', method: 'PATCH', query: [ 'regionName' => 'RegionName' ], body: [ 'notes' => 'My new notes' ] );