Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
cyriltata wants to merge27 commits intozencoder:master
base:master
Choose a base branch
Loading
fromcyriltata:reports-api
Open
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
27 commits
Select commitHold shift + click to select a range
f91060d
add access to reports api
Mar 11, 2014
7396e99
add reports object to zencoder api
Mar 11, 2014
c41ee1b
typo fixes
Mar 11, 2014
e433b13
auto-format
Mar 11, 2014
6798ce4
update README with reports api
Mar 11, 2014
dfe27dc
use doc space format
Mar 11, 2014
237615a
update README
Mar 12, 2014
efdd4df
Merge pull request #18 from zencoder/remove_ca_cert_bundle
Jul 25, 2014
290eb23
Merge pull request #19 from zencoder/remove_ca_cert_bundle
Jul 25, 2014
4607c61
Update README.md for formatting
Jul 29, 2014
e03988c
Make it so that you can set curl opts for CA paths and files
Jul 29, 2014
7673c4b
Bump version to 2.2.1 and add docs
Jul 29, 2014
b3046f2
Fixing a bug where api_key was set as api_version in the http connect…
Jul 29, 2014
f50a045
Documenting the changes in 2.2.2
Jul 29, 2014
e2604c4
Fixed the versions listed in the user agent and throughout the code
Jul 29, 2014
3fab4c9
add access to reports api
Mar 11, 2014
589c7c5
add reports object to zencoder api
Mar 11, 2014
c028c53
typo fixes
Mar 11, 2014
bde0dd2
auto-format
Mar 11, 2014
c09bf2c
update README with reports api
Mar 11, 2014
caee9fb
fix merge conflict
cyriltataJul 8, 2015
9463c66
fix merge error
cyriltataJul 8, 2015
7b74562
remove casting to different types of reports
cyriltataJul 8, 2015
bd90317
autoformat
cyriltataJul 8, 2015
0654a28
update Readme
cyriltataJul 8, 2015
28b1cfd
autoformat
cyriltataJul 8, 2015
86c4a2f
format doc code
cyriltataJul 8, 2015
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
PrevPrevious commit
NextNext commit
auto-format
  • Loading branch information
@cyriltata
Cyril Tata authored andcyriltata committedJul 8, 2015
commitbde0dd2d3729dfd0fb94d3e0790456ee65e2acd5
175 changes: 87 additions & 88 deletionsServices/Zencoder/Report.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,103 +12,102 @@
*/
class Services_Zencoder_Report extends Services_Zencoder_Object {

/**
* Array for statistics of the report
*
* @var array
*/
public $statistics = array();
/**
* Array for statistics of the report
*
* @var array
*/
public $statistics = array();

/**
* Holds the totals in case of single type of report
*
* @var mixed (Services_Zencoder_Report_VodTotal|Services_Zencoder_Report_LiveTotal)
*/
public $total;
/**
* Holds the totals in case of single type of report
*
* @var mixed (Services_Zencoder_Report_VodTotal|Services_Zencoder_Report_LiveTotal)
*/
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;

/**
* Flag to check if you will be filling array of arrays (when type = 'all')
*
* @var boolean
*/
protected $is_multiple = false;
/**
* Flag to check if you will be filling array of arrays (when type = 'all')
*
* @var boolean
*/
protected $is_multiple = false;

/**
* The type of report that is being fetched ('live', 'vod' 'minutes' or 'all')
*
* @var string
*/
protected $type;
/**
* The type of report that is being fetched ('live', 'vod' 'minutes' or 'all')
*
* @var string
*/
protected $type;

/**
* Create a new Services_Zencoder_Job object.
*
* @param mixed $params API response
* @param string $type The type of statistic we are fetching
*/
public function __construct($params, $type) {
$this->raw_response = $params;
$this->type = $type;
$this->is_multiple = $this->type === "all";
$this->_update_attributes($params);
}
/**
* Create a new Services_Zencoder_Job object.
*
* @param mixed $params API response
* @param string $type The type of statistic we are fetching
*/
public function __construct($params, $type) {
$this->raw_response = $params;
$this->type = $type;
$this->is_multiple = $this->type === "all";
$this->_update_attributes($params);
}

private function _update_attributes($attributes = array()) {
foreach ($attributes as $attr_name => $attr_value) {
if (($attr_name == "statistics")) {
if (!$this->is_multiple) {
$this->_create_statistics($attr_value, $this->type);
} else {
foreach ($attr_value as $type => $attrs) {
$this->_create_statistics($attrs, $type);
}
}
} elseif (($attr_name == "total")) {
if (!$this->is_multiple) {
$this->_create_totals($attr_value, $this->type);
} else {
foreach ($attr_value as $type => $attrs) {
$this->_create_totals($attrs, $type);
}
}

}
}
}
private function _update_attributes($attributes = array()) {
foreach ($attributes as $attr_name => $attr_value) {
if (($attr_name == "statistics")) {
if (!$this->is_multiple) {
$this->_create_statistics($attr_value, $this->type);
} else {
foreach ($attr_value as $type => $attrs) {
$this->_create_statistics($attrs, $type);
}
}
} elseif (($attr_name == "total")) {
if (!$this->is_multiple) {
$this->_create_totals($attr_value, $this->type);
} else {
foreach ($attr_value as $type => $attrs) {
$this->_create_totals($attrs, $type);
}
}
}
}
}

private function _create_statistics($statistics = array(), $type = null) {
$class = $this->_get_report_class('statistic', $type);
if ($this->is_multiple) {
$this->statistics[$type] = array();
}
private function _create_statistics($statistics = array(), $type = null) {
$class = $this->_get_report_class('statistic', $type);
if ($this->is_multiple) {
$this->statistics[$type] = array();
}

foreach ($statistics as $stat_attrs) {
if ($this->is_multiple) {
$this->statistics[$type][] = new $class($stat_attrs);
} else {
$this->statistics[] = new $class($stat_attrs);
}
}
}
foreach ($statistics as $stat_attrs) {
if ($this->is_multiple) {
$this->statistics[$type][] = new $class($stat_attrs);
} else {
$this->statistics[] = new $class($stat_attrs);
}
}
}

private function _create_totals($totals, $type = null) {
$class = $this->_get_report_class('total', $type);
if ($this->is_multiple) {
$this->total[$type] = new $class($totals);
} else {
$this->total = new $class($totals);
}
}
private function _create_totals($totals, $type = null) {
$class = $this->_get_report_class('total', $type);
if ($this->is_multiple) {
$this->total[$type] = new $class($totals);
} else {
$this->total = new $class($totals);
}
}

private function _get_report_class($attr_name, $type) {
return 'Services_Zencoder_Report_' . ucwords($type) . ucwords($attr_name);
}
private function _get_report_class($attr_name, $type) {
return 'Services_Zencoder_Report_' . ucwords($type) . ucwords($attr_name);
}

}
88 changes: 44 additions & 44 deletionsServices/Zencoder/Reports.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,49 +10,49 @@
* @license http://creativecommons.org/licenses/MIT/MIT
* @link http://github.com/zencoder/zencoder-php
*/
class Services_Zencoder_Reports extends Services_Zencoder_Base {

/**
* A list of valid 'methods' to be trapped in __call()
*
* @link https://app.zencoder.com/docs/api/reports/
* @var array
*/
protected $methods = array('vod', 'live', 'minutes', 'all');

/**
* Return all reports for VOD
*
* @link https://app.zencoder.com/docs/api/reports
*
* @param string $method The method name indicates the type of report we want to get
* @param array $args A list of arguments for the overriden methods. Each methods takes 2 arguements.
* The first being an associative array of query string parameters and the second
* an associative array of option overrides
*
* @throws Services_Zencoder_Exception
*
* @return Services_Zencoder_Report The object representation of the resource
*/
public function __call($method, $args) {
if (!in_array($method, $this->methods)) {
throw new Services_Zencoder_Exception("Unsupported method call '$method' for Services_Zencoder_Reports");
}

// initialize query string parameters and optional overrides
$params = $opts = array();

// set query string parameters
if (isset($args[0]) && is_array($args[0])) {
$params = $args[0];
}

// set optional overrides
if (isset($args[1]) && is_array($args[1])) {
$opts = $args[1];
}

return new Services_Zencoder_Report($this->proxy->retrieveData("reports/$method", $params, $opts), $method);
}
class Services_Zencoder_Reports extends Services_Zencoder_Base
{
/**
* A list of valid 'methods' to be trapped in __call()
*
* @link https://app.zencoder.com/docs/api/reports/
* @var array
*/
protected $methods = array('vod', 'live', 'minutes', 'all');

/**
* Return all reports for VOD
*
* @link https://app.zencoder.com/docs/api/reports
*
* @param string $method The method name indicates the type of report we want to get
* @param array $args A list of arguments for the overriden methods. Each methods takes 2 arguements.
* The first being an associative array of query string parameters and the second
* an associative array of option overrides
*
* @throws Services_Zencoder_Exception
*
* @return Services_Zencoder_Report The object representation of the resource
*/
public function __call($method, $args) {
if (!in_array($method, $this->methods)) {
throw new Services_Zencoder_Exception("Unsupported method call '$method' for Services_Zencoder_Reports");
}

// initialize query string parameters and optional overrides
$params = $opts = array();

// set query string parameters
if (isset($args[0]) && is_array($args[0])) {
$params = $args[0];
}

// set optional overrides
if (isset($args[1]) && is_array($args[1])) {
$opts = $args[1];
}

return new Services_Zencoder_Report($this->proxy->retrieveData("reports/$method", $params, $opts), $method);
}

}

[8]ページ先頭

©2009-2025 Movatter.jp