Skip to content

Reports api #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
autoformat
  • Loading branch information
cyriltata committed Jul 8, 2015
commit 28b1cfd41893d61a9a7eb93a58ace9a04422cb1a
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,19 @@ Create a script to get usage for VOD
'from' => '2014-02-01',
'to' => '2014-02-28',
)

// 'all' can be replaced by 'vod' or 'live' acccording to entry points in docs
$reports = $zencoder->reports->details('all', $params);
// Each reports object should have a 'statistics' and 'total' base element
if ($reports->statistics) {
foreach ($reports->statistics as $statistic) {
print_r($statistic);
}
print_r($reports->total);
} else {
echo "no statistics found";
$report = $zencoder->reports->details('all', $params);

// Each reports object should have a 'statistics' and 'total' base element
if ($report->statistics) {
foreach ($report->statistics as $statistic) {
print_r($statistic);
}
print_r($report->total);
} else {
echo "no statistics found";
}

```

Expand Down
64 changes: 32 additions & 32 deletions Services/Zencoder/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,40 @@
*/
class Services_Zencoder_Report extends Services_Zencoder_Object {

/**
* Statistics of a report
*
* @var object
*/
public $statistics;
/**
* Statistics of a report
*
* @var object
*/
public $statistics;

/**
* Totals of a of report
*
* @var object
*/
public $total;
/**
* Totals of a of report
*
* @var object
*/
public $total;

/**
* A copy of the raw API response for debug purposes
*
* @var mixed
*/
protected $raw_response;
/**
* A copy of the raw API response for debug purposes
*
* @var mixed
*/
protected $raw_response;

/**
* Create a new Services_Zencoder_Report object.
* For attributes of the various kinds of reports, see
* @link https://app.zencoder.com/docs/api/reports/vod
* @link https://app.zencoder.com/docs/api/reports/live
* @link https://app.zencoder.com/docs/api/reports/all
*
* @param mixed $params API response
* @param string $type The type of statistic we are fetching
*/
public function __construct($params) {
$this->raw_response = $params;
parent::__construct($params);
}
/**
* Create a new Services_Zencoder_Report object.
* For attributes of the various kinds of reports, see
* @link https://app.zencoder.com/docs/api/reports/vod
* @link https://app.zencoder.com/docs/api/reports/live
* @link https://app.zencoder.com/docs/api/reports/all
*
* @param mixed $params API response
* @param string $type The type of statistic we are fetching
*/
public function __construct($params) {
$this->raw_response = $params;
parent::__construct($params);
}

}
34 changes: 17 additions & 17 deletions Services/Zencoder/Reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@
*/
class Services_Zencoder_Reports extends Services_Zencoder_Base {

/**
* Get details about different types of reports
*
* @link https://app.zencoder.com/docs/api/reports
*
* @param string $report_type The type of report to get. The following are currently supported over the api
* - 'all' : Returns all reports, both VOD and LIVE
* - 'vod' : Returns VOD reports
* - 'live': Return LIVE reports
* @param array $params An associated array of optional query parameters per requested report type
* @param array $opts Optional overrides
*
* @return Services_Zencoder_Report The object representation of the resource
*/
public function details($report_type = 'all', $params = array(), $opts = array()) {
return new Services_Zencoder_Report($this->proxy->retrieveData("reports/$report_type", $params, $opts));
}
/**
* Get details about different types of reports
*
* @link https://app.zencoder.com/docs/api/reports
*
* @param string $report_type The type of report to get. The following are currently supported over the api
* - 'all' : Returns all reports, both VOD and LIVE
* - 'vod' : Returns VOD reports
* - 'live': Return LIVE reports
* @param array $params An associated array of optional query parameters per requested report type
* @param array $opts Optional overrides
*
* @return Services_Zencoder_Report The object representation of the resource
*/
public function details($report_type = 'all', $params = array(), $opts = array()) {
return new Services_Zencoder_Report($this->proxy->retrieveData("reports/$report_type", $params, $opts));
}

}