|
1 | | -# Databox bindings for PHP |
| 1 | +# Databox |
2 | 2 |
|
3 | | -[](http://databox.mit-license.org) |
4 | | -[](https://packagist.org/packages/databox/databox) |
| 3 | +Push API resources Open API documentation |
5 | 4 |
|
6 | 5 |
|
7 | | -The PHP SDK for interacting with the [Databox](http://databox.com) Push API. |
| 6 | +## Installation & Usage |
8 | 7 |
|
9 | | -## Requirements |
| 8 | +### Requirements |
10 | 9 |
|
11 | | -* PHP >= 5.5.0 with [cURL](http://php.net/manual/en/book.curl.php) extension, |
12 | | -* [Guzzle](https://github.com/guzzle/guzzle) library, |
13 | | -* (optional) [PHPUnit](https://phpunit.de/) to run tests. |
| 10 | +PHP 7.4 and later. |
| 11 | +Should also work with PHP 8.0. |
14 | 12 |
|
15 | | -## Autoloading |
| 13 | +### Composer |
16 | 14 |
|
17 | | -`databox-php` uses [Composer](http://getcomposer.org). |
18 | | -The first step to use `databox-php` is to download composer: |
| 15 | +To install the bindings via [Composer](https://getcomposer.org/), add the following to `composer.json`: |
19 | 16 |
|
20 | | -```bash |
21 | | -$ curl -s http://getcomposer.org/installer | php |
22 | | -``` |
23 | | - |
24 | | -Clone the repo and install dependencies using: |
25 | | -```bash |
26 | | -$ git clone https://github.com/databox/databox-php.git && cd databox-php |
27 | | -$ php composer.phar install |
28 | | -``` |
29 | | - |
30 | | -Use autoloader from Composer by: |
31 | 17 | ```json |
32 | 18 | { |
33 | | - "require": { |
34 | | - "databox/databox": "@stable" |
| 19 | + "repositories": [ |
| 20 | + { |
| 21 | + "type": "vcs", |
| 22 | + "url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git" |
35 | 23 | } |
| 24 | + ], |
| 25 | + "require": { |
| 26 | + "GIT_USER_ID/GIT_REPO_ID": "*@dev" |
| 27 | + } |
36 | 28 | } |
37 | 29 | ``` |
38 | 30 |
|
39 | | -`databox-php` follows the PSR-4 convention names for its classes, which means you can easily integrate `databox-php` classes loading in your own autoloader. |
| 31 | +Then run `composer install` |
| 32 | + |
| 33 | +### Manual Installation |
40 | 34 |
|
41 | | -## Basic example |
| 35 | +Download the files and include `autoload.php`: |
42 | 36 |
|
43 | 37 | ```php |
44 | 38 | <?php |
45 | | -require __DIR__ . '/vendor/autoload.php'; |
| 39 | +require_once('/path/to/Databox/vendor/autoload.php'); |
| 40 | +``` |
46 | 41 |
|
47 | | -use Databox\Client; |
| 42 | +## Getting Started |
| 43 | + |
| 44 | +Please follow the [installation procedure](#installation--usage) and then run the following: |
| 45 | + |
| 46 | +```php |
| 47 | +<?php |
| 48 | +require_once(__DIR__ . '/vendor/autoload.php'); |
48 | 49 |
|
49 | | -$c = new Client('<push_token>'); |
50 | 50 |
|
51 | | -$ok = $c->push('sales', 203); |
52 | | -if ($ok) { |
53 | | - echo 'Inserted,...'; |
54 | | -} |
55 | 51 |
|
56 | | -$c->insertAll([ |
57 | | - ['sales', 203], |
58 | | - ['sales', 103, '2015-01-01 17:00:00'], |
59 | | -]); |
| 52 | +// Configure HTTP basic authorization: basicAuth |
| 53 | +$config = Databox\Configuration::getDefaultConfiguration() |
| 54 | + ->setUsername('YOUR_USERNAME') |
| 55 | + ->setPassword('YOUR_PASSWORD'); |
60 | 56 |
|
61 | | -// Or push some attributes |
62 | | -$ok = $c->push('sales', 203, null, [ |
63 | | - 'city' => 'Boston' |
64 | | -]); |
65 | 57 |
|
66 | | -print_r( |
67 | | - $c->lastPush(3) |
| 58 | +$apiInstance = new Databox\Api\DefaultApi( |
| 59 | + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. |
| 60 | + // This is optional, `GuzzleHttp\Client` will be used as default. |
| 61 | + new GuzzleHttp\Client(), |
| 62 | + $config |
68 | 63 | ); |
69 | 64 |
|
70 | | -// Or push with units |
71 | | -$c->insertAll([ |
72 | | - ['transaction', 12134, null, null, 'USD'], |
73 | | - ['transaction', 3245, null, null, 'EUR'] |
74 | | -]); |
| 65 | +try { |
| 66 | + $apiInstance->dataDelete(); |
| 67 | +} catch (Exception $e) { |
| 68 | + echo 'Exception when calling DefaultApi->dataDelete: ', $e->getMessage(), PHP_EOL; |
| 69 | +} |
75 | 70 |
|
76 | 71 | ``` |
77 | 72 |
|
78 | | -## Documentation |
| 73 | +## API Endpoints |
| 74 | + |
| 75 | +All URIs are relative to *https://push.databox.com* |
| 76 | + |
| 77 | +Class | Method | HTTP request | Description |
| 78 | +------------ | ------------- | ------------- | ------------- |
| 79 | +*DefaultApi* | [**dataDelete**](docs/Api/DefaultApi.md#datadelete) | **DELETE** /data | |
| 80 | +*DefaultApi* | [**dataMetricKeyDelete**](docs/Api/DefaultApi.md#datametrickeydelete) | **DELETE** /data/{metricKey} | |
| 81 | +*DefaultApi* | [**dataPost**](docs/Api/DefaultApi.md#datapost) | **POST** /data | |
| 82 | +*DefaultApi* | [**metrickeysGet**](docs/Api/DefaultApi.md#metrickeysget) | **GET** /metrickeys | |
| 83 | +*DefaultApi* | [**metrickeysPost**](docs/Api/DefaultApi.md#metrickeyspost) | **POST** /metrickeys | |
| 84 | +*DefaultApi* | [**pingGet**](docs/Api/DefaultApi.md#pingget) | **GET** /ping | |
| 85 | + |
| 86 | +## Models |
| 87 | + |
| 88 | +- [ApiResponse](docs/Model/ApiResponse.md) |
| 89 | +- [PushData](docs/Model/PushData.md) |
| 90 | +- [PushDataAttribute](docs/Model/PushDataAttribute.md) |
| 91 | +- [State](docs/Model/State.md) |
| 92 | + |
| 93 | +## Authorization |
79 | 94 |
|
80 | | -See the `doc` directory for more detailed documentation. |
| 95 | +Authentication schemes defined for the API: |
| 96 | +### basicAuth |
| 97 | + |
| 98 | +- **Type**: HTTP basic authentication |
| 99 | + |
| 100 | +## Tests |
| 101 | + |
| 102 | +To run the tests, use: |
| 103 | + |
| 104 | +```bash |
| 105 | +composer install |
| 106 | +vendor/bin/phpunit |
| 107 | +``` |
81 | 108 |
|
82 | | -## License |
| 109 | +## Author |
83 | 110 |
|
84 | | -`databox-php` is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
85 | 111 |
|
86 | | -## Contributing |
87 | 112 |
|
88 | | -See the [contribute guide](CONTRIBUTING.md) for more info how to contribute. |
| 113 | +## About this package |
89 | 114 |
|
90 | | -## Credits & contributors |
| 115 | +This PHP package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: |
91 | 116 |
|
92 | | -- [Jakob Murko](http://github.com/sraka1) |
93 | | -- [Uroš Majerič](http://github.com/umajeric) |
94 | | -- [Oto Brglez](https://github.com/otobrglez) |
95 | | -- [Vlada Petrovic](https://github.com/vladapetrovic) |
| 117 | +- API version: `0.3.15-sdk.5` |
| 118 | + - Package version: `2.1` |
| 119 | + - Generator version: `7.6.0` |
| 120 | +- Build package: `org.openapitools.codegen.languages.PhpClientCodegen` |
0 commit comments