2017 © Pedro Peláez
 

library adjust-api-sdk

PHP SDK for Adjust API

image

f-dg/adjust-api-sdk

PHP SDK for Adjust API

  • Monday, December 25, 2017
  • by fdg
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Adjust's web api documentations

Official doc, (*1)

A note - do not read a rus variant of the docs, cause some not translated docblock just dropped, (*2)

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, (*3)

The default is: + response as JSON", "CSV" not implemented + time zone of account's, (*4)

Adjust's API does not support a query to fetch list of applications, (*5)

Installation

via composer.json, (*6)

  "require": {
    "f-dg/adjust-api-sdk": "dev-master"
  }

or via git clone, (*7)

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, (*8)

bootstrap="./vendor/autoload.php"
cd path/to/adjust-api-sdk/tests && phpunit -v -c ../phpunit.xml . --coverage-text

The Versions

25/12 2017

dev-master

9999999-dev

PHP SDK for Adjust API

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Firsov Dmitry

25/12 2017

v0.1

0.1.0.0

PHP SDK for Adjust API

  Sources   Download

The Requires

  • php >=5.5.9

 

The Development Requires

by Firsov Dmitry