f-dg / adjust-api-sdk
There is no license information available for the latest version (v0.1) of this package.
PHP SDK for Adjust API
v0.1
2017-12-25 12:33 UTC
Requires
- php: >=5.5.9
Requires (Dev)
- phpunit/phpunit: >=6.1.4
This package is not auto-updated.
Last update: 2024-04-14 01:46:42 UTC
README
A note - do not read a rus variant of the docs, cause some not translated docblock just dropped
Description
This SDK not fully implemented according to the official doc Feel free to add a new code to the SDK, but do not forget about unit tests
The default is:
response
as JSON", "CSV" not implemented- time zone of account's
Adjust's API does not support a query to fetch list of applications
Installation
via composer.json
"require": { "f-dg/adjust-api-sdk": "dev-master" }
or via git clone
git clone git@github.com:f-dg/adjust-api-sdk.git
Example of fetching Overview statistics
use \AdjustKPIService\OverviewStatistics, \AdjustKPIService\OverviewStatisticsValues as Params, \AdjustKPIService\adapter\CurlAdapter, \AdjustKPIService\AdjustKPIServiceException; try { $curlAdapter = new CurlAdapter; $apiConfig = [ 'user_token' => 'token1', 'app_token' => 'token2', ]; $startTimestamp = strtotime('-30 days'); $endTimestamp = time(); $params = new Params; $overviewStats = new OverviewStatistics($curlAdapter, $apiConfig); $data = $overviewStats->getData([ Params::REQUEST_PARAM_UTC_OFFSET => '00:00', Params::REQUEST_PARAM_START_DAY => $params->formatRequestDate($startTimestamp), Params::REQUEST_PARAM_END_DAY => $params->formatRequestDate($endTimestamp), Params::REQUEST_PARAM_KPIS => $params->getAppKPIListForRequest(), Params::REQUEST_PARAM_EVENT_KPIS => $params->getEventKPIListForRequest(), Params::REQUEST_PARAM_GROUPING => join(',', [Params::REQUEST_VALUE_GROUPING_TRACKER]), ]); print_r($data); } catch (AdjustKPIServiceException $e) { echo 'An error occurred: ' . PHP_EOL . $e->getMessage() . PHP_EOL; }
Example of fetching Event statistics
use \AdjustKPIService\EventStatistics, \AdjustKPIService\EventStatisticsValues as Params, \AdjustKPIService\adapter\CurlAdapter, \AdjustKPIService\AdjustKPIServiceException; try { $curlAdapter = new CurlAdapter; $apiConfig = [ 'user_token' => 'token1', 'app_token' => 'token2', ]; $startTimestamp = strtotime('-30 days'); $endTimestamp = time(); $params = new Params; $eventStats = new EventStatistics($curlAdapter, $apiConfig); $data = $eventStats->getData([ Params::REQUEST_PARAM_UTC_OFFSET => '00:00', Params::REQUEST_PARAM_START_DAY => $params->formatRequestDate($startTimestamp), Params::REQUEST_PARAM_END_DAY => $params->formatRequestDate($endTimestamp), Params::REQUEST_PARAM_KPIS => $params->getEventKPIListForRequest(), Params::REQUEST_PARAM_GROUPING => join(',', [ Params::REQUEST_VALUE_GROUPING_TRACKER, Params::REQUEST_VALUE_GROUPING_COUNTRIES, Params::REQUEST_VALUE_GROUPING_DAY, ]), ]); print_r($data); } catch (AdjustKPIServiceException $e) { echo 'An error occurred: ' . PHP_EOL . $e->getMessage() . PHP_EOL; }
Example of fetching Cohort statistics
use \AdjustKPIService\CohortStatistics, \AdjustKPIService\CohortStatisticsValues as Params, \AdjustKPIService\adapter\CurlAdapter, \AdjustKPIService\AdjustKPIServiceException; try { $curlAdapter = new CurlAdapter; $apiConfig = [ 'user_token' => 'token1', 'app_token' => 'token2', ]; $startTimestamp = strtotime('-30 days'); $endTimestamp = time(); $params = new Params; $cohortStats = new CohortStatistics($curlAdapter, $apiConfig); $data = $cohortStats->getData([ Params::REQUEST_PARAM_UTC_OFFSET => '00:00', Params::REQUEST_PARAM_START_DAY => $params->formatRequestDate($startTimestamp), Params::REQUEST_PARAM_END_DAY => $params->formatRequestDate($endTimestamp), Params::REQUEST_PARAM_KPIS => $params->getCohortKPIListForRequest(), Params::REQUEST_PARAM_GROUPING => join(',', [ Params::REQUEST_VALUE_GROUPING_TRACKER, Params::REQUEST_VALUE_GROUPING_COUNTRIES, Params::REQUEST_VALUE_GROUPING_DAY, ]), ]); print_r($data); } catch (AdjustKPIServiceException $e) { echo 'An error occurred: ' . PHP_EOL . $e->getMessage() . PHP_EOL; }
Unit tests
You may need to edit path to autoload.php in the phpunit.xml
bootstrap="./vendor/autoload.php"
cd path/to/adjust-api-sdk/tests && phpunit -v -c ../phpunit.xml . --coverage-text