Skip to content

Commit 9a0d88d

Browse files
authored
Add Watching Resource (#18)
* add watching resource/items method * bump version update changelog * update readme
1 parent f10991c commit 9a0d88d

File tree

8 files changed

+31
-6
lines changed

8 files changed

+31
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### 1.7.0
2+
**2016-11-29**
3+
4+
* Add watching resource (an alias to `customers/:id/watching`) with the `items` method.
5+
16
### 1.6.1
27
**2016-11-21**
38

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ You can install the bindings via [Composer](http://getcomposer.org/). Add this t
1212
```json
1313
{
1414
"require": {
15-
"vhx/vhx-php": "1.6.*"
15+
"vhx/vhx-php": "1.7.*"
1616
}
1717
}
1818
```
@@ -81,6 +81,9 @@ watchlist
8181
* [`addItem`](http://dev.vhx.tv/docs/api/?php#customer-watchlist-add-item)
8282
* [`removeItem`](http://dev.vhx.tv/docs/api/?php#customer-watchlist-remove-item)
8383

84+
watching
85+
* [`items`](http://dev.vhx.tv/docs/api/?php#customer-watching)
86+
8487
videos
8588
* [`create`](http://dev.vhx.tv/docs/api/?php#videos-create)
8689
* [`retrieve`](http://dev.vhx.tv/docs/api/?php#videos-get)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.6.1
1+
1.7.0

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vhx/vhx-php",
3-
"version": "1.6.1",
3+
"version": "1.7.0",
44
"description": "VHX PHP API Wrapper",
55
"keywords": [
66
"vhx",

init.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
require(dirname(__FILE__) . '/lib/Customers.php');
1212
require(dirname(__FILE__) . '/lib/Products.php');
1313
require(dirname(__FILE__) . '/lib/Videos.php');
14+
require(dirname(__FILE__) . '/lib/Watching.php');
1415
require(dirname(__FILE__) . '/lib/Watchlist.php');
1516

1617
// Errors

lib/Api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Api
77
public static $key;
88
const HOST = 'api.vhx.tv';
99
const PROTOCOL = 'https://';
10-
const VERSION = '1.6.0';
10+
const VERSION = '1.7.0';
1111

1212
public static function setKey($api_key) {
1313
self::$key = $api_key;

lib/Resource.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,11 @@ private static function _request($method, $path, $data = array()) {
121121
endif;
122122
}
123123

124-
protected static function _retrieve($id) {
124+
protected static function _retrieve($id, $scope = null) {
125+
$scope = isset($scope) ? '/' . $scope : '';
125126
$params = self::_getParameters($id);
126127
self::_hasID($id, 'retrieve');
127-
return self::_request('GET', self::_getResourceName() . '/' . $params['id']);
128+
return self::_request('GET', self::_getResourceName() . '/' . $params['id'] . $scope);
128129
}
129130

130131
protected static function _list($params) {
@@ -190,6 +191,8 @@ protected static function _matchClassToResource($class) {
190191
case 'watchlist':
191192
return 'customers';
192193
break;
194+
case 'watching':
195+
return 'customers';
193196
default:
194197
return $class;
195198
break;

lib/Watching.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace VHX;
4+
5+
class Watching extends Resource {
6+
public static function items($id = null, $params = array()) {
7+
if (is_array($id) && isset($id['customer'])) {
8+
$params = $id;
9+
$id = $id['customer'];
10+
}
11+
return self::_items($id, $params, 'watching');
12+
}
13+
}

0 commit comments

Comments
 (0)