Skip to content

Commit 5ec3927

Browse files
author
Michael Christopher
committed
Completed classes for Job and Output, added structures for Account and Input
1 parent ee22220 commit 5ec3927

File tree

7 files changed

+123
-6
lines changed

7 files changed

+123
-6
lines changed

Services/Zencoder/Account.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/*
3+
4+
Zencoder API PHP Library
5+
Version: 2.0
6+
See the README file for info on how to use this library.
7+
8+
*/
9+
10+
class Services_Zencoder_Account {
11+
public $id;
12+
13+
public function __construct($params) {
14+
$this->update_attributes($params);
15+
}
16+
17+
private function update_attributes($attributes = array()) {
18+
foreach($attributes as $attr_name => $attr_value) {
19+
if(!function_exists($this->$attr_name)) {
20+
$this->$attr_name = $attr_value;
21+
}
22+
}
23+
}
24+
}

Services/Zencoder/Http.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public function __call($name, $args) {
3333
CURLOPT_POSTFIELDS => NULL,
3434
CURLOPT_CONNECTTIMEOUT => 30,
3535
CURLOPT_TIMEOUT => 30,
36-
CURLOPT_SSL_VERIFYPEER => 1,
37-
CURLOPT_SSL_VERIFYHOST => 2
36+
CURLOPT_SSL_VERIFYPEER => 0,
37+
CURLOPT_SSL_VERIFYHOST => 0
3838
);
3939

4040
foreach ($req_headers as $k => $v) $opts[CURLOPT_HTTPHEADER][] = "$k: $v";

Services/Zencoder/Input.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/*
3+
4+
Zencoder API PHP Library
5+
Version: 2.0
6+
See the README file for info on how to use this library.
7+
8+
*/
9+
10+
class Services_Zencoder_Input {
11+
public $id;
12+
13+
public function __construct($params) {
14+
$this->update_attributes($params);
15+
}
16+
17+
private function update_attributes($attributes = array()) {
18+
foreach($attributes as $attr_name => $attr_value) {
19+
if(!function_exists($this->$attr_name)) {
20+
$this->$attr_name = $attr_value;
21+
}
22+
}
23+
}
24+
}

Services/Zencoder/Job.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/*
3+
4+
Zencoder API PHP Library
5+
Version: 2.0
6+
See the README file for info on how to use this library.
7+
8+
*/
9+
10+
class Services_Zencoder_Job {
11+
public $id, $test, $state, $outputs = array();
12+
protected $raw_response;
13+
14+
public function __construct($params) {
15+
$this->raw_response = $params;
16+
$this->update_attributes($params);
17+
}
18+
19+
private function update_attributes($attributes = array()) {
20+
foreach($attributes as $attr_name => $attr_value) {
21+
if($attr_name == "outputs" && is_array($attr_value)) {
22+
$this->create_outputs($attr_value);
23+
} elseif (!function_exists($this->$attr_name)) {
24+
$this->$attr_name = $attr_value;
25+
}
26+
}
27+
}
28+
29+
private function create_outputs($outputs = array()) {
30+
foreach($outputs as $output_attrs) {
31+
if(!empty($output_attrs->label)) {
32+
$this->outputs[$output_attrs->label] = new Services_Zencoder_Output($output_attrs);
33+
} else {
34+
$this->outputs[] = new Services_Zencoder_Output($output_attrs);
35+
}
36+
}
37+
}
38+
}

Services/Zencoder/Jobs.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99

1010
class Services_Zencoder_Jobs extends Services_Zencoder_Base {
11-
public $id, $test, $state, $outputs = array();
1211

1312
public function create($params = NULL) {
1413
if(is_string($params)) {
@@ -19,7 +18,11 @@ public function create($params = NULL) {
1918
throw new Services_Zencoder_Exception(
2019
'Job parameters required to create job.');
2120
}
22-
return $request = $this->proxy->createData("jobs", $json);
21+
$request = $this->proxy->createData("jobs", $json);
22+
if ($request) {
23+
return new Services_Zencoder_Job($request);
24+
}
25+
throw new Services_Zencoder_Exception('Unable to create job');
2326
}
2427

2528
public function index() {

Services/Zencoder/Notifications.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99

1010
class Services_Zencoder_Notifications extends Services_Zencoder_Base {
1111
public function parseIncoming() {
12-
$notification_data = json_decode(trim(file_get_contents('php://input')), true);
13-
return new Services_Zencoder_Notification($notification_data);
12+
$incoming_data = json_decode(trim(file_get_contents('php://input')), true);
13+
if (!$incoming_data) {
14+
throw new Services_Zencoder_Exception(
15+
'Unable to parse notification data: ' . file_get_contents('php://input'));
16+
}
17+
return new Services_Zencoder_Notification();
1418
}
1519
}

Services/Zencoder/Output.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/*
3+
4+
Zencoder API PHP Library
5+
Version: 2.0
6+
See the README file for info on how to use this library.
7+
8+
*/
9+
10+
class Services_Zencoder_Output {
11+
public $id, $label, $url, $state, $error_message, $error_link;
12+
13+
public function __construct($params) {
14+
$this->update_attributes($params);
15+
}
16+
17+
private function update_attributes($attributes = array()) {
18+
foreach($attributes as $attr_name => $attr_value) {
19+
if(!function_exists($this->$attr_name)) {
20+
$this->$attr_name = $attr_value;
21+
}
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)