Applications.php
1 year ago
Campaigns.php
1 year ago
Deliveries.php
1 year ago
Events.php
1 year ago
Installations.php
1 year ago
Rest.php
1 year ago
Segments.php
1 year ago
Stats.php
1 year ago
Applications.php
41 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WonderPush\Api; |
| 4 | |
| 5 | if (count(get_included_files()) === 1) { http_response_code(403); exit(); } // Prevent direct access |
| 6 | |
| 7 | use WonderPush\Obj\ApplicationCollection; |
| 8 | use WonderPush\Params\CollectionParams; |
| 9 | |
| 10 | /** |
| 11 | * Applications API. |
| 12 | */ |
| 13 | class Applications { |
| 14 | |
| 15 | /** |
| 16 | * Instance of the library whose credentials are to be used. |
| 17 | * @var \WonderPush\WonderPush |
| 18 | */ |
| 19 | private $wp; |
| 20 | |
| 21 | public function __construct(\WonderPush\WonderPush $wp) { |
| 22 | $this->wp = $wp; |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * List applications associated with the access token used to initialize the WonderPush object. |
| 27 | * @param array|CollectionParams $collectionParams |
| 28 | * @return ApplicationCollection |
| 29 | * @throws \WonderPush\Errors\Base |
| 30 | */ |
| 31 | public function all($collectionParams = array()) { |
| 32 | $response = $this->wp->rest()->get('/applications', is_array($collectionParams) ? $collectionParams : $collectionParams->toArray()); |
| 33 | return $response->checkedResult('\WonderPush\Obj\ApplicationCollection'); |
| 34 | } |
| 35 | |
| 36 | public function patch($applicationId, $body = array(), $params = array()) { |
| 37 | $response = $this->wp->rest()->patch('/applications/' . $applicationId, array_merge($params, array('body' => $body))); |
| 38 | return $response->checkedResult('\WonderPush\Obj\Application', 'application'); |
| 39 | } |
| 40 | } |
| 41 |