scn / evalanche-reporting-api-connector
Official PHP client for Evalanche Reporting API
Installs: 26 532
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 9
Forks: 5
Open Issues: 0
Requires
- php: ^8.0||^8.1
- ext-json: *
- php-http/discovery: ^1.13
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- guzzlehttp/guzzle: ^7.4
- phpstan/phpstan: ^1.3
- phpstan/phpstan-strict-rules: ^1.1
- phpunit/phpunit: ^9
- rector/rector: ^0.13
This package is auto-updated.
Last update: 2024-12-07 06:15:12 UTC
README
Install
Via Composer
$ composer require scn/evalanche-reporting-api-connector
Usage
General
First create a connection with the access credentials provided by SC-Networks.
use Scn\EvalancheReportingApiConnector\Enum\Language; use Scn\EvalancheReportingApiConnector\Enum\TimeFormat; use Scn\EvalancheReportingApiConnector\EvalancheConfig; use Scn\EvalancheReportingApiConnector\EvalancheConnection; $connection = EvalancheConnection::create( new EvalancheConfig( 'your evalanche hostname (no uri, just the hostname)', 'username', 'password', Language::LANG_EN, TimeFormat::ISO8601, ), // $requestFactory, (optional existing PSR-17 RequestFactory instance) // $httpClient, (optional existing PSR-18 Http-Client instance) );
The EvalancheConnection class provides one method for each table. E.g. the method getPools()
queries the table 'pools'.
These methods each return a specific client class, e.g. PoolsClient
, to specify further options and to receive the data in different formats.
A minimal working example could be:
$connection->getPools()->asXml();
The available methods follow the "Fluent Interface" pattern, which means they enable method chaining.
The call of a format method like asXml()
or asCsv()
is always the last call in the chain, as it returns the data.
Methods
The following methods are available:
getArticleReferences(int $customer_id)
getCustomers()
getForms()
getGeoCoordinates(int $customer_id)
getLeadpages(int $customerId = null)
getMailings()
getMilestoneProfiles(int $customer_id)
getNewsletterSendlogs(int $customer_id)
getPools()
getProfileChangelogs(int $pool_id)
getProfiles(int $pool_id)
getProfileScores()
getResourceTypes()
getScoringCluster()
getScoringGroups()
getScoringHistory()
getTrackingHistory()
getTrackingTypes()
Formats
At the current state you can choose between the following formats:
JsonArray
Example:
$connection->getPools()->asJsonArray();
Returns an array of stdClass objects.
JsonObject
Example:
$connection->getPools()->asJsonObject();
Returns a stdClass object.
XML
Example:
$connection->getPools()->asXml();
Returns a string, containing valid xml.
CSV
Example:
$connection->getPools()->asCsv();
Returns a string with comma separated values. The first line contains the column titles.
Parameters
Some tables provide further options or mandatory parameters:
Customer id (int)
Use it to get the results for a specific customer, instead of the current customer.
Example:
$connection->getLeadpages(1234)->asJsonArray();
Provided by:
- getLeadpages (optional)
- getNewsletterSendlogs
Pool id (int)
Id of the pool you want to get results for.
Example:
$connection->getProfiles(123)->asJsonArray();
Provided by:
- getProfiles
- getLeadpages
Time restrictions
Limit the result to a defined time span by using the method withTimeRestriction(string $from = null, string $to = null)
. Both parameters are optional and can be replaced by null
.
Examples:
Everything since yesterday:
$connection ->getMailings() ->withTimeRestriction('yesterday') ->asJsonArray();
From date to yesterday:
$connection ->getMailings() ->withTimeRestriction('2018-09-27', 'yesterday') ->asJsonArray();
Everything until yesterday:
$connection ->getMailings() ->withTimeRestriction(null, 'yesterday') ->asJsonArray();
Possible values:
- date:
2018-08-03
,03.08.2018
- date and time:
03.08.2018 07:30
- relative values:
yesterday
,last monday
,now-24hours
etc.
Provided by:
- getMailings
- getNewsletterSendLogs
- getProfiles
- getScoringHistory
- getTrackingHistory
Language
Default language is English, but you can pass a different language code when establishing the connection.
Use the provided Enums in the class \Scn\EvalancheReportingApiConnector\Enum\Language
Example
use Scn\EvalancheReportingApiConnector\Enum\Language; use Scn\EvalancheReportingApiConnector\EvalancheConnection; $connection = EvalancheConnection::create( 'given host', 'given username', 'given password', Language::LANG_DE );
Possible values
- English:
Language::LANG_EN
- German:
Language::LANG_DE
- Italian:
Language::LANG_IT
- French:
Language::LANG_FR
Time format
Default time format is iso8601, but you can pass a different format code when establishing the connection.
Use the provided Enums in the class \Scn\EvalancheReportingApiConnector\Enum\TimeFormat
Example
use Scn\EvalancheReportingApiConnector\EvalancheConnection; use Scn\EvalancheReportingApiConnector\Enum\Language; use Scn\EvalancheReportingApiConnector\Enum\TimeFormat; $connection = EvalancheConnection::create( 'given host', 'given username', 'given password', Language::LANG_DE, TimeFormat::UNIX, );
Possible values
TimeFormat::ISO8601
TimeFormat::UNIX
TimeFormat::RFC822
TimeFormat::RFC850
TimeFormat::RFC1036
TimeFormat::RFC1123
TimeFormat::RFC2822
TimeFormat::RFC3339
TimeFormat::W3C
License
The MIT License (MIT). Please see License File for more information.