This connector is work in progress, methods and parameter may change. Please do NOT use it in production until the first official release.
Via Composer
$ composer require scn/evalanche-reporting-api-connector
First create a connection with the access credentials provided by SC-Networks.
$connection = \Scn\EvalancheReportingApiConnector\EvalancheConnection::create(
'given host',
'given username',
'given password'
);
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.
The following methods are available:
getCheckpoints(int $customerId = null)
getCustomers()
getForms()
getLeadpages(int $customerId = null)
getMailings()
getPools()
getProfileChangelogs(int $pool_id)
getProfiles(int $pool_id)
getProfileScores()
getResourceTypes()
getScoringGroups()
getScoringHistory()
getTrackingHistory()
getTrackingTypes()
getNewsletterSendlogs(int $customer_id)
At the current state you can choose between the following formats:
Example: $connection->getPools()->asJsonArray();
Returns an array of stdClass objects.
Example: $connection->getPools()->asJsonObject();
Returns a stdClass object.
Example: $connection->getPools()->asXml();
Returns a string, containing valid xml.
Example: $connection->getPools()->asCsv();
Returns a string with comma separated values. The first line contains the column titles.
Some tables provide further options or mandatory parameters:
Use it to get the results for a specific customer, instead of the current customer.
$connection->getLeadpages(1234)->asJsonArray();
- getCheckpoints (optional)
- getLeadpages (optional)
- getNewsletterSendlogs
Id of the pool you want to get results for.
$connection->getProfiles(123)->asJsonArray();
- getProfiles
- getLeadpages
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
.
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();
- date:
2018-08-03,
,03.08.2018
- date and time:
03.08.2018 07:30
- relative values:
yesterday
,last monday
,now-24hours
etc.
- getMailings
- getNewsletterSendLogs
- getProfiles
- getScoringHistory
- getTrackingHistory
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
:
$connection = \Scn\EvalancheReportingApiConnector\EvalancheConnection::create(
'given host',
'given username',
'given password',
\Scn\EvalancheReportingApiConnector\Enum\Language::LANG_DE
);
- English:
Language::LANG_EN
- German:
Language::LANG_DE
- Italian:
Language::LANG_IT
- French:
Language::LANG_FR
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
:
$connection = \Scn\EvalancheReportingApiConnector\EvalancheConnection::create(
'given host',
'given username',
'given password',
\Scn\EvalancheReportingApiConnector\Enum\Language::LANG_DE,
\Scn\EvalancheReportingApiConnector\Enum\TimeFormat::UNIX,
);
TimeFormat::ISO8601
TimeFormat::UNIX
TimeFormat::RFC822
TimeFormat::RFC850
TimeFormat::RFC1036
TimeFormat::RFC1123
TimeFormat::RFC2822
TimeFormat::RFC3339
TimeFormat::W3C
The MIT License (MIT). Please see License File for more information.