diff --git a/.github/workflows/generate_sdk_code.yml b/.github/workflows/generate_sdk_code.yml index 4150451..fdce496 100644 --- a/.github/workflows/generate_sdk_code.yml +++ b/.github/workflows/generate_sdk_code.yml @@ -3,7 +3,7 @@ on: repository_dispatch: types: [publish_sdk] env: - GENERATOR_VERISON: "7.6.0" + GENERATOR_VERISON: "7.6.0" CONFIG_FILE: "sdk-gen-config.json" jobs: sdk: @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - + - name: Get Latest Release id: latest-version uses: pozetroninc/github-action-get-latest-release@v0.7.0 @@ -45,7 +45,7 @@ jobs: } const newVersion = parts.join('.'); return newVersion; - + - name: Download OpenAPI Generator run: | curl https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${{ env.GENERATOR_VERISON }}/openapi-generator-cli-${{ env.GENERATOR_VERISON }}.jar -o ${{ runner.temp }}/openapi-generator-cli.jar @@ -78,9 +78,8 @@ jobs: run: | java --version java -jar ${{ runner.temp }}/openapi-generator-cli.jar generate -i ${{ runner.temp }}/openapispec/openapi.yml -g php -o ./src -c ${{ runner.temp }}/${{ env.CONFIG_FILE }} --skip-validate-spec - cp ./src/README.md ./README.md - cp ./src/composer.json ./composer.json cp -r ./src/docs ./docs + git checkout HEAD README.md composer.json - name: Create Pull Request id: cpr diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..52e2fc4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +./vendor/ + +# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control +# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file +# composer.lock + +# php-cs-fixer cache +.php_cs.cache +.php-cs-fixer.cache + +# PHPUnit cache +.phpunit.result.cache diff --git a/README.md b/README.md index 7c4627f..48d8f24 100644 --- a/README.md +++ b/README.md @@ -45,27 +45,49 @@ Please follow the [installation procedure](#installation--usage) and then run th ```php setUsername('YOUR_USERNAME') - ->setPassword('YOUR_PASSWORD'); +execute(); +function execute() +{ + // Configure HTTP basic authorization: basicAuth + $config = Configuration::getDefaultConfiguration() + ->setHost('https://push.databox.com') + ->setUsername(''); + + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/vnd.databox.v2+json' + ]; -$apiInstance = new Databox\Api\DefaultApi( + $apiInstance = new DefaultApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. - new GuzzleHttp\Client(), - $config -); - -try { - $apiInstance->dataDelete(); -} catch (Exception $e) { - echo 'Exception when calling DefaultApi->dataDelete: ', $e->getMessage(), PHP_EOL; + new Client(['headers' => $headers]), + $config + ); + + $pushData = (new DataboxPushData()) + ->setKey('') // for e.g. sessions + ->setValue(125) + ->setDate('2017-01-01T00:00:00Z') // Date in ISO8601 format + ->setUnit('') // for e.g. $ + ->setAttributes(['']); // for e.g. ['US'] + + try { + $apiInstance->dataPost([$pushData]); + echo "Successfully pushed data to Databox"; + } catch (ApiException $e) { + echo 'Exception when calling DefaultApi->dataPost: ' . $e->getMessage() . PHP_EOL . $e->getResponseBody() . PHP_EOL; + } } ``` diff --git a/composer.json b/composer.json index 5135a93..05df3eb 100644 --- a/composer.json +++ b/composer.json @@ -32,9 +32,9 @@ "friendsofphp/php-cs-fixer": "^3.5" }, "autoload": { - "psr-4": { "Databox\\" : "lib/" } + "psr-4": { "Databox\\" : "src/lib" } }, "autoload-dev": { - "psr-4": { "Databox\\Test\\" : "test/" } + "psr-4": { "Databox\\Test\\" : "src/test" } } } diff --git a/src/examples/pushData/PushData.php b/src/examples/pushData/PushData.php new file mode 100644 index 0000000..89249a9 --- /dev/null +++ b/src/examples/pushData/PushData.php @@ -0,0 +1,45 @@ +setHost('https://push.databox.com') + ->setUsername(''); + + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/vnd.databox.v2+json' + ]; + + $apiInstance = new DefaultApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new Client(['headers' => $headers]), + $config + ); + + $pushData = (new DataboxPushData()) + ->setKey('') // for e.g. sessions + ->setValue(125) + ->setDate('2017-01-01T00:00:00Z') // Date in ISO8601 format + ->setUnit('') // for e.g. $ + ->setAttributes(['']); // for e.g. ['US'] + + try { + $apiInstance->dataPost([$pushData]); + echo "Successfully pushed data to Databox"; + } catch (ApiException $e) { + echo 'Exception when calling DefaultApi->dataPost: ' . $e->getMessage() . PHP_EOL . $e->getResponseBody() . PHP_EOL; + } +} \ No newline at end of file