@@ -45,27 +45,49 @@ Please follow the [installation procedure](#installation--usage) and then run th
4545
4646``` php
4747<?php
48- require_once(__DIR__ . '/vendor/autoload.php');
4948
49+ require_once __DIR__ . '/../../../vendor/autoload.php';
5050
51+ use Databox\Api\DefaultApi;
52+ use Databox\ApiException;
53+ use Databox\Configuration;
54+ use Databox\Model\PushData as DataboxPushData;
55+ use GuzzleHttp\Client;
5156
52- // Configure HTTP basic authorization: basicAuth
53- $config = Databox\Configuration::getDefaultConfiguration()
54- ->setUsername('YOUR_USERNAME')
55- ->setPassword('YOUR_PASSWORD');
57+ execute();
5658
59+ function execute()
60+ {
61+ // Configure HTTP basic authorization: basicAuth
62+ $config = Configuration::getDefaultConfiguration()
63+ ->setHost('https://push.databox.com')
64+ ->setUsername('<CUSTOM _DATA_TOKEN >');
65+
66+ $headers = [
67+ 'Content-Type' => 'application/json',
68+ 'Accept' => 'application/vnd.databox.v2+json'
69+ ];
5770
58- $apiInstance = new Databox\Api\ DefaultApi(
71+ $apiInstance = new DefaultApi(
5972 // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
6073 // This is optional, `GuzzleHttp\Client` will be used as default.
61- new GuzzleHttp\Client(),
62- $config
63- );
64-
65- try {
66- $apiInstance->dataDelete();
67- } catch (Exception $e) {
68- echo 'Exception when calling DefaultApi->dataDelete: ', $e->getMessage(), PHP_EOL;
74+ new Client(['headers' => $headers]),
75+ $config
76+ );
77+
78+ $pushData = (new DataboxPushData())
79+ ->setKey('<METRIC _KEY_NAME >') // for e.g. sessions
80+ ->setValue(125)
81+ ->setDate('2017-01-01T00:00:00Z') // Date in ISO8601 format
82+ ->setUnit('<UNIT >') // for e.g. $
83+ ->setAttributes(['<DIMENSION _VALUE >']); // for e.g. ['US']
84+
85+ try {
86+ $apiInstance->dataPost([$pushData]);
87+ echo "Successfully pushed data to Databox";
88+ } catch (ApiException $e) {
89+ echo 'Exception when calling DefaultApi->dataPost: ' . $e->getMessage() . PHP_EOL . $e->getResponseBody() . PHP_EOL;
90+ }
6991}
7092
7193```
0 commit comments