Skip to content

Commit

Permalink
phpdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
norkunas committed May 24, 2015
1 parent 3315717 commit de437e1
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 21 deletions.
37 changes: 36 additions & 1 deletion src/Apps.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Apps
protected $api;

/**
* Constructor
* Constructor.
*
* @param OneSignal $api
*/
Expand All @@ -20,6 +20,15 @@ public function __construct(OneSignal $api)
$this->api = $api;
}

/**
* Get information about application with provided ID.
*
* User authentication key must be set.
*
* @param string $id ID of your application
*
* @return array
*/
public function getOne($id)
{
return $this->api->request('GET', '/apps/' . $id, [
Expand All @@ -29,6 +38,13 @@ public function getOne($id)
]);
}

/**
* Get information about all your created applications.
*
* User authentication key must be set.
*
* @return array
*/
public function getAll()
{
return $this->api->request('GET', '/apps', [
Expand All @@ -38,6 +54,15 @@ public function getAll()
]);
}

/**
* Create a new application with provided data.
*
* User authentication key must be set.
*
* @param array $data Application data
*
* @return array
*/
public function add(array $data)
{
$data = $this->resolve($data);
Expand All @@ -51,6 +76,16 @@ public function add(array $data)
]);
}

/**
* Update application with provided data.
*
* User authentication key must be set.
*
* @param string $id ID of your application
* @param array $data New application data
*
* @return \GuzzleHttp\Message\Response
*/
public function update($id, array $data)
{
$data = $this->resolve($data);
Expand Down
12 changes: 6 additions & 6 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Config
protected $userAuthKey;

/**
* Set OneSignal application id
* Set OneSignal application id.
*
* @param string $applicationId
*/
Expand All @@ -29,7 +29,7 @@ public function setApplicationId($applicationId)
}

/**
* Get OneSignal application id
* Get OneSignal application id.
*
* @return string
*/
Expand All @@ -39,7 +39,7 @@ public function getApplicationId()
}

/**
* Set OneSignal application authentication key
* Set OneSignal application authentication key.
*
* @param string $applicationAuthKey
*/
Expand All @@ -49,7 +49,7 @@ public function setApplicationAuthKey($applicationAuthKey)
}

/**
* Get OneSignal application authentication key
* Get OneSignal application authentication key.
*
* @return string
*/
Expand All @@ -59,7 +59,7 @@ public function getApplicationAuthKey()
}

/**
* Set user authentication key
* Set user authentication key.
*
* @param string $userAuthKey
*/
Expand All @@ -69,7 +69,7 @@ public function setUserAuthKey($userAuthKey)
}

/**
* Get user authentication key
* Get user authentication key.
*
* @return string
*/
Expand Down
34 changes: 33 additions & 1 deletion src/Devices.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Devices
protected $api;

/**
* Constructor
* Constructor.
*
* @param OneSignal $api
*/
Expand All @@ -25,11 +25,28 @@ public function __construct(OneSignal $api)
$this->api = $api;
}

/**
* Get information about device with provided ID.
*
* @param string $id Device ID
*
* @return \GuzzleHttp\Message\Response
*/
public function getOne($id)
{
return $this->api->request('GET', '/players/' . $id);
}

/**
* Get information about all registered devices for your application.
*
* Application auth key must be set.
*
* @param int $limit Results offset (results are sorted by ID)
* @param int $offset How many devices to return (max 50)
*
* @return array
*/
public function getAll($limit = 50, $offset = 0)
{
return $this->api->request('GET', '/players?' . http_build_query([
Expand All @@ -45,6 +62,13 @@ public function getAll($limit = 50, $offset = 0)
]);
}

/**
* Register a device for your application.
*
* @param array $data Device data
*
* @return array
*/
public function add(array $data)
{
$data = $this->resolve($data, function (OptionsResolver $resolver) {
Expand All @@ -67,6 +91,14 @@ public function add(array $data)
]);
}

/**
* Update existing registered device for your application with provided data.
*
* @param string $id Device ID
* @param array $data New device data
*
* @return array
*/
public function update($id, array $data)
{
$data = $this->resolve($data);
Expand Down
6 changes: 3 additions & 3 deletions src/Exception/OneSignalException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class OneSignalException extends \RuntimeException
protected $errors;

/**
* Constructor
* Constructor.
*
* @param int $statusCode HTTP Status Code
* @param array $errors [optional] Errors list
Expand All @@ -29,7 +29,7 @@ public function __construct($statusCode, $errors = [], $message = '', $code = 0,
}

/**
* Get http status code
* Get http status code.
*
* @return int
*/
Expand All @@ -39,7 +39,7 @@ public function getStatusCode()
}

/**
* Get errors list
* Get errors list.
*
* @return array
*/
Expand Down
46 changes: 46 additions & 0 deletions src/Notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ public function __construct(OneSignal $api)
$this->api = $api;
}

/**
* Get information about notification with provided ID.
*
* Application authentication key and ID must be set.
*
* @param string $id Notification ID
*
* @return array
*/
public function getOne($id)
{
$url = '/notifications/' . $id . '?app_id=' . $this->api->getConfig()->getApplicationId();
Expand All @@ -32,6 +41,16 @@ public function getOne($id)
]);
}

/**
* Get information about all notifications.
*
* Application authentication key and ID must be set.
*
* @param int $limit Results offset (results are sorted by ID)
* @param int $offset How many notifications to return (max 50)
*
* @return array
*/
public function getAll($limit = null, $offset = null)
{
return $this->api->request('GET', '/notifications?' . http_build_query([
Expand All @@ -47,6 +66,15 @@ public function getAll($limit = null, $offset = null)
]);
}

/**
* Send new notification with provided data.
*
* Application authentication key and ID must be set.
*
* @param array $data
*
* @return array
*/
public function add(array $data)
{
$data = $this->resolve($data);
Expand All @@ -60,6 +88,15 @@ public function add(array $data)
]);
}

/**
* Open notification.
*
* Application authentication key and ID must be set.
*
* @param string $id Notification ID
*
* @return array
*/
public function open($id)
{
return $this->api->request('PUT', '/notifications/' . $id, [
Expand All @@ -73,6 +110,15 @@ public function open($id)
]);
}

/**
* Cancel notification.
*
* Application authentication key and ID must be set.
*
* @param string $id Notification ID
*
* @return array
*/
public function cancel($id)
{
return $this->api->request('DELETE', '/notifications/' . $id, [
Expand Down
20 changes: 10 additions & 10 deletions src/OneSignal.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
use OneSignal\Exception\OneSignalException;

/**
* @property-read Apps $apps
* @property-read Devices $devices
* @property-read Notifications $notifications
* @property-read Apps $apps Applications API service.
* @property-read Devices $devices Devices API service.
* @property-read Notifications $notifications Notifications API service.
*/
class OneSignal
{
Expand All @@ -31,7 +31,7 @@ class OneSignal
protected $services = [];

/**
* Constructor
* Constructor.
*
* @param Config $config
* @param Client $client
Expand All @@ -49,7 +49,7 @@ public function __construct(Config $config = null, Client $client = null)
}

/**
* Set config
* Set config.
*
* @param Config $config
*/
Expand All @@ -59,7 +59,7 @@ public function setConfig(Config $config)
}

/**
* Get config
* Get config.
*
* @return Config
*/
Expand All @@ -69,7 +69,7 @@ public function getConfig()
}

/**
* Set client
* Set client.
*
* @param Client $client
*/
Expand All @@ -79,7 +79,7 @@ public function setClient(Client $client)
}

/**
* Get client
* Get client.
*
* @return Client
*/
Expand All @@ -89,7 +89,7 @@ public function getClient()
}

/**
* Make a custom api request
* Make a custom api request.
*
* @param string $method HTTP Method
* @param string $uri URI template
Expand Down Expand Up @@ -127,7 +127,7 @@ public function request($method, $uri, array $options = [])
}

/**
* Create required services on the fly
* Create required services on the fly.
*
* @param string $name
*
Expand Down

0 comments on commit de437e1

Please sign in to comment.