scn/evalanche-reporting-api-connector
最新稳定版本:v2.0.0
Composer 安装命令:
composer require scn/evalanche-reporting-api-connector
包简介
Official PHP client for Evalanche Reporting API
README 文档
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-24hoursetc.
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::ISO8601TimeFormat::UNIXTimeFormat::RFC822TimeFormat::RFC850TimeFormat::RFC1036TimeFormat::RFC1123TimeFormat::RFC2822TimeFormat::RFC3339TimeFormat::W3C
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 29.9k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-10-18