├── LICENSE.md ├── README.md ├── composer.json ├── phpunit.xml.dist └── src └── main ├── php └── Gomoob │ └── Pushwoosh │ ├── Client │ ├── CURLClient.php │ ├── Pushwoosh.php │ └── PushwooshMock.php │ ├── Curl │ ├── CurlRequest.php │ └── ICurlRequest.php │ ├── Exception │ └── PushwooshException.php │ ├── ICURLClient.php │ ├── IPushwoosh.php │ ├── JsonUtils.php │ └── Model │ ├── Condition │ ├── AbstractCondition.php │ ├── DateCondition.php │ ├── ICondition.php │ ├── IntCondition.php │ ├── ListCondition.php │ └── StringCondition.php │ ├── IRequest.php │ ├── IResponse.php │ ├── Notification │ ├── ADM.php │ ├── Android.php │ ├── BlackBerry.php │ ├── Chrome.php │ ├── Firefox.php │ ├── IOS.php │ ├── Mac.php │ ├── MinimizeLink.php │ ├── Notification.php │ ├── Platform.php │ ├── Safari.php │ ├── WNS.php │ └── WP.php │ ├── Request │ ├── AbstractRequest.php │ ├── CreateMessageRequest.php │ ├── CreateTargetedMessageRequest.php │ ├── DeleteMessageRequest.php │ ├── GetNearestZoneRequest.php │ ├── GetTagsRequest.php │ ├── PushStatRequest.php │ ├── RegisterDeviceRequest.php │ ├── SetBadgeRequest.php │ ├── SetTagsRequest.php │ └── UnregisterDeviceRequest.php │ └── Response │ ├── AbstractResponse.php │ ├── CreateMessageResponse.php │ ├── CreateMessageResponseResponse.php │ ├── CreateTargetedMessageResponse.php │ ├── CreateTargetedMessageResponseResponse.php │ ├── DeleteMessageResponse.php │ ├── GetNearestZoneResponse.php │ ├── GetNearestZoneResponseResponse.php │ ├── GetTagsResponse.php │ ├── GetTagsResponseResponse.php │ ├── PushStatResponse.php │ ├── RegisterDeviceResponse.php │ ├── SetBadgeResponse.php │ ├── SetTagsResponse.php │ └── UnregisterDeviceResponse.php └── resources └── cacert.pem /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 GOMOOB SARL. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # php-pushwoosh 2 | 3 | > A PHP Library to easily send push notifications with the Pushwoosh REST Web Services. 4 | 5 | [![Total Downloads](https://img.shields.io/packagist/dt/gomoob/php-pushwoosh.svg?style=flat-square)](https://packagist.org/packages/gomoob/php-pushwoosh) 6 | [![Latest Stable Version](https://img.shields.io/packagist/v/gomoob/php-pushwoosh.svg?style=flat-square)](https://packagist.org/packages/gomoob/php-pushwoosh) 7 | [![Build Status](https://img.shields.io/travis/gomoob/php-pushwoosh.svg?style=flat-square)](https://travis-ci.org/gomoob/php-pushwoosh) 8 | [![Coverage](https://img.shields.io/coveralls/gomoob/php-pushwoosh.svg?style=flat-square)](https://coveralls.io/r/gomoob/php-pushwoosh?branch=master) 9 | [![Code Climate](https://img.shields.io/codeclimate/github/gomoob/php-pushwoosh.svg?style=flat-square)](https://codeclimate.com/github/gomoob/php-pushwoosh) 10 | [![License](https://img.shields.io/packagist/l/gomoob/php-pushwoosh.svg?style=flat-square)](https://packagist.org/packages/gomoob/php-pushwoosh) 11 | 12 | ## First sample, creating a Pushwoosh message 13 | 14 | ```php 15 | // Create a Pushwoosh client 16 | $pushwoosh = Pushwoosh::create() 17 | ->setApplication('XXXX-XXX') 18 | ->setAuth('xxxxxxxx'); 19 | 20 | // Create a request for the '/createMessage' Web Service 21 | $request = CreateMessageRequest::create() 22 | ->addNotification(Notification::create()->setContent('Hello Jean !')); 23 | 24 | // Call the REST Web Service 25 | $response = $pushwoosh->createMessage($request); 26 | 27 | // Check if its ok 28 | if($response->isOk()) { 29 | print 'Great, my message has been sent !'; 30 | } else { 31 | print 'Oups, the sent failed :-('; 32 | print 'Status code : ' . $response->getStatusCode(); 33 | print 'Status message : ' . $response->getStatusMessage(); 34 | } 35 | ``` 36 | 37 | Easy, isn't it ? 38 | 39 | ## Documentation 40 | 41 | * [Documentation](http://gomoob.github.io/php-pushwoosh) 42 | * [How to Contribute](http://gomoob.github.io/php-pushwoosh/contribute.html) 43 | 44 | ## Framework Integrations 45 | - **Laravel** - https://github.com/schimpanz/Laravel-Pushwoosh 46 | - **Symfony 2** - https://github.com/Prezent/pushwoosh-bundle 47 | 48 | If you have integrated php-pushwoosh into a popular PHP framework let us know ! 49 | 50 | ## About Gomoob 51 | 52 | At [Gomoob](https://www.gomoob.com) we build high quality software with awesome Open Source frameworks everyday. Would 53 | you like to start your next project with us? That's great! Give us a call or send us an email and we will get back to 54 | you as soon as possible ! 55 | 56 | You can contact us by email at [contact@gomoob.com](mailto:contact@gomoob.com) or by phone number 57 | [(+33) 6 85 12 81 26](tel:+33685128126) or [(+33) 6 28 35 04 49](tel:+33685128126). 58 | 59 | Visit also http://gomoob.github.io to discover more Open Source softwares we develop. 60 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "gomoob/php-pushwoosh", 3 | "description" : "A PHP Library to easily send push notifications with the Pushwoosh REST Web Services.", 4 | "license" : "MIT", 5 | "type" : "library", 6 | "keywords" : [ 7 | "gomoob", 8 | "notification", 9 | "push", 10 | "pushwoosh" 11 | ], 12 | "authors" : [{ 13 | "name" : "GoMoob", 14 | "email" : "contact@gomoob.com", 15 | "homepage" : "http://www.gomoob.com" 16 | }, { 17 | "name" : "Baptiste Gaillard", 18 | "email" : "baptiste.gaillard@gomoob.com" 19 | }, { 20 | "name" : "Simon Baudry", 21 | "email" : "simon.baudry@gomoob.com" 22 | } 23 | ], 24 | "autoload" : { 25 | "psr-4" : { 26 | "Gomoob\\" : "src/main/php/Gomoob" 27 | } 28 | }, 29 | "autoload-dev" : { 30 | "psr-4" : { 31 | "Gomoob\\" : "src/test/php/Gomoob" 32 | } 33 | }, 34 | "require" : { 35 | "php" : "^5.6 || ^7.0" 36 | }, 37 | "require-dev" : { 38 | "codeclimate/php-test-reporter" : "^0.3.2", 39 | "pdepend/pdepend" : "^2.2.4", 40 | "phpdocumentor/phpdocumentor" : "^2.9.0", 41 | "phploc/phploc" : "^3.0.1", 42 | "phpmd/phpmd" : "^2.4.3", 43 | "phpunit/phpunit" : "^5.5.4", 44 | "satooshi/php-coveralls" : "^1.0.1", 45 | "sebastian/phpcpd" : "^2.0.4", 46 | "squizlabs/php_codesniffer" : "^3.0.0RC1", 47 | "symfony/yaml" : "^3.1.4" 48 | } 49 | } -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 24 | 25 | 27 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | src/main/php 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Client/CURLClient.php: -------------------------------------------------------------------------------- 1 | apiUrl = $apiUrl; 57 | $this->curlRequest = new CurlRequest(); 58 | } 59 | 60 | /** 61 | * {@inheritDoc} 62 | */ 63 | public function getAdditionalCurlOpts() 64 | { 65 | return $this->additionalCurlOpts; 66 | } 67 | 68 | /** 69 | * {@inheritDoc} 70 | */ 71 | public function getApiUrl() 72 | { 73 | return $this->apiUrl; 74 | } 75 | 76 | /** 77 | * Gets the CURL Request object currently in use. 78 | * 79 | * @return \Gomoob\Pushwoosh\Curl\ICurlRequest The CURL request object currently in use. 80 | */ 81 | public function getCurlRequest() 82 | { 83 | return $this->curlRequest; 84 | } 85 | 86 | /** 87 | * {@inheritDoc} 88 | */ 89 | public function pushwooshCall($method, array $data) 90 | { 91 | // Creates the absolute Web Service URL to call, here we first remove trailing '/' characters to be sure the URL 92 | // is well formed 93 | $url = rtrim($this->apiUrl, '/') . '/' . $method; 94 | 95 | // Creates the JSON request to POST 96 | $request = json_encode(['request' => $data]); 97 | 98 | // Initialize the CURL request 99 | $this->curlRequest->init($url); 100 | 101 | // Apply CURL options 102 | foreach ($this->createMergedCurlOpts($request) as $option => $value) { 103 | $this->curlRequest->setOpt($option, $value); 104 | } 105 | 106 | // Executes the CURL request 107 | $response = $this->curlRequest->exec(); 108 | 109 | // Retrieves potential errors 110 | $error = $this->curlRequest->error(); 111 | 112 | // If an error has been encountered 113 | if ($error) { 114 | // Get additional informations about the failed CURL transfert 115 | $info = $this->curlRequest->getInfo(); 116 | 117 | // Close the CURL handle 118 | $this->curlRequest->close(); 119 | 120 | throw new PushwooshException( 121 | 'CURL error encountered while requesting the Pushwoosh web services using CURL !', 122 | -1, 123 | null, 124 | [ 125 | 'curl_error' => $error, 126 | 'curl_info' => $info, 127 | 'response' => $response 128 | ] 129 | ); 130 | } 131 | 132 | $jsonResult = json_decode($response, true); 133 | 134 | // This should never append but we want to be 100% sure our response is well formatted for the PHP Pushwoosh 135 | // APIs. If its not the case we throw an exception with as much details as possible. 136 | if (!is_array($jsonResult)) { 137 | // Get additional informations about the failed CURL transfert 138 | $info = $this->curlRequest->getInfo(); 139 | 140 | // Close the CURL handle 141 | $this->curlRequest->close(); 142 | 143 | throw new PushwooshException( 144 | 'Bad response encountered while requesting the Pushwoosh web services using CURL !', 145 | -1, 146 | null, 147 | [ 148 | 'curl_info' => $info, 149 | 'response' => $response 150 | ] 151 | ); 152 | } 153 | 154 | // Close the CURL handle 155 | $this->curlRequest->close(); 156 | 157 | return $jsonResult; 158 | } 159 | 160 | /** 161 | * {@inheritDoc} 162 | */ 163 | public function setAdditionalCurlOpt($option, $value) 164 | { 165 | $notOverwritableOptions = [ 166 | CURLOPT_ENCODING, 167 | CURLOPT_HTTPHEADER, 168 | CURLOPT_POST, 169 | CURLOPT_POSTFIELDS, 170 | CURLOPT_RETURNTRANSFER 171 | ]; 172 | $notOverwritableOptionNames = [ 173 | CURLOPT_ENCODING => 'CURLOPT_ENCODING', 174 | CURLOPT_HTTPHEADER => 'CURLOPT_HTTPHEADER', 175 | CURLOPT_POST => 'CURLOPT_POST', 176 | CURLOPT_POSTFIELDS => 'CURLOPT_POSTFIELDS', 177 | CURLOPT_RETURNTRANSFER => 'CURLOPT_RETURNTRANSFER' 178 | ]; 179 | 180 | // The provided option must not be a not overwritable option 181 | if (in_array($option, $notOverwritableOptions)) { 182 | throw new PushwooshException( 183 | 'The option \'' . $notOverwritableOptionNames[$option] . '\' cannot be set as an additional CURL ' . 184 | 'option because its internally used by the CURL client and modifying it would break valid Pushwoosh ' . 185 | 'Web Service calls !', 186 | -1 187 | ); 188 | } 189 | 190 | $this->additionalCurlOpts[$option] = $value; 191 | } 192 | 193 | /** 194 | * {@inheritDoc} 195 | */ 196 | public function setAdditionalCurlOpts(array $additionalCurlOpts) 197 | { 198 | // Set additional CURL option one by one to ensure each option is not a not overwritable CURL option 199 | foreach ($additionalCurlOpts as $option => $value) { 200 | $this->setAdditionalCurlOpt($option, $value); 201 | } 202 | } 203 | 204 | /** 205 | * {@inheritDoc} 206 | */ 207 | public function setApiUrl($apiUrl) 208 | { 209 | $this->apiUrl = $apiUrl; 210 | } 211 | 212 | /** 213 | * Sets the CURL request object to be used. 214 | * 215 | * @param \Gomoob\Pushwoosh\Curl\ICurlRequest $curlRequest The CURL request object to use. 216 | */ 217 | public function setCurlRequest(ICurlRequest $curlRequest) 218 | { 219 | $this->curlRequest = $curlRequest; 220 | } 221 | 222 | /** 223 | * Utility function used to create a set of CURL options from additional CURL options defined on the CURL client and 224 | * not overwritable CURL options. 225 | * 226 | * @param array $request the request to POST to the Pushwoosh Web Services. 227 | * 228 | * @return array the resulting CURL options to use. 229 | */ 230 | private function createMergedCurlOpts($request) 231 | { 232 | // Merge default CURL options with overwritable CURL options 233 | $mergedCurlOpts = [ 234 | // see: http://curl.haxx.se/docs/sslcerts.html 235 | CURLOPT_CAINFO => __DIR__ . '/../../../../resources/cacert.pem', 236 | CURLOPT_SSL_VERIFYHOST => 2, 237 | CURLOPT_SSL_VERIFYPEER => true 238 | ]; 239 | 240 | foreach($this->additionalCurlOpts as $option => $value) { 241 | $mergedCurlOpts[$option] = $value; 242 | } 243 | 244 | // Set not overwritable CURL options 245 | $mergedCurlOpts[CURLOPT_RETURNTRANSFER] = true; 246 | $mergedCurlOpts[CURLOPT_ENCODING] = 'gzip, deflate'; 247 | $mergedCurlOpts[CURLOPT_POST] = true; 248 | $mergedCurlOpts[CURLOPT_POSTFIELDS] = $request; 249 | $mergedCurlOpts[CURLOPT_HTTPHEADER] = [ 250 | 'Content-Type: application/json', 251 | 'Content-Length: ' . strlen($request) 252 | ]; 253 | 254 | return $mergedCurlOpts; 255 | } 256 | } 257 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Client/Pushwoosh.php: -------------------------------------------------------------------------------- 1 | WARNING: If the application is defined then the applications groups must not be defined.

58 | * 59 | * @var string 60 | */ 61 | private $applicationsGroup; 62 | 63 | /** 64 | * The API access token from the Pushwoosh control panel (create this token at https://cp.pushwoosh.com/api_access). 65 | * 66 | * @var string 67 | */ 68 | private $auth; 69 | 70 | /** 71 | * A CURL client used to request the Pushwoosh Web Services. 72 | * 73 | * @var \Gomoob\Pushwoosh\ICURLClient 74 | */ 75 | private $cURLClient; 76 | 77 | /** 78 | * Create a new instance of the Pushwoosh client. 79 | * 80 | * @param string $apiUrl (Optional) the root URL to the API server to use, if this parameter is not provided then 81 | * the default API URL will be equal to `https://cp.pushwoosh.com/json/1.3`. If you have an enterprise 82 | * Pushwoosh plan then you have a dedicated API server URL like `https://your-company.pushwoosh.com`, you can 83 | * provide this custom API server URL here. 84 | */ 85 | public function __construct($apiUrl = ICURLClient::DEFAULT_API_URL) 86 | { 87 | $this->cURLClient = new CURLClient($apiUrl); 88 | } 89 | 90 | /** 91 | * Utility function used to create a new instance of the Pushwoosh client. 92 | * 93 | * @param string $apiUrl (Optional) the root URL to the API server to use, if this parameter is not provided then 94 | * the default API URL will be equal to `https://cp.pushwoosh.com/json/1.3`. If you have an enterprise 95 | * Pushwoosh plan then you have a dedicated API server URL like `https://your-company.pushwoosh.com`, you can 96 | * provide this custom API server URL here. 97 | * 98 | * @return \Gomoob\Pushwoosh\Client\Pushwoosh the new created instance. 99 | */ 100 | public static function create($apiUrl = ICURLClient::DEFAULT_API_URL) 101 | { 102 | return new Pushwoosh($apiUrl); 103 | } 104 | 105 | /** 106 | * {@inheritDoc} 107 | */ 108 | public function createMessage(CreateMessageRequest $createMessageRequest) 109 | { 110 | // If both the 'application' and 'applicationsGroup' attribute are not set in the request we try to get a 111 | // default one from the Pushwoosh client 112 | if ($createMessageRequest->getApplication() === null && $createMessageRequest->getApplicationsGroup() === null 113 | ) { 114 | // Setting both 'application' and 'applicationsGroup' is forbidden 115 | if (!isset($this->application) && !isset($this->applicationsGroup)) { 116 | throw new PushwooshException( 117 | 'None of the \'application\' or \'applicationsGroup\' properties are set !' 118 | ); 119 | 120 | // Setting both the 'application' and 'applicationsGroup' parameters is an error here 121 | } elseif (isset($this->application) && isset($this->applicationsGroup)) { 122 | throw new PushwooshException('Both \'application\' and \'applicationsGroup\' properties are set !'); 123 | 124 | // Sets the 'application' attribute 125 | } elseif (isset($this->application)) { 126 | $createMessageRequest->setApplication($this->application); 127 | 128 | // Sets the 'applicationsGroup' attribute 129 | } elseif (isset($this->applicationsGroup)) { 130 | $createMessageRequest->setApplicationsGroup($this->applicationsGroup); 131 | } 132 | } 133 | 134 | // If the 'auth' parameter is not set in the request we try to get it from the Pushwoosh client 135 | $this->setAuthIfNotSet($createMessageRequest); 136 | 137 | $response = $this->cURLClient->pushwooshCall('createMessage', $createMessageRequest->jsonSerialize()); 138 | 139 | return CreateMessageResponse::create($response); 140 | } 141 | 142 | /** 143 | * {@inheritDoc} 144 | */ 145 | public function createTargetedMessage(CreateTargetedMessageRequest $createTargetedMessageRequest) 146 | { 147 | // If the 'auth' parameter is not set in the request we try to get it from the Pushwoosh client 148 | $this->setAuthIfNotSet($createTargetedMessageRequest); 149 | 150 | $response = $this->cURLClient->pushwooshCall( 151 | 'createTargetedMessage', 152 | $createTargetedMessageRequest->jsonSerialize() 153 | ); 154 | 155 | return CreateTargetedMessageResponse::create($response); 156 | } 157 | 158 | /** 159 | * {@inheritDoc} 160 | */ 161 | public function deleteMessage(DeleteMessageRequest $deleteMessageRequest) 162 | { 163 | // If the 'auth' parameter is not set in the request we try to get it from the Pushwoosh client 164 | $this->setAuthIfNotSet($deleteMessageRequest); 165 | 166 | $response = $this->cURLClient->pushwooshCall('deleteMessage', $deleteMessageRequest->jsonSerialize()); 167 | 168 | return DeleteMessageResponse::create($response); 169 | } 170 | 171 | /** 172 | * {@inheritDoc} 173 | */ 174 | public function getApplication() 175 | { 176 | return $this->application; 177 | } 178 | 179 | /** 180 | * {@inheritDoc} 181 | */ 182 | public function getApplicationsGroup() 183 | { 184 | return $this->applicationsGroup; 185 | } 186 | 187 | /** 188 | * {@inheritDoc} 189 | */ 190 | public function getAuth() 191 | { 192 | return $this->auth; 193 | } 194 | 195 | /** 196 | * Gets the CURL client used to request the Pushwoosh Web Services. 197 | * 198 | * @return \Gomoob\Pushwoosh\ICURLClient the CURL client used to request the Pushwoosh Web Services. 199 | */ 200 | public function getCURLClient() 201 | { 202 | return $this->cURLClient; 203 | } 204 | 205 | /** 206 | * {@inheritDoc} 207 | */ 208 | public function getNearestZone(GetNearestZoneRequest $getNearestZoneRequest) 209 | { 210 | // If the 'application' attribute is not set in the request we try to get a default one from the Pushwoosh 211 | // client 212 | $this->setApplicationIfNotSet($getNearestZoneRequest); 213 | 214 | $response = $this->cURLClient->pushwooshCall('getNearestZone', $getNearestZoneRequest->jsonSerialize()); 215 | 216 | return GetNearestZoneResponse::create($response); 217 | } 218 | 219 | /** 220 | * {@inheritDoc} 221 | */ 222 | public function getTags(GetTagsRequest $getTagsRequest) 223 | { 224 | // If the 'application' attribute is not set in the request we try to get a default one from the Pushwoosh 225 | // client 226 | $this->setApplicationIfNotSet($getTagsRequest); 227 | 228 | // If the 'auth' parameter is not set in the request we try to get it from the Pushwoosh client 229 | $this->setAuthIfNotSet($getTagsRequest); 230 | 231 | $response = $this->cURLClient->pushwooshCall('getTags', $getTagsRequest->jsonSerialize()); 232 | 233 | return GetTagsResponse::create($response); 234 | } 235 | 236 | /** 237 | * {@inheritDoc} 238 | */ 239 | public function pushStat(PushStatRequest $pushStatRequest) 240 | { 241 | // If the 'application' attribute is not set in the request we try to get a default one from the Pushwoosh 242 | // client 243 | $this->setApplicationIfNotSet($pushStatRequest); 244 | 245 | $response = $this->cURLClient->pushwooshCall('pushStat', $pushStatRequest->jsonSerialize()); 246 | 247 | return PushStatResponse::create($response); 248 | } 249 | 250 | /** 251 | * {@inheritDoc} 252 | */ 253 | public function registerDevice(RegisterDeviceRequest $registerDeviceRequest) 254 | { 255 | // If the 'application' attribute is not set in the request we try to get a default one from the Pushwoosh 256 | // client 257 | $this->setApplicationIfNotSet($registerDeviceRequest); 258 | 259 | $response = $this->cURLClient->pushwooshCall('registerDevice', $registerDeviceRequest->jsonSerialize()); 260 | 261 | return RegisterDeviceResponse::create($response); 262 | } 263 | 264 | /** 265 | * {@inheritDoc} 266 | */ 267 | public function setApplication($application) 268 | { 269 | $this->application = $application; 270 | 271 | return $this; 272 | } 273 | 274 | /** 275 | * {@inheritDoc} 276 | */ 277 | public function setApplicationsGroup($applicationsGroup) 278 | { 279 | $this->applicationsGroup = $applicationsGroup; 280 | 281 | return $this; 282 | } 283 | 284 | /** 285 | * {@inheritDoc} 286 | */ 287 | public function setAuth($auth) 288 | { 289 | $this->auth = $auth; 290 | 291 | return $this; 292 | } 293 | 294 | /** 295 | * {@inheritDoc} 296 | */ 297 | public function setBadge(SetBadgeRequest $setBadgeRequest) 298 | { 299 | // If the 'application' attribute is not set in the request we try to get a default one from the Pushwoosh 300 | // client 301 | $this->setApplicationIfNotSet($setBadgeRequest); 302 | 303 | $response = $this->cURLClient->pushwooshCall('setBadge', $setBadgeRequest->jsonSerialize()); 304 | 305 | return SetBadgeResponse::create($response); 306 | } 307 | 308 | /** 309 | * Sets the CURL client used to request the Pushwoosh Web Services. 310 | * 311 | * @param \Gomoob\Pushwoosh\ICURLClient $cURLClient the CURL client used to request the Pushwoosh Web Services. 312 | * 313 | * @return \Gomoob\Pushwoosh\IPushwoosh this instance. 314 | */ 315 | public function setCURLClient(ICURLClient $cURLClient) 316 | { 317 | $this->cURLClient = $cURLClient; 318 | 319 | return $this; 320 | } 321 | 322 | /** 323 | * {@inheritDoc} 324 | */ 325 | public function setTags(SetTagsRequest $setTagsRequest) 326 | { 327 | // If the 'application' attribute is not set in the request we try to get a default one from the Pushwoosh 328 | // client 329 | $this->setApplicationIfNotSet($setTagsRequest); 330 | 331 | $response = $this->cURLClient->pushwooshCall('setTags', $setTagsRequest->jsonSerialize()); 332 | 333 | return SetTagsResponse::create($response); 334 | } 335 | 336 | /** 337 | * {@inheritDoc} 338 | */ 339 | public function unregisterDevice(UnregisterDeviceRequest $unregisterDeviceRequest) 340 | { 341 | // If the 'application' attribute is not set in the request we try to get a default one from the Pushwoosh 342 | // client 343 | $this->setApplicationIfNotSet($unregisterDeviceRequest); 344 | 345 | $response = $this->cURLClient->pushwooshCall('unregisterDevice', $unregisterDeviceRequest->jsonSerialize()); 346 | 347 | return UnregisterDeviceResponse::create($response); 348 | } 349 | 350 | /** 351 | * Function used to check if the `application` parameter is set on a Pushwoosh request and if no try to set it from 352 | * the Pushwoosh client `auth` parameter. 353 | * 354 | * @param \Gomoob\Pushwoosh\Model\IRequest $request The Pushwoosh request to update. 355 | */ 356 | private function setApplicationIfNotSet(IRequest $request) 357 | { 358 | // If the 'application' attribute is not set in the request we try to get a default one from the Pushwoosh 359 | // client 360 | if ($request->getApplication() === null) { 361 | // The 'application' must be set 362 | if (!isset($this->application)) { 363 | throw new PushwooshException('The \'application\' property is not set !'); 364 | } 365 | 366 | $request->setApplication($this->application); 367 | } 368 | } 369 | 370 | /** 371 | * Function used to check if the `auth` parameter is set on a Pushwoosh request and if no try to set it from the 372 | * Pushwoosh client `auth` parameter. 373 | * 374 | * @param \Gomoob\Pushwoosh\Model\IRequest $request The Pushwoosh request to update. 375 | */ 376 | private function setAuthIfNotSet(IRequest $request) 377 | { 378 | // If the 'auth' parameter is not set in the request we try to get it from the Pushwoosh client 379 | if ($request->getAuth() === null) { 380 | // The 'auth' parameter is expected here 381 | if (!isset($this->auth)) { 382 | throw new PushwooshException('The \'auth\' parameter is not set !'); 383 | 384 | // Use the 'auth' parameter defined in the Pushwoosh client 385 | } else { 386 | $request->setAuth($this->auth); 387 | } 388 | } 389 | } 390 | } 391 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Client/PushwooshMock.php: -------------------------------------------------------------------------------- 1 | WARNING: If the application is defined then the applications groups must not be defined.

54 | * 55 | * @var string 56 | */ 57 | private $applicationsGroup; 58 | 59 | /** 60 | * The API access token from the Pushwoosh control panel (create this token at https://cp.pushwoosh.com/api_access). 61 | * 62 | * @var string 63 | */ 64 | private $auth; 65 | 66 | /** 67 | * An array which contains all pushwoosh requests sent by this pushwoosh client. 68 | * 69 | * @var array 70 | */ 71 | private $pushwhooshRequests = []; 72 | 73 | /** 74 | * {@inheritDoc} 75 | */ 76 | public function createMessage(CreateMessageRequest $createMessageRequest) 77 | { 78 | $this->pushwhooshRequests[] = $createMessageRequest; 79 | 80 | return CreateMessageResponse::create( 81 | json_decode('{ 82 | "status_code":200, 83 | "status_message":"OK", 84 | "response": { 85 | "Messages":[] 86 | } 87 | }', true) 88 | ); 89 | } 90 | 91 | /** 92 | * {@inheritDoc} 93 | */ 94 | public function createTargetedMessage(CreateTargetedMessageRequest $createTargetedMessageRequest) 95 | { 96 | return CreateTargetedMessageResponse::create( 97 | json_decode('{ 98 | "status_code":200, 99 | "status_message":"OK", 100 | "response": {} 101 | }', true) 102 | ); 103 | } 104 | 105 | /** 106 | * {@inheritDoc} 107 | */ 108 | public function deleteMessage(DeleteMessageRequest $deleteMessageRequest) 109 | { 110 | $this->pushwhooshRequests[] = $deleteMessageRequest; 111 | 112 | return DeleteMessageResponse::create( 113 | json_decode('{ 114 | "status_code":200, 115 | "status_message":"OK" 116 | }', true) 117 | ); 118 | } 119 | 120 | /** 121 | * {@inheritDoc} 122 | */ 123 | public function getApplication() 124 | { 125 | return $this->application; 126 | } 127 | 128 | /** 129 | * {@inheritDoc} 130 | */ 131 | public function getApplicationsGroup() 132 | { 133 | return $this->applicationsGroup; 134 | } 135 | 136 | /** 137 | * {@inheritDoc} 138 | */ 139 | public function getAuth() 140 | { 141 | return $this->auth; 142 | } 143 | 144 | /** 145 | * {@inheritDoc} 146 | */ 147 | public function getNearestZone(GetNearestZoneRequest $getNearestZoneRequest) 148 | { 149 | $this->pushwhooshRequests[] = $getNearestZoneRequest; 150 | 151 | return GetNearestZoneResponse::create( 152 | json_decode('{ 153 | "status_code":200, 154 | "status_message":"OK", 155 | "response": { 156 | "name":"zone name", 157 | "lat":42, 158 | "lng":42, 159 | "range":100, 160 | "distance":4715784 161 | } 162 | }', true) 163 | ); 164 | } 165 | 166 | /** 167 | * Gets the list of pushwoosh requests which have been sent with this Pushwoosh client. 168 | * 169 | * @return array An array of pushwoosh requests which have been sent with this Pushwoosh client. 170 | */ 171 | public function getPushwooshRequests() 172 | { 173 | return $this->pushwhooshRequests; 174 | } 175 | 176 | /** 177 | * Clears the create message requests which have been sent with this Pushwoosh client. 178 | */ 179 | public function clear() 180 | { 181 | $this->pushwhooshRequests = []; 182 | } 183 | 184 | /** 185 | * {@inheritDoc} 186 | */ 187 | public function getTags(GetTagsRequest $getTagsRequest) 188 | { 189 | $this->pushwhooshRequests[] = $getTagsRequest; 190 | 191 | return GetTagsResponse::create( 192 | json_decode('{ 193 | "status_code": 200, 194 | "status_message": "OK", 195 | "response": { 196 | "result": { 197 | "Language": "fr" 198 | } 199 | } 200 | }', true) 201 | ); 202 | } 203 | 204 | /** 205 | * {@inheritDoc} 206 | */ 207 | public function pushStat(PushStatRequest $pushStatRequest) 208 | { 209 | $this->pushwhooshRequests[] = $pushStatRequest; 210 | 211 | return PushStatResponse::create( 212 | json_decode('{ 213 | "status_code":200, 214 | "status_message":"OK" 215 | }', true) 216 | ); 217 | } 218 | 219 | /** 220 | * {@inheritDoc} 221 | */ 222 | public function registerDevice(RegisterDeviceRequest $registerDeviceRequest) 223 | { 224 | $this->pushwhooshRequests[] = $registerDeviceRequest; 225 | 226 | return RegisterDeviceResponse::create( 227 | json_decode('{ 228 | "status_code":200, 229 | "status_message":"OK", 230 | "response": null 231 | }', true) 232 | ); 233 | } 234 | 235 | /** 236 | * {@inheritDoc} 237 | */ 238 | public function setApplication($application) 239 | { 240 | $this->application = $application; 241 | 242 | return $this; 243 | } 244 | 245 | /** 246 | * {@inheritDoc} 247 | */ 248 | public function setApplicationsGroup($applicationsGroup) 249 | { 250 | $this->applicationsGroup = $applicationsGroup; 251 | 252 | return $this; 253 | } 254 | 255 | /** 256 | * {@inheritDoc} 257 | */ 258 | public function setAuth($auth) 259 | { 260 | $this->auth = $auth; 261 | 262 | return $this; 263 | } 264 | 265 | /** 266 | * {@inheritDoc} 267 | */ 268 | public function setBadge(SetBadgeRequest $setBadgeRequest) 269 | { 270 | $this->pushwhooshRequests[] = $setBadgeRequest; 271 | 272 | return SetBadgeResponse::create( 273 | json_decode('{ 274 | "status_code":200, 275 | "status_message":"OK" 276 | }', true) 277 | ); 278 | } 279 | 280 | /** 281 | * {@inheritDoc} 282 | */ 283 | public function setTags(SetTagsRequest $setTagsRequest) 284 | { 285 | $this->pushwhooshRequests[] = $setTagsRequest; 286 | 287 | return SetTagsResponse::create( 288 | json_decode('{ 289 | "status_code":200, 290 | "status_message":"OK", 291 | "response": null 292 | }', true) 293 | ); 294 | } 295 | 296 | /** 297 | * {@inheritDoc} 298 | */ 299 | public function unregisterDevice(UnregisterDeviceRequest $unregisterDeviceRequest) 300 | { 301 | $this->pushwhooshRequests[] = $unregisterDeviceRequest; 302 | 303 | return UnregisterDeviceResponse::create( 304 | json_decode('{ 305 | "status_code":200, 306 | "status_message":"OK" 307 | }', true) 308 | ); 309 | } 310 | } 311 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Curl/CurlRequest.php: -------------------------------------------------------------------------------- 1 | init($url); 47 | } 48 | 49 | /** 50 | * {@inheritdoc} 51 | */ 52 | public function close() 53 | { 54 | curl_close($this->getCh()); 55 | 56 | $this->ch = null; 57 | } 58 | 59 | /** 60 | * {@inheritdoc} 61 | */ 62 | public function error() 63 | { 64 | return curl_error($this->getCh()); 65 | } 66 | 67 | /** 68 | * {@inheritdoc} 69 | */ 70 | public function exec() 71 | { 72 | return curl_exec($this->getCh()); 73 | } 74 | 75 | /** 76 | * {@inheritdoc} 77 | */ 78 | public function init($url = null) 79 | { 80 | // If a previous CURL handle exists close it 81 | if ($this->ch) { 82 | $this->close(); 83 | } 84 | 85 | // If a URL is provided 86 | if (isset($url)) { 87 | // The provided URL must be valid 88 | if (!$this->isUrlValid($url)) { 89 | throw new \Exception('Invalid URL provided \'' . $url . '\' !', -1, null); 90 | } 91 | 92 | $this->ch = curl_init($url); 93 | } 94 | 95 | return $this->ch; 96 | } 97 | 98 | /** 99 | * {@inheritdoc} 100 | */ 101 | public function getInfo($opt = CURLINFO_EFFECTIVE_URL) 102 | { 103 | return curl_getinfo($this->getCh(), $opt); 104 | } 105 | 106 | /** 107 | * {@inheritdoc} 108 | */ 109 | public function setOpt($option, $value) 110 | { 111 | return curl_setopt($this->getCh(), $option, $value); 112 | } 113 | 114 | /** 115 | * Gets the CURL handle is use. 116 | * 117 | * @throws \Exception If the init method has not been called. 118 | */ 119 | private function getCh() 120 | { 121 | if (!$this->ch) { 122 | throw new \Exception('No CURL handle found, did you call init ?'); 123 | } 124 | 125 | return $this->ch; 126 | } 127 | 128 | /** 129 | * Indicates if a URL is valid. 130 | * 131 | * @param string $url the URL to validate. 132 | * 133 | * @return bool `true` if `$url` is valid, `false` otherwise. 134 | */ 135 | private function isUrlValid($url) 136 | { 137 | return (bool) preg_match(static::URL_REGEX, $url); 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Curl/ICurlRequest.php: -------------------------------------------------------------------------------- 1 | data = $data; 39 | } 40 | 41 | 42 | /** 43 | * Gets the additional data attached to the exception, those data must be represented as an array which is 44 | * serializable in a JSON format. 45 | * 46 | * @return array The additional data / details attached to the exception. 47 | */ 48 | public function getData() 49 | { 50 | return $this->data; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/ICURLClient.php: -------------------------------------------------------------------------------- 1 | WARNING: If the application group is defined then the application must not be defined.

66 | * 67 | * @return string the Pushwoosh application ID to be used by default by all the requests performed by the Pushwoosh 68 | * client. 69 | */ 70 | public function getApplication(); 71 | 72 | /** 73 | * Gets the Pushwoosh applications group code to be used to defautl by all the requests performed by the Pushwoosh 74 | * client. This identifier can be overwritten by requests if needed. 75 | * 76 | *

WARNING: If the application is defined then the applications groups must not be defined.

77 | * 78 | * @return string the Pushwoosh applications group code to be used to defautl by all the requests performed by the 79 | * Pushwoosh client. 80 | */ 81 | public function getApplicationsGroup(); 82 | 83 | /** 84 | * Gets the API access token from the Pushwoosh control panel (create this token at 85 | * https://cp.pushwoosh.com/api_access). 86 | * 87 | * @return string the API access token from the Pushwoosh control panel (create this token at 88 | * https://cp.pushwoosh.com/api_access). 89 | */ 90 | public function getAuth(); 91 | 92 | /** 93 | * Function used to record a device location for Geographical Push Notification using a '/getNearestZone' request. 94 | * 95 | * @param \Gomoob\Pushwoosh\Model\Request\GetNearestZoneRequest $getNearestZoneRequest the '/getNearestZone' request 96 | * used to record a device 97 | * location for Georgraphical 98 | * Push Notification. 99 | * 100 | * @return \Gomoob\Pushwoosh\Model\Response\GetNearestZoneResponse the resulting '/getNearestZone' response. 101 | */ 102 | public function getNearestZone(GetNearestZoneRequest $getNearestZoneRequest); 103 | 104 | /** 105 | * Function used to get the tags associated to a device using a '/getTags' request. 106 | * 107 | * @param \Gomoob\Pushwoosh\Model\Request\GetTagsRequest $getTagsRequest the '/getTags' request used to get the tags 108 | * associated to a specified device. 109 | * 110 | * @return \Gomoob\Pushwoosh\Model\Response\GetTagsResponse the resulting '/getTags' response. 111 | */ 112 | public function getTags(GetTagsRequest $getTagsRequest); 113 | 114 | /** 115 | * Function used to register a device for Push Open events using the '/pushStat' request. 116 | * 117 | * @param \Gomoob\Pushwoosh\Model\Request\PushStatRequest $pushStatRequest the '/pushStat' request used to register 118 | * a device for Push Open events. 119 | * 120 | * @return \Gomoob\Pushwoosh\Model\Response\PushStatResponse the resulting '/pushStat' response. 121 | */ 122 | public function pushStat(PushStatRequest $pushStatRequest); 123 | 124 | /** 125 | * Function used to register a device for an application using a '/registerDevice' request. 126 | * 127 | * @param \Gomoob\Pushwoosh\Model\Request\RegisterDeviceRequest $registerDeviceRequest the register device request 128 | * used to register a device for the application. 129 | * 130 | * @return \Gomoob\Pushwoosh\Model\Response\RegisterDeviceResponse the resulting register device response. 131 | */ 132 | public function registerDevice(RegisterDeviceRequest $registerDeviceRequest); 133 | 134 | /** 135 | * Sets the Pushwoosh application ID to be used by default by all the requests performed by the Pushwoosh client. 136 | * This identifier can be overwritten by request if needed. 137 | * 138 | *

WARNING: If the application group is defined then the application must not be defined.

139 | * 140 | * @param string $application the Pushwoosh application ID to be used by default by all the requests performed by 141 | * the Pushwoosh client. This identifier can be overwritten by request if needed. 142 | * 143 | * @return \Gomoob\Pushwoosh\IPushwoosh this instance. 144 | */ 145 | public function setApplication($application); 146 | 147 | /** 148 | * Sets the Pushwoosh applications group code to be used to defautl by all the requests performed by the Pushwoosh 149 | * client. This identifier can be overwritten by requests if needed. 150 | * 151 | *

WARNING: If the application is defined then the applications groups must not be defined.

152 | * 153 | * @param string $applicationsGroup the Pushwoosh applications group code to be used to defautl by all the requests 154 | * performed by the Pushwoosh client. 155 | * 156 | * @return \Gomoob\Pushwoosh\IPushwoosh this instance. 157 | */ 158 | public function setApplicationsGroup($applicationsGroup); 159 | 160 | /** 161 | * Sets the API access token from the Pushwoosh control panel (create this token at 162 | * https://cp.pushwoosh.com/api_access). 163 | * 164 | * @param string $auth the API access token from the Pushwoosh control panel (create this token at 165 | * https://cp.pushwoosh.com/api_access). 166 | * 167 | * @return \Gomoob\Pushwoosh\IPushwoosh this instance. 168 | */ 169 | public function setAuth($auth); 170 | 171 | /** 172 | * Function used to set the current badge for a device to let auto-incrementing badges work properly using the 173 | * '/setBadge' request. 174 | * 175 | * @param \Gomoob\Pushwoosh\Model\Request\SetBadgeRequest $setBadgeRequest the '/setBadge' request used to set the 176 | * current badge for a device to let 177 | * auto-incrementing badges work properly. 178 | * 179 | * @return \Gomoob\Pushwoosh\Model\Response\SetBadgeResponse the resulting '/setBadge' response. 180 | */ 181 | public function setBadge(SetBadgeRequest $setBadgeRequest); 182 | 183 | /** 184 | * Function used to set tags for a device using a '/setTags' request. 185 | * 186 | * @param \Gomoob\Pushwoosh\Model\Request\SetTagsRequest $setTagsRequest the '/setTags' request used to set tags for 187 | * a device. 188 | * 189 | * @return \Gomoob\Pushwoosh\Model\Response\SetTagsResponse the resulting set tags response. 190 | */ 191 | public function setTags(SetTagsRequest $setTagsRequest); 192 | 193 | /** 194 | * Function used to remove a device from an application using a '/unregisterDevice' request. 195 | * 196 | * @param \Gomoob\Pushwoosh\Model\Request\UnregisterDeviceRequest $unregisterDeviceRequest the '/unregisterDevice' 197 | * request used to unregister a device from an application. 198 | */ 199 | public function unregisterDevice(UnregisterDeviceRequest $unregisterDeviceRequest); 200 | } 201 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/JsonUtils.php: -------------------------------------------------------------------------------- 1 | jsonSerialize()); 36 | } 37 | } 38 | 39 | return $array; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Condition/AbstractCondition.php: -------------------------------------------------------------------------------- 1 | operand; 45 | 46 | } 47 | 48 | /** 49 | * {@inheritDoc} 50 | */ 51 | public function getOperator() 52 | { 53 | return $this->operator; 54 | 55 | } 56 | 57 | /** 58 | * {@inheritDoc} 59 | */ 60 | public function getTagName() 61 | { 62 | return $this->tagName; 63 | 64 | } 65 | 66 | /** 67 | * {@inheritDoc} 68 | */ 69 | public function jsonSerialize() 70 | { 71 | return [ 72 | $this->tagName, 73 | $this->operator, 74 | $this->operand 75 | ]; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Condition/DateCondition.php: -------------------------------------------------------------------------------- 1 | tagName = $tagName; 24 | } 25 | 26 | /** 27 | * Apply a between operator (i.e `BETWEEN`) to min and max operand values. 28 | * 29 | * @param \DateTime $minValue the date and time min value of the range. 30 | * @param \DateTime $maxValue the date and time max value of the range. 31 | * 32 | * @return \Gomoob\Pushwoosh\Model\Condition\DateCondition this instance. 33 | */ 34 | public function between($minValue, $maxValue) 35 | { 36 | $this->operator = 'BETWEEN'; 37 | $this->operand = [$minValue, $maxValue]; 38 | 39 | return $this; 40 | } 41 | 42 | /** 43 | * Create a new `DateCondition` instance. 44 | * 45 | * @param string $tagName the name of the tag. 46 | * 47 | * @return \Gomoob\Pushwoosh\Model\Condition\DateCondition the created date condition. 48 | */ 49 | public static function create($tagName) 50 | { 51 | return new DateCondition($tagName); 52 | } 53 | 54 | /** 55 | * Apply an equals operator (i.e `EQ`) to a specified operand value. 56 | * 57 | * @param \DateTime $value the date and time value to compare with. 58 | * 59 | * @return \Gomoob\Pushwoosh\Model\Condition\DateCondition this instance. 60 | */ 61 | public function eq($value) 62 | { 63 | $this->operator = 'EQ'; 64 | $this->operand = $value; 65 | 66 | return $this; 67 | } 68 | 69 | /** 70 | * Apply a greater than or equals operator (i.e `GTE`) to a specified operand value. 71 | * 72 | * @param \DateTime $value the date and time value to compare with. 73 | * 74 | * @return \Gomoob\Pushwoosh\Model\Condition\DateCondition this instance. 75 | */ 76 | public function gte($value) 77 | { 78 | $this->operator = 'GTE'; 79 | $this->operand = $value; 80 | 81 | return $this; 82 | } 83 | 84 | /** 85 | * Apply an inclusion operator (i.e `IN`) to a specified array of values. 86 | * 87 | * @param \DateTime[] $values the array of date and time values to check for inclusion. 88 | * 89 | * @return \Gomoob\Pushwoosh\Model\Condition\DateCondition this instance. 90 | */ 91 | public function in(array $values = []) 92 | { 93 | $this->operator = 'IN'; 94 | $this->operand = $values; 95 | 96 | return $this; 97 | } 98 | 99 | /** 100 | * {@inheritDoc} 101 | */ 102 | public function jsonSerialize() 103 | { 104 | $operandWithString = null; 105 | 106 | // The operand is an array of date and time objects 107 | if (is_array($this->operand)) { 108 | $operandWithString = []; 109 | 110 | foreach ($this->operand as $dateAndTime) { 111 | $operandWithString[] = $dateAndTime->format('Y-m-d h:i'); 112 | } 113 | } // The operand is a date and time object 114 | else { 115 | $operandWithString = $this->operand->format('Y-m-d h:i'); 116 | } 117 | 118 | return [ 119 | $this->tagName, 120 | $this->operator, 121 | $operandWithString 122 | ]; 123 | } 124 | 125 | /** 126 | * Apply a less than or equals operator (i.e `LTE`) to a specified operand value. 127 | * 128 | * @param \DateTime $value the date and time value to compare with. 129 | * 130 | * @return \Gomoob\Pushwoosh\Model\Condition\DateCondition this instance. 131 | */ 132 | public function lte($value) 133 | { 134 | $this->operator = 'LTE'; 135 | $this->operand = $value; 136 | 137 | return $this; 138 | } 139 | 140 | /** 141 | * Apply a not equals operator (i.e `NOTEQ`) to a specified operand value. 142 | * 143 | * @param \DateTime $value the date and time value to compare with. 144 | * 145 | * @return \Gomoob\Pushwoosh\Model\Condition\DateCondition this instance. 146 | */ 147 | public function noteq($value) 148 | { 149 | $this->operator = 'NOTEQ'; 150 | $this->operand = $value; 151 | 152 | return $this; 153 | } 154 | 155 | /** 156 | * Apply an exclusion operator (i.e `NOTIN`) to a specified array of values. 157 | * 158 | * @param \DateTime[] $values the array of date and time values to check for exclusion. 159 | * 160 | * @return \Gomoob\Pushwoosh\Model\Condition\DateCondition this instance. 161 | */ 162 | public function notin(array $values = []) 163 | { 164 | $this->operator = 'NOTIN'; 165 | $this->operand = $values; 166 | 167 | return $this; 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Condition/ICondition.php: -------------------------------------------------------------------------------- 1 | tagName = $tagName; 26 | } 27 | 28 | /** 29 | * Apply a between operator (i.e `BETWEEN`) to min and max operand values. 30 | * 31 | * @param int $minValue the integer min value of the range. 32 | * @param int $maxValue the integer max value of the range. 33 | * 34 | * @return \Gomoob\Pushwoosh\Model\Condition\IntCondition this instance. 35 | */ 36 | public function between($minValue, $maxValue) 37 | { 38 | $this->operator = 'BETWEEN'; 39 | $this->operand = [$minValue, $maxValue]; 40 | 41 | return $this; 42 | } 43 | 44 | /** 45 | * Create a new `IntCondition` instance. 46 | * 47 | * @param string $tagName the name of the tag. 48 | * 49 | * @return \Gomoob\Pushwoosh\Model\Condition\IntCondition the created integer condition. 50 | */ 51 | public static function create($tagName) 52 | { 53 | return new IntCondition($tagName); 54 | } 55 | 56 | /** 57 | * Apply an equals operator (i.e `EQ`) to a specified operand value. 58 | * 59 | * @param int $value the integer value to compare with. 60 | * 61 | * @return \Gomoob\Pushwoosh\Model\Condition\IntCondition this instance. 62 | */ 63 | public function eq($value) 64 | { 65 | $this->operator = 'EQ'; 66 | $this->operand = $value; 67 | 68 | return $this; 69 | } 70 | 71 | /** 72 | * Apply a greater than or equals operator (i.e `GTE`) to a specified operand value. 73 | * 74 | * @param int $value the integer value to compare with. 75 | * 76 | * @return \Gomoob\Pushwoosh\Model\Condition\IntCondition this instance. 77 | */ 78 | public function gte($value) 79 | { 80 | $this->operator = 'GTE'; 81 | $this->operand = $value; 82 | 83 | return $this; 84 | } 85 | 86 | /** 87 | * Apply an inclusion operator (i.e `IN`) to a specified array of values. 88 | * 89 | * @param int[] $values the array of integer values to check for inclusion. 90 | * 91 | * @return \Gomoob\Pushwoosh\Model\Condition\IntCondition this instance. 92 | */ 93 | public function in(array $values = []) 94 | { 95 | $this->operator = 'IN'; 96 | $this->operand = $values; 97 | 98 | return $this; 99 | } 100 | 101 | /** 102 | * Apply a less than or equals operator (i.e `LTE`) to a specified operand value. 103 | * 104 | * @param int $value the integer value to compare with. 105 | * 106 | * @return \Gomoob\Pushwoosh\Model\Condition\IntCondition this instance. 107 | */ 108 | public function lte($value) 109 | { 110 | $this->operator = 'LTE'; 111 | $this->operand = $value; 112 | 113 | return $this; 114 | } 115 | 116 | /** 117 | * Apply a not equals operator (i.e `NOTEQ`) to a specified operand value. 118 | * 119 | * @param int $value the integer value to compare with. 120 | * 121 | * @return \Gomoob\Pushwoosh\Model\Condition\IntCondition this instance. 122 | */ 123 | public function noteq($value) 124 | { 125 | $this->operator = 'NOTEQ'; 126 | $this->operand = $value; 127 | 128 | return $this; 129 | } 130 | 131 | /** 132 | * Apply an exclusion operator (i.e `NOTIN`) to a specified array of values. 133 | * 134 | * @param int[] $values the array of integer values to check for exclusion. 135 | * 136 | * @return \Gomoob\Pushwoosh\Model\Condition\IntCondition this instance. 137 | */ 138 | public function notin(array $values = []) 139 | { 140 | $this->operator = 'NOTIN'; 141 | $this->operand = $values; 142 | 143 | return $this; 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Condition/ListCondition.php: -------------------------------------------------------------------------------- 1 | ListCondition instance. 20 | */ 21 | private function __construct($tagName) 22 | { 23 | $this->tagName = $tagName; 24 | } 25 | 26 | /** 27 | * Create a new ListCondition instance. 28 | * 29 | * @param string $tagName the name of the tag. 30 | * 31 | * @return \Gomoob\Pushwoosh\Model\Condition\ListCondition the created list condition. 32 | */ 33 | public static function create($tagName) 34 | { 35 | return new ListCondition($tagName); 36 | } 37 | 38 | /** 39 | * Apply an IN operator to a specified operand value. 40 | * 41 | * @param string[] $values the string values used to build in IN value set. 42 | * 43 | * @return \Gomoob\Pushwoosh\Model\Condition\ListCondition this instance. 44 | */ 45 | public function in(array $values) 46 | { 47 | $this->operator = 'IN'; 48 | $this->operand = $values; 49 | 50 | return $this; 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Condition/StringCondition.php: -------------------------------------------------------------------------------- 1 | tagName = $tagName; 24 | } 25 | 26 | /** 27 | * Create a new `StringCondition` instance. 28 | * 29 | * @param string $tagName the name of the tag. 30 | * 31 | * @return \Gomoob\Pushwoosh\Model\Condition\StringCondition the created string condition. 32 | */ 33 | public static function create($tagName) 34 | { 35 | return new StringCondition($tagName); 36 | } 37 | 38 | /** 39 | * Apply an equals operator to a specified operand value. 40 | * 41 | * @param string $value the string value to compare with. 42 | * 43 | * @return \Gomoob\Pushwoosh\Model\Condition\StringCondition this instance. 44 | */ 45 | public function eq($value) 46 | { 47 | $this->operator = 'EQ'; 48 | $this->operand = $value; 49 | 50 | return $this; 51 | } 52 | 53 | /** 54 | * Apply an inclusion operator (i.e `IN`) to a specified array of values. 55 | * 56 | * @param string[] $values the array of string values to check for inclusion. 57 | * 58 | * @return \Gomoob\Pushwoosh\Model\Condition\IntCondition this instance. 59 | */ 60 | public function in(array $values = []) 61 | { 62 | $this->operator = 'IN'; 63 | $this->operand = $values; 64 | 65 | return $this; 66 | } 67 | 68 | /** 69 | * Apply a not equals operator (i.e `NOTEQ`) to a specified operand value. 70 | * 71 | * @param string $value the string value to compare with. 72 | * 73 | * @return \Gomoob\Pushwoosh\Model\Condition\StringCondition this instance. 74 | */ 75 | public function noteq($value) 76 | { 77 | $this->operator = 'NOTEQ'; 78 | $this->operand = $value; 79 | 80 | return $this; 81 | } 82 | 83 | /** 84 | * Apply an exclusion operator (i.e `NOTIN`) to a specified array of values. 85 | * 86 | * @param string[] $values the array of string values to check for exclusion. 87 | * 88 | * @return \Gomoob\Pushwoosh\Model\Condition\IntCondition this instance. 89 | */ 90 | public function notin(array $values = []) 91 | { 92 | $this->operator = 'NOTIN'; 93 | $this->operand = $values; 94 | 95 | return $this; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/IRequest.php: -------------------------------------------------------------------------------- 1 | banner; 49 | 50 | } 51 | 52 | public function getCustomIcon() 53 | { 54 | return $this->customIcon; 55 | 56 | } 57 | 58 | public function getHeader() 59 | { 60 | return $this->header; 61 | 62 | } 63 | 64 | public function getIcon() 65 | { 66 | return $this->icon; 67 | 68 | } 69 | 70 | /** 71 | * Gets the priority of the push in the Amazon push drawer, valid values are -2, -1, 0, 1 and 2. 72 | * 73 | * @return int The priority of the push in the Amazon push drawer. 74 | */ 75 | public function getPriority() 76 | { 77 | return $this->priority; 78 | } 79 | 80 | public function getRootParams() 81 | { 82 | return $this->rootParams; 83 | 84 | } 85 | 86 | public function getSound() 87 | { 88 | return $this->sound; 89 | 90 | } 91 | 92 | public function getTtl() 93 | { 94 | return $this->ttl; 95 | 96 | } 97 | 98 | /** 99 | * {@inheritdoc} 100 | */ 101 | public function jsonSerialize() 102 | { 103 | $json = []; 104 | 105 | isset($this->banner) ? $json['adm_banner'] = $this->banner : false; 106 | isset($this->customIcon) ? $json['adm_custom_icon'] = $this->customIcon : false; 107 | isset($this->header) ? $json['adm_header'] = $this->header : false; 108 | isset($this->icon) ? $json['adm_icon'] = $this->icon : false; 109 | isset($this->priority) ? $json['adm_priority'] = $this->priority : false; 110 | isset($this->rootParams) ? $json['adm_root_params'] = $this->rootParams : false; 111 | isset($this->sound) ? $json['adm_sound'] = $this->sound : false; 112 | isset($this->ttl) ? $json['adm_ttl'] = $this->ttl : false; 113 | 114 | return $json; 115 | 116 | } 117 | 118 | public function setBanner($banner) 119 | { 120 | $this->banner = $banner; 121 | 122 | return $this; 123 | } 124 | 125 | public function setCustomIcon($customIcon) 126 | { 127 | $this->customIcon = $customIcon; 128 | 129 | return $this; 130 | } 131 | 132 | public function setHeader($header) 133 | { 134 | $this->header = $header; 135 | 136 | return $this; 137 | } 138 | 139 | public function setIcon($icon) 140 | { 141 | $this->icon = $icon; 142 | 143 | return $this; 144 | } 145 | 146 | /** 147 | * Sets the priority of the push in the Amazon push drawer, valid values are -2, -1, 0, 1 and 2. 148 | * 149 | * @param int $priority The priority of the push in the Amazon push drawer. 150 | * 151 | * @return \Gomoob\Pushwoosh\Model\Notification\ADM this instance. 152 | */ 153 | public function setPriority($priority) 154 | { 155 | $this->priority = $priority; 156 | 157 | return $this; 158 | } 159 | 160 | public function setRootParams($rootParams) 161 | { 162 | $this->rootParams = $rootParams; 163 | 164 | return $this; 165 | } 166 | 167 | public function setSound($sound) 168 | { 169 | $this->sound = $sound; 170 | 171 | return $this; 172 | } 173 | 174 | public function setTtl($ttl) 175 | { 176 | $this->ttl = $ttl; 177 | 178 | return $this; 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Notification/Android.php: -------------------------------------------------------------------------------- 1 | badges; 89 | } 90 | 91 | public function getBanner() 92 | { 93 | return $this->banner; 94 | 95 | } 96 | 97 | public function getCustomIcon() 98 | { 99 | return $this->customIcon; 100 | 101 | } 102 | 103 | /** 104 | * Gets the Google Cloud Messaging Time To Live, this indicates how long (in seconds) the message should be kept on 105 | * GCM storage if the device is offline. Optional (default time-to-live is 4 weeks, and must be set as a JSON 106 | * number). 107 | * 108 | * @return int the Google Cloud Messaging Time To Live. 109 | */ 110 | public function getGcmTtl() 111 | { 112 | return $this->gcmTtl; 113 | 114 | } 115 | 116 | public function getHeader() 117 | { 118 | return $this->header; 119 | 120 | } 121 | 122 | /** 123 | * Gets the icon background color on Lollipop, #RRGGBB, #AARRGGBB, "red", "black", "yellow", etc. 124 | * 125 | * @return string The icon background color on Lollipop. 126 | */ 127 | public function getIbc() 128 | { 129 | return $this->ibc; 130 | } 131 | 132 | public function getIcon() 133 | { 134 | return $this->icon; 135 | } 136 | 137 | /** 138 | * Gets the LED hex color, device will do its best approximation. 139 | * 140 | * @return string The LED hex color. 141 | */ 142 | public function getLed() 143 | { 144 | return $this->led; 145 | } 146 | 147 | /** 148 | * Gets priority of the push in the Android push drawer, valid values are -2, -1, 0, 1 and 2. 149 | * 150 | * @return int The priority of the push in the Android push drawer. 151 | */ 152 | public function getPriority() 153 | { 154 | return $this->priority; 155 | } 156 | 157 | public function getRootParams() 158 | { 159 | return $this->rootParams; 160 | } 161 | 162 | public function getSound() 163 | { 164 | return $this->sound; 165 | } 166 | 167 | /** 168 | * Gets the boolean used to force vibration for high-priority pushes. 169 | * 170 | * @return boolean The boolean used to force vibration for high-priority pushes. 171 | */ 172 | public function isVibration() 173 | { 174 | return $this->vibration; 175 | } 176 | 177 | /** 178 | * {@inheritdoc} 179 | */ 180 | public function jsonSerialize() 181 | { 182 | $json = []; 183 | 184 | isset($this->badges) ? $json['android_badges'] = $this->badges : false; 185 | isset($this->banner) ? $json['android_banner'] = $this->banner : false; 186 | isset($this->customIcon) ? $json['android_custom_icon'] = $this->customIcon : false; 187 | isset($this->gcmTtl) ? $json['android_gcm_ttl'] = $this->gcmTtl : false; 188 | isset($this->header) ? $json['android_header'] = $this->header : false; 189 | isset($this->ibc) ? $json['android_ibc'] = $this->ibc : false; 190 | isset($this->icon) ? $json['android_icon'] = $this->icon : false; 191 | isset($this->led) ? $json['android_led'] = $this->led : false; 192 | isset($this->priority) ? $json['android_priority'] = $this->priority : false; 193 | isset($this->rootParams) ? $json['android_root_params'] = $this->rootParams : false; 194 | isset($this->sound) ? $json['android_sound'] = $this->sound : false; 195 | isset($this->vibration) ? $json['android_vibration'] = ($this->vibration ? 1 : 0) : false; 196 | 197 | return $json; 198 | 199 | } 200 | 201 | /** 202 | * Sets the Android application icon badge number. 203 | * 204 | * @param int $badges The Android application icon badge number. 205 | * 206 | * @return \Gomoob\Pushwoosh\Model\Notification\Android this instance. 207 | */ 208 | public function setBadges($badges) 209 | { 210 | $this->badges = $badges; 211 | 212 | return $this; 213 | } 214 | 215 | public function setBanner($banner) 216 | { 217 | $this->banner = $banner; 218 | 219 | return $this; 220 | } 221 | 222 | public function setCustomIcon($customIcon) 223 | { 224 | $this->customIcon = $customIcon; 225 | 226 | return $this; 227 | } 228 | 229 | /** 230 | * Sets the Google Cloud Messaging Time To Live, this indicates how long (in seconds) the message should be kept on 231 | * GCM storage if the device is offline. Optional (default time-to-live is 4 weeks, and must be set as a JSON 232 | * number). 233 | * 234 | * @param int $gcmTtl the Google Cloud Messaging Time To Live. 235 | * 236 | * @return \Gomoob\Pushwoosh\Model\Notification\Android this instance. 237 | */ 238 | public function setGcmTtl($gcmTtl) 239 | { 240 | $this->gcmTtl = $gcmTtl; 241 | 242 | return $this; 243 | } 244 | 245 | public function setHeader($header) 246 | { 247 | $this->header = $header; 248 | 249 | return $this; 250 | 251 | } 252 | 253 | /** 254 | * Sets the icon background color on Lollipop, #RRGGBB, #AARRGGBB, "red", "black", "yellow", etc. 255 | * 256 | * @param string $ibc The icon background color on Lollipop. 257 | * 258 | * @return \Gomoob\Pushwoosh\Model\Notification\Android this instance. 259 | */ 260 | public function setIbc($ibc) 261 | { 262 | $this->ibc = $ibc; 263 | 264 | return $this; 265 | } 266 | 267 | public function setIcon($icon) 268 | { 269 | $this->icon = $icon; 270 | 271 | return $this; 272 | } 273 | 274 | /** 275 | * Sets the LED hex color, device will do its best approximation. 276 | * 277 | * @param string $led The LED hex color to set. 278 | * 279 | * @return \Gomoob\Pushwoosh\Model\Notification\Android this instance. 280 | */ 281 | public function setLed($led) 282 | { 283 | $this->led = $led; 284 | 285 | return $this; 286 | } 287 | 288 | /** 289 | * Sets the priority of the push in the Android push drawer, valid values are -2, -1, 0, 1 and 2. 290 | * 291 | * @param int $priority The priority of the push in the Android push drawer. 292 | * 293 | * @return \Gomoob\Pushwoosh\Model\Notification\Android this instance. 294 | */ 295 | public function setPriority($priority) 296 | { 297 | $this->priority = $priority; 298 | 299 | return $this; 300 | } 301 | 302 | public function setRootParams($rootParams) 303 | { 304 | $this->rootParams = $rootParams; 305 | 306 | return $this; 307 | } 308 | 309 | public function setSound($sound) 310 | { 311 | $this->sound = $sound; 312 | 313 | return $this; 314 | } 315 | 316 | /** 317 | * Sets the boolean used to force vibration for high-priority pushes. 318 | * 319 | * @param boolean $vibration The boolean used to force vibration for high-priority pushes. 320 | * 321 | * @return \Gomoob\Pushwoosh\Model\Notification\Android this instance. 322 | */ 323 | public function setVibration($vibration) 324 | { 325 | $this->vibration = $vibration; 326 | 327 | return $this; 328 | } 329 | } 330 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Notification/BlackBerry.php: -------------------------------------------------------------------------------- 1 | header; 34 | 35 | } 36 | 37 | /** 38 | * {@inheritdoc} 39 | */ 40 | public function jsonSerialize() 41 | { 42 | $json = []; 43 | 44 | isset($this->header) ? $json['blackberry_header'] = $this->header : false; 45 | 46 | return $json; 47 | 48 | } 49 | 50 | public function setHeader($header) 51 | { 52 | $this->header = $header; 53 | 54 | return $this; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Notification/Chrome.php: -------------------------------------------------------------------------------- 1 | gcmTtl; 64 | } 65 | 66 | /** 67 | * Gets the full path URL to the icon, or the path to the file in resources of the extension. 68 | * 69 | * @return string the full path URL to the icon, or the path to the file in resources of the extension. 70 | */ 71 | public function getIcon() 72 | { 73 | return $this->icon; 74 | } 75 | 76 | /** 77 | * Gets the header of the message. 78 | * 79 | * @var string The header of the message. 80 | */ 81 | public function getTitle() 82 | { 83 | return $this->title; 84 | } 85 | 86 | /** 87 | * Gets the image of the message. 88 | * 89 | * @var string The image of the message. 90 | */ 91 | public function getImage() 92 | { 93 | return $this->image; 94 | } 95 | 96 | /** 97 | * {@inheritdoc} 98 | */ 99 | public function jsonSerialize() 100 | { 101 | $json = []; 102 | 103 | isset($this->gcmTtl) ? $json['chrome_gcm_ttl'] = $this->gcmTtl : false; 104 | isset($this->icon) ? $json['chrome_icon'] = $this->icon : false; 105 | isset($this->title) ? $json['chrome_title'] = $this->title : false; 106 | isset($this->image) ? $json['chrome_image'] = $this->image : false; 107 | 108 | return $json; 109 | 110 | } 111 | 112 | /** 113 | * Sets the time to live parameter - the maximum lifespan of a message in seconds. 114 | * 115 | * @param int $gcmTtl The time to live parameter. 116 | * 117 | * @return \Gomoob\Pushwoosh\Model\Notification\Chrome this instance. 118 | */ 119 | public function setGcmTtl($gcmTtl) 120 | { 121 | $this->gcmTtl = $gcmTtl; 122 | 123 | return $this; 124 | } 125 | 126 | /** 127 | * Sets the full path URL to the icon, or the path to the file in resources of the extension. 128 | * 129 | * @param string $icon the full path URL to the icon, or the path to the file in resources of the extension. 130 | * 131 | * @return \Gomoob\Pushwoosh\Model\Notification\Chrome this instance. 132 | */ 133 | public function setIcon($icon) 134 | { 135 | $this->icon = $icon; 136 | 137 | return $this; 138 | } 139 | 140 | /** 141 | * Sets the header of the message. 142 | * 143 | * @param string $title The header of the message. 144 | * 145 | * @return \Gomoob\Pushwoosh\Model\Notification\Chrome this instance. 146 | */ 147 | public function setTitle($title) 148 | { 149 | $this->title = $title; 150 | 151 | return $this; 152 | } 153 | 154 | /** 155 | * Sets the image of the message. 156 | * 157 | * @param string $image The image of the message. 158 | * 159 | * @return \Gomoob\Pushwoosh\Model\Notification\Chrome this instance. 160 | */ 161 | public function setImage($image) 162 | { 163 | $this->image = $image; 164 | 165 | return $this; 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Notification/Firefox.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | class Firefox implements \JsonSerializable 17 | { 18 | /** 19 | * The full path URL to the icon, or the path to the file in resources of the extension. 20 | * 21 | * @var string 22 | */ 23 | private $icon; 24 | 25 | /** 26 | * The header of the message. 27 | * 28 | * @var string 29 | */ 30 | private $title; 31 | 32 | /** 33 | * Utility function used to create a new Firefox instance. 34 | * 35 | * @return \Gomoob\Pushwoosh\Model\Notification\Firefox the new created instance. 36 | */ 37 | public static function create() 38 | { 39 | return new Firefox(); 40 | } 41 | 42 | /** 43 | * Get the full path URL to the icon, or the path to the file in resources of the extension. 44 | * 45 | * @return string the full path URL to the icon, or the path to the file in resources of the extension. 46 | */ 47 | public function getIcon() 48 | { 49 | return $this->icon; 50 | } 51 | 52 | /** 53 | * Gets the header of the message. 54 | * 55 | * @return string the header of the message. 56 | */ 57 | public function getTitle() 58 | { 59 | return $this->title; 60 | } 61 | 62 | /** 63 | * {@inheritdoc} 64 | */ 65 | public function jsonSerialize() 66 | { 67 | $json = []; 68 | 69 | isset($this->icon) ? $json['firefox_icon'] = $this->icon : false; 70 | isset($this->title) ? $json['firefox_title'] = $this->title : false; 71 | 72 | return $json; 73 | } 74 | 75 | /** 76 | * Sets the full path URL to the icon, or the path to the file in resources of the extension. 77 | * 78 | * @param string $icon the full path URL to the icon, or the path to the file in resources of the extension. 79 | * 80 | * @return \Gomoob\Pushwoosh\Model\Notification\Firefox this instance. 81 | */ 82 | public function setIcon($icon) 83 | { 84 | $this->icon = $icon; 85 | return $this; 86 | } 87 | 88 | /** 89 | * Sets the header of the message. 90 | * 91 | * @param string $title the header of the message to set. 92 | * 93 | * @return \Gomoob\Pushwoosh\Model\Notification\Firefox this instance. 94 | */ 95 | public function setTitle($title) 96 | { 97 | $this->title = $title; 98 | return $this; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Notification/IOS.php: -------------------------------------------------------------------------------- 1 | badges; 52 | } 53 | 54 | /** 55 | * Gets the iOS 8 category ID from Pushwoosh. 56 | * 57 | * @return int The iOS 8 category ID from Pushwoosh. 58 | */ 59 | public function getCategoryId() 60 | { 61 | return $this->categoryId; 62 | } 63 | 64 | public function getRootParams() 65 | { 66 | return $this->rootParams; 67 | } 68 | 69 | public function getSound() 70 | { 71 | return $this->sound; 72 | 73 | } 74 | 75 | public function getTtl() 76 | { 77 | return $this->ttl; 78 | } 79 | 80 | /** 81 | * TODO: TO BE DOCUMENTED ! 82 | * 83 | * @return boolean 84 | */ 85 | public function isApnsTrimContent() 86 | { 87 | return $this->apnsTrimContent; 88 | 89 | } 90 | 91 | public function isTrimContent() 92 | { 93 | return $this->trimContent; 94 | 95 | } 96 | 97 | /** 98 | * {@inheritdoc} 99 | */ 100 | public function jsonSerialize() 101 | { 102 | $json = []; 103 | 104 | isset($this->apnsTrimContent) ? $json['apns_trim_content'] = intval($this->apnsTrimContent) : false; 105 | isset($this->badges) ? $json['ios_badges'] = $this->badges : false; 106 | isset($this->categoryId) ? $json['ios_category_id'] = $this->categoryId : false; 107 | isset($this->rootParams) ? $json['ios_root_params'] = $this->rootParams : false; 108 | isset($this->sound) ? $json['ios_sound'] = $this->sound : false; 109 | isset($this->ttl) ? $json['ios_ttl'] = $this->ttl : false; 110 | isset($this->trimContent) ? $json['ios_trim_content'] = intval($this->trimContent) : false; 111 | 112 | return $json; 113 | 114 | } 115 | 116 | /** 117 | * TODO: TO BE DOCUMENTED ! 118 | * 119 | * @param boolean $apnsTrimContent 120 | * 121 | * @return \Gomoob\Pushwoosh\Model\Notification\IOS this instance. 122 | */ 123 | public function setApnsTrimContent($apnsTrimContent) 124 | { 125 | $this->apnsTrimContent = $apnsTrimContent; 126 | 127 | return $this; 128 | 129 | } 130 | 131 | public function setBadges($badges) 132 | { 133 | $this->badges = $badges; 134 | 135 | return $this; 136 | 137 | } 138 | 139 | /** 140 | * Sets the iOS 8 category ID from Pushwoosh. 141 | * 142 | * @param int $categoryId The iOS 8 category ID from Pushwoosh. 143 | * 144 | * @return \Gomoob\Pushwoosh\Model\Notification\IOS this instance. 145 | */ 146 | public function setCategoryId($categoryId) 147 | { 148 | $this->categoryId = $categoryId; 149 | 150 | return $this; 151 | } 152 | 153 | public function setRootParams($rootParams) 154 | { 155 | $this->rootParams = $rootParams; 156 | 157 | return $this; 158 | 159 | } 160 | 161 | public function setSound($sound) 162 | { 163 | $this->sound = $sound; 164 | 165 | return $this; 166 | } 167 | 168 | public function setTtl($ttl) 169 | { 170 | $this->ttl = $ttl; 171 | 172 | return $this; 173 | 174 | } 175 | 176 | public function setTrimContent($trimContent) 177 | { 178 | $this->trimContent = $trimContent; 179 | 180 | return $this; 181 | } 182 | } 183 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Notification/Mac.php: -------------------------------------------------------------------------------- 1 | badges; 37 | 38 | } 39 | 40 | public function getRootParams() 41 | { 42 | return $this->rootParams; 43 | 44 | } 45 | 46 | public function getSound() 47 | { 48 | return $this->sound; 49 | 50 | } 51 | 52 | public function getTtl() 53 | { 54 | return $this->ttl; 55 | } 56 | 57 | /** 58 | * {@inheritdoc} 59 | */ 60 | public function jsonSerialize() 61 | { 62 | $json = []; 63 | 64 | isset($this->badges) ? $json['mac_badges'] = $this->badges : false; 65 | isset($this->rootParams) ? $json['mac_root_params'] = $this->rootParams : false; 66 | isset($this->sound) ? $json['mac_sound'] = $this->sound : false; 67 | isset($this->ttl) ? $json['mac_ttl'] = $this->ttl : false; 68 | 69 | return $json; 70 | 71 | } 72 | 73 | public function setBadges($badges) 74 | { 75 | $this->badges = $badges; 76 | 77 | return $this; 78 | } 79 | 80 | public function setRootParams($rootParams) 81 | { 82 | $this->rootParams = $rootParams; 83 | 84 | return $this; 85 | } 86 | 87 | public function setSound($sound) 88 | { 89 | $this->sound = $sound; 90 | 91 | return $this; 92 | } 93 | 94 | public function setTtl($ttl) 95 | { 96 | $this->ttl = $ttl; 97 | 98 | return $this; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Notification/MinimizeLink.php: -------------------------------------------------------------------------------- 1 | MinimizeLink instance. 30 | * 31 | * @param int $value the value. 32 | */ 33 | private function __construct($value) 34 | { 35 | $this->value = $value; 36 | } 37 | 38 | /** 39 | * Gets a MinimizeLink instance for Bitly minimization. 40 | * 41 | * @return \Gomoob\Pushwoosh\Model\Notification\MinimizeLink the created MinimizeLink instance. 42 | */ 43 | public static function bitly() 44 | { 45 | return new MinimizeLink(2); 46 | } 47 | 48 | /** 49 | * Gets a MinimizeLink instance for no minimization. 50 | * 51 | * @return \Gomoob\Pushwoosh\Model\Notification\MinimizeLink the created MinimizeLink instance. 52 | */ 53 | public static function none() 54 | { 55 | return new MinimizeLink(0); 56 | } 57 | 58 | /** 59 | * Gets a MinimizeLink instance for Google minimization. 60 | * 61 | * @return \Gomoob\Pushwoosh\Model\Notification\MinimizeLink the created MinimizeLink instance. 62 | */ 63 | public static function google() 64 | { 65 | return new MinimizeLink(1); 66 | } 67 | 68 | /** 69 | * Gets the value of the minimize link, this can be equal to : 70 | * - 0 or false : do not minimize the link 71 | * - 1 : (Default) Minimze with Google 72 | * - 2 : Minimize with Bitly 73 | * 74 | * @return int the value of the minimize link. 75 | */ 76 | public function getValue() 77 | { 78 | return $this->value; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Notification/Platform.php: -------------------------------------------------------------------------------- 1 | Platform instance. 83 | * 84 | * @param int $value the value of the platform. 85 | */ 86 | private function __construct($value) 87 | { 88 | $this->value = $value; 89 | } 90 | 91 | /** 92 | * Get a Platform instance for Amazon. 93 | * 94 | * @return \Gomoob\Pushwoosh\Model\Notification\Platform the created Platform instance. 95 | */ 96 | public static function amazon() 97 | { 98 | return new Platform(self::AMAZON); 99 | } 100 | 101 | /** 102 | * Get a Platform instance for Android. 103 | * 104 | * @return \Gomoob\Pushwoosh\Model\Notification\Platform the created Platform instance. 105 | */ 106 | public static function android() 107 | { 108 | return new Platform(self::ANDROID); 109 | } 110 | 111 | /** 112 | * Get a Platform instance for BlackBerry. 113 | * 114 | * @return \Gomoob\Pushwoosh\Model\Notification\Platform the created Platform instance. 115 | */ 116 | public static function blackBerry() 117 | { 118 | return new Platform(self::BLACKBERRY); 119 | } 120 | 121 | /** 122 | * Get a Platform instance for Chrome. 123 | * 124 | * @return \Gomoob\Pushwoosh\Model\Notification\Platform the created Platform instance. 125 | */ 126 | public static function chrome() 127 | { 128 | return new Platform(self::CHROME); 129 | } 130 | 131 | /** 132 | * Get a Platform instance for iOS. 133 | * 134 | * @return \Gomoob\Pushwoosh\Model\Notification\Platform the created Platform instance. 135 | */ 136 | public static function iOS() 137 | { 138 | return new Platform(self::IOS); 139 | } 140 | 141 | /** 142 | * Get a Platform instance for Mac OS X. 143 | * 144 | * @return \Gomoob\Pushwoosh\Model\Notification\Platform the created Platform instance. 145 | */ 146 | public static function macOSX() 147 | { 148 | return new Platform(self::MAC_OS_X); 149 | } 150 | 151 | /** 152 | * Get a Platform instance for Nokia ASHA. 153 | * 154 | * @return \Gomoob\Pushwoosh\Model\Notification\Platform the created Platform instance. 155 | */ 156 | public static function nokia() 157 | { 158 | return new Platform(self::NOKIA_ASHA); 159 | } 160 | 161 | /** 162 | * Get a Platform instance for Safari. 163 | * 164 | * @return \Gomoob\Pushwoosh\Model\Notification\Platform the created Platform instance. 165 | */ 166 | public static function safari() 167 | { 168 | return new Platform(self::SAFARI); 169 | } 170 | 171 | /** 172 | * Get a Platform instance for Windows Phone 7. 173 | * 174 | * @return \Gomoob\Pushwoosh\Model\Notification\Platform the created Platform instance. 175 | */ 176 | public static function windowsPhone7() 177 | { 178 | return new Platform(self::WINDOWS_PHONE_7); 179 | } 180 | 181 | /** 182 | * Get a Platform instance for Windows 8. 183 | * 184 | * @return \Gomoob\Pushwoosh\Model\Notification\Platform the created Platform instance. 185 | */ 186 | public static function windows8() 187 | { 188 | return new Platform(self::WINDOWS_8); 189 | } 190 | 191 | /** 192 | * Get a Platform instance for Firefox. 193 | * 194 | * @return \Gomoob\Pushwoosh\Model\Notification\Platform the created Platform instance. 195 | */ 196 | public static function firefox() 197 | { 198 | return new Platform(self::FIREFOX); 199 | } 200 | 201 | /** 202 | * Gets the value of the plateform, this can be equal to : 203 | * - 1 : iOS 204 | * - 2 : BlackBerry 205 | * - 3 : Android 206 | * - 4 : Nokia ASHA 207 | * - 5 : Windows Phone 7 208 | * - 7 : Mac OS X 209 | * - 8 : Windows 8 210 | * - 9 : Amazon 211 | * - 10: Safari 212 | * - 11: Chrome 213 | * - 12: Firefox 214 | * 215 | * @return int the value of the platform. 216 | */ 217 | public function getValue() 218 | { 219 | return $this->value; 220 | } 221 | } 222 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Notification/Safari.php: -------------------------------------------------------------------------------- 1 | action; 36 | } 37 | 38 | public function getTitle() 39 | { 40 | return $this->title; 41 | } 42 | 43 | public function getTtl() 44 | { 45 | return $this->ttl; 46 | } 47 | 48 | public function getUrlArgs() 49 | { 50 | return $this->urlArgs; 51 | } 52 | 53 | /** 54 | * {@inheritdoc} 55 | */ 56 | public function jsonSerialize() 57 | { 58 | $json = []; 59 | 60 | isset($this->action) ? $json['safari_action'] = $this->action : false; 61 | isset($this->title) ? $json['safari_title'] = $this->title : false; 62 | isset($this->ttl) ? $json['safari_ttl'] = $this->ttl : false; 63 | isset($this->urlArgs) ? $json['safari_url_args'] = $this->urlArgs : false; 64 | 65 | return $json; 66 | 67 | } 68 | 69 | public function setAction($action) 70 | { 71 | $this->action = $action; 72 | 73 | return $this; 74 | } 75 | 76 | public function setTitle($title) 77 | { 78 | $this->title = $title; 79 | 80 | return $this; 81 | } 82 | 83 | public function setTtl($ttl) 84 | { 85 | $this->ttl = $ttl; 86 | 87 | return $this; 88 | } 89 | 90 | public function setUrlArgs(array $urlArgs) 91 | { 92 | $this->urlArgs = $urlArgs; 93 | 94 | return $this; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Notification/WNS.php: -------------------------------------------------------------------------------- 1 | content; 36 | 37 | } 38 | 39 | public function getTag() 40 | { 41 | return $this->tag; 42 | 43 | } 44 | 45 | public function getType() 46 | { 47 | return $this->type; 48 | 49 | } 50 | 51 | public function setContent($content) 52 | { 53 | $this->content = $content; 54 | 55 | return $this; 56 | } 57 | 58 | public function setTag($tag) 59 | { 60 | $this->tag = $tag; 61 | 62 | return $this; 63 | } 64 | 65 | public function setType($type) 66 | { 67 | $this->type = $type; 68 | 69 | return $this; 70 | } 71 | 72 | /** 73 | * {@inheritdoc} 74 | */ 75 | public function jsonSerialize() 76 | { 77 | $json = []; 78 | 79 | isset($this->content) ? $json['wns_content'] = $this->content : false; 80 | isset($this->tag) ? $json['wns_tag'] = $this->tag : false; 81 | isset($this->type) ? $json['wns_type'] = $this->type : false; 82 | 83 | return $json; 84 | 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Notification/WP.php: -------------------------------------------------------------------------------- 1 | backbackground; 38 | 39 | } 40 | 41 | public function getBackcontent() 42 | { 43 | return $this->backcontent; 44 | } 45 | 46 | public function getBackground() 47 | { 48 | return $this->background; 49 | } 50 | 51 | public function getBacktitle() 52 | { 53 | return $this->backtitle; 54 | 55 | } 56 | 57 | public function getCount() 58 | { 59 | return $this->count; 60 | } 61 | 62 | public function getType() 63 | { 64 | return $this->type; 65 | } 66 | 67 | /** 68 | * {@inheritdoc} 69 | */ 70 | public function jsonSerialize() 71 | { 72 | $json = []; 73 | 74 | isset($this->backbackground) ? $json['wp_backbackground'] = $this->backbackground : false; 75 | isset($this->backcontent) ? $json['wp_backcontent'] = $this->backcontent : false; 76 | isset($this->background) ? $json['wp_background'] = $this->background : false; 77 | isset($this->backtitle) ? $json['wp_backtitle'] = $this->backtitle : false; 78 | isset($this->count) ? $json['wp_count'] = $this->count : false; 79 | isset($this->type) ? $json['wp_type'] = $this->type : false; 80 | 81 | return $json; 82 | 83 | } 84 | 85 | public function setBackbackground($backbackground) 86 | { 87 | $this->backbackground = $backbackground; 88 | 89 | return $this; 90 | } 91 | 92 | public function setBackcontent($backcontent) 93 | { 94 | $this->backcontent = $backcontent; 95 | 96 | return $this; 97 | } 98 | 99 | public function setBackground($background) 100 | { 101 | $this->background = $background; 102 | 103 | return $this; 104 | } 105 | 106 | public function setBacktitle($backtitle) 107 | { 108 | $this->backtitle = $backtitle; 109 | 110 | return $this; 111 | } 112 | 113 | public function setCount($count) 114 | { 115 | $this->count = $count; 116 | 117 | return $this; 118 | } 119 | 120 | public function setType($type) 121 | { 122 | $this->type = $type; 123 | 124 | return $this; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Request/AbstractRequest.php: -------------------------------------------------------------------------------- 1 | isAuthSupported()) { 36 | throw new PushwooshException('This request does not support the \'auth\' parameter !'); 37 | } 38 | 39 | return $this->auth; 40 | } 41 | 42 | /** 43 | * {@inheritDoc} 44 | */ 45 | public function setAuth($auth) 46 | { 47 | // If the `auth` parameter is not supported we throw an exception 48 | if (!$this->isAuthSupported()) { 49 | throw new PushwooshException('This request does not support the \'auth\' parameter !'); 50 | } 51 | 52 | $this->auth = $auth; 53 | 54 | return $this; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Request/CreateMessageRequest.php: -------------------------------------------------------------------------------- 1 | CreateMessageRequest. 45 | * 46 | * @return \Gomoob\Pushwoosh\Model\Request\CreateMessageRequest the new created instance. 47 | */ 48 | public static function create() 49 | { 50 | return new CreateMessageRequest(); 51 | } 52 | 53 | /** 54 | * Adds a new Pushwoosh notification to the notifications attached to this create message request. 55 | * 56 | * @param \Gomoob\Pushwoosh\Model\Notification\Notification $notification the new notification to add. 57 | * 58 | * @return \Gomoob\Pushwoosh\Model\Request\CreateMessageRequest this instance. 59 | */ 60 | public function addNotification(Notification $notification) 61 | { 62 | if (!isset($this->notifications)) { 63 | $this->notifications = []; 64 | } 65 | 66 | $this->notifications[] = $notification; 67 | 68 | return $this; 69 | } 70 | 71 | /** 72 | * Gets the Pushwoosh application ID where to send the message to (cannot be used together with "applicationsGroup") 73 | * . 74 | * 75 | * @return string the Pushwoosh application ID where to send the message to (cannot be used together with 76 | * "applicationsGroup"). 77 | */ 78 | public function getApplication() 79 | { 80 | return $this->application; 81 | } 82 | 83 | /** 84 | * Gets the Pushwoosh Application group code (cannot be used together with "application"). 85 | * 86 | * @return string the Pushwoosh Application group code (cannot be used together with "application"). 87 | */ 88 | public function getApplicationsGroup() 89 | { 90 | return $this->applicationsGroup; 91 | } 92 | 93 | /** 94 | * Gets the Pushwoosh notifications to attach to the create message request. 95 | * 96 | * @return \Gomoob\Pushwoosh\Model\Notification\Notification[] the Pushwoosh notifications to attach to the create 97 | * message request. 98 | */ 99 | public function getNotifications() 100 | { 101 | return $this->notifications; 102 | } 103 | 104 | /** 105 | * {@inheritDoc} 106 | */ 107 | public function isAuthSupported() 108 | { 109 | return true; 110 | } 111 | 112 | /** 113 | * {@inheritdoc} 114 | */ 115 | public function jsonSerialize() 116 | { 117 | // One of the 'application' or 'applicationsGroup' parameter must have been defined. 118 | if (!isset($this->application) && !isset($this->applicationsGroup)) { 119 | throw new PushwooshException('None of the \'application\' or \'applicationsGroup\' properties are set !'); 120 | } 121 | 122 | // If the 'application' or 'applicationsGroup' parameters are both set this is an error 123 | if (isset($this->application) && isset($this->applicationsGroup)) { 124 | throw new PushwooshException('Both \'application\' and \'applicationsGroup\' properties are set !'); 125 | } 126 | 127 | // The 'auth' parameter must have been set 128 | if (!isset($this->auth)) { 129 | throw new PushwooshException('The \'auth\' property is not set !'); 130 | } 131 | 132 | $json = [ 133 | 'application' => $this->application, 134 | 'applications_group' => $this->applicationsGroup, 135 | 'auth' => $this->auth, 136 | 'notifications' => [] 137 | ]; 138 | 139 | // Adds the notifications 140 | // Please note that the Pushwoosh REST API seems to authorize calls to the 'createMessage' service with a create 141 | // message request which do not define any notification. This is authorized but has no effect. 142 | if (isset($this->notifications)) { 143 | foreach ($this->notifications as $notification) { 144 | $json['notifications'][] = $notification->jsonSerialize(); 145 | } 146 | } 147 | 148 | return $json; 149 | } 150 | 151 | /** 152 | * Sets the Pushwoosh application ID where to send the message to (cannot be used together with "applicationsGroup") 153 | * . 154 | * 155 | * @param string $application the Pushwoosh application ID where to send the message to (cannot be used together 156 | * with "applicationsGroup"). 157 | * 158 | * @return \Gomoob\Pushwoosh\Model\Request\CreateMessageRequest this instance. 159 | */ 160 | public function setApplication($application) 161 | { 162 | $this->application = $application; 163 | 164 | return $this; 165 | } 166 | 167 | /** 168 | * Sets the Pushwoosh Application group code (cannot be used together with "application"). 169 | * 170 | * @param string $applicationsGroup the Pushwoosh Application group code (cannot be used together with 171 | * "application"). 172 | * 173 | * @return \Gomoob\Pushwoosh\Model\Request\CreateMessageRequest this instance. 174 | */ 175 | public function setApplicationsGroup($applicationsGroup) 176 | { 177 | $this->applicationsGroup = $applicationsGroup; 178 | 179 | return $this; 180 | } 181 | 182 | /** 183 | * Sets the Pushwoosh notifications to attach to the create message request. 184 | * 185 | * @param \Gomoob\Pushwoosh\Model\Notification\Notification[] $notifications the Pushwoosh notifications to attach 186 | * to the create message request. 187 | * 188 | * @return \Gomoob\Pushwoosh\Model\Request\CreateMessageRequest this instance. 189 | */ 190 | public function setNotifications(array $notifications) 191 | { 192 | $this->notifications = $notifications; 193 | 194 | return $this; 195 | } 196 | } 197 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Request/DeleteMessageRequest.php: -------------------------------------------------------------------------------- 1 | DeleteMessageRequest. 29 | * 30 | * @return \Gomoob\Pushwoosh\Model\Request\DeleteMessageRequest the new created instance. 31 | */ 32 | public static function create() 33 | { 34 | return new DeleteMessageRequest(); 35 | } 36 | 37 | /** 38 | * Gets the message code obtained in createMessage. 39 | * 40 | * @return string the message code obtained in createMessage. 41 | */ 42 | public function getMessage() 43 | { 44 | return $this->message; 45 | } 46 | 47 | /** 48 | * {@inheritDoc} 49 | */ 50 | public function isAuthSupported() 51 | { 52 | return true; 53 | } 54 | 55 | /** 56 | * {@inheritdoc} 57 | */ 58 | public function jsonSerialize() 59 | { 60 | // The 'auth' parameter must have been set 61 | if (!isset($this->auth)) { 62 | throw new PushwooshException('The \'auth\' property is not set !'); 63 | } 64 | 65 | // The 'message' parameter must have been set 66 | if (!isset($this->message)) { 67 | throw new PushwooshException('The \'message\' property is not set !'); 68 | } 69 | 70 | return [ 71 | 'auth' => $this->auth, 72 | 'message' => $this->message 73 | ]; 74 | } 75 | 76 | /** 77 | * Sets the message code obtained in createMessage. 78 | * 79 | * @param string $message the message code obtained in createdMessage. 80 | * 81 | * @return \Gomoob\Pushwoosh\Model\Request\DeleteMessageRequest this instance. 82 | */ 83 | public function setMessage($message) 84 | { 85 | $this->message = $message; 86 | 87 | return $this; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Request/GetNearestZoneRequest.php: -------------------------------------------------------------------------------- 1 | GetNearestZoneRequest. 50 | * 51 | * @return \Gomoob\Pushwoosh\Model\Request\GetNearestZoneRequest the new created instance. 52 | */ 53 | public static function create() 54 | { 55 | return new GetNearestZoneRequest(); 56 | } 57 | 58 | /** 59 | * Gets the Pushwoosh application ID where you send the message to. 60 | * 61 | * @return string Pushwoosh application ID where you send the message to. 62 | */ 63 | public function getApplication() 64 | { 65 | return $this->application; 66 | } 67 | 68 | /** 69 | * Gets the hardware device id used in registerDevice function call. 70 | * 71 | * @return string the hardware device id used in registerDevice function call. 72 | */ 73 | public function getHwid() 74 | { 75 | return $this->hwid; 76 | } 77 | 78 | /** 79 | * Gets the latitude of the device. 80 | * 81 | * @return float the latitude of the device. 82 | */ 83 | public function getLat() 84 | { 85 | return $this->lat; 86 | } 87 | 88 | /** 89 | * Gets the longitude of the device. 90 | * 91 | * @return float the longitude of the device. 92 | */ 93 | public function getLng() 94 | { 95 | return $this->lng; 96 | } 97 | 98 | /** 99 | * {@inheritDoc} 100 | */ 101 | public function isAuthSupported() 102 | { 103 | return false; 104 | } 105 | 106 | /** 107 | * {@inheritdoc} 108 | */ 109 | public function jsonSerialize() 110 | { 111 | // The 'application' parameter must have been defined. 112 | if (!isset($this->application)) { 113 | throw new PushwooshException('The \'application\' property is not set !'); 114 | } 115 | 116 | // The 'hwid' parameter must have been defined. 117 | if (!isset($this->hwid)) { 118 | throw new PushwooshException('The \'hwid\' property is not set !'); 119 | } 120 | 121 | // The 'lat' parameter must have been defined 122 | if (!isset($this->lat)) { 123 | throw new PushwooshException('The \'lat\' property is not set !'); 124 | } 125 | 126 | // The 'lng' parameter must have been defined 127 | if (!isset($this->lng)) { 128 | throw new PushwooshException('The \'lng\' property is not set !'); 129 | } 130 | 131 | return [ 132 | 'application' => $this->application, 133 | 'hwid' => $this->hwid, 134 | 'lat' => $this->lat, 135 | 'lng' => $this->lng 136 | ]; 137 | } 138 | 139 | /** 140 | * Sets the Pushwoosh application ID where you send the message to. 141 | * 142 | * @param string $application Pushwoosh application ID where you send the message to. 143 | * 144 | * @return \Gomoob\Pushwoosh\Model\Request\GetNearestZoneRequest this instance. 145 | */ 146 | public function setApplication($application) 147 | { 148 | $this->application = $application; 149 | 150 | return $this; 151 | } 152 | 153 | /** 154 | * Sets the hardware device id used in registerDevice function call. 155 | * 156 | * @param string $hwid the the hardware device id used in registerDevice function call. 157 | * 158 | * @return \Gomoob\Pushwoosh\Model\Request\GetNearestZoneRequest this instance. 159 | */ 160 | public function setHwid($hwid) 161 | { 162 | $this->hwid = $hwid; 163 | 164 | return $this; 165 | } 166 | 167 | /** 168 | * Sets the latitude of the device. 169 | * 170 | * @param float $lat the latitude of the device. 171 | * 172 | * @return \Gomoob\Pushwoosh\Model\Request\GetNearestZoneRequest this instance. 173 | */ 174 | public function setLat($lat) 175 | { 176 | $this->lat = $lat; 177 | 178 | return $this; 179 | } 180 | 181 | /** 182 | * Sets the longitude of the device. 183 | * 184 | * @param float $lng the longitude of the device. 185 | * 186 | * @return \Gomoob\Pushwoosh\Model\Request\GetNearestZoneRequest this instance. 187 | */ 188 | public function setLng($lng) 189 | { 190 | $this->lng = $lng; 191 | 192 | return $this; 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Request/GetTagsRequest.php: -------------------------------------------------------------------------------- 1 | GetTagsRequest. 36 | * 37 | * @return \Gomoob\Pushwoosh\Model\Request\GetTagsRequest the new created instance. 38 | */ 39 | public static function create() 40 | { 41 | return new GetTagsRequest(); 42 | } 43 | 44 | /** 45 | * Gets the Pushwoosh application ID where to send the message to. 46 | * 47 | * @return string the Pushwoosh application ID where to send the message to. 48 | */ 49 | public function getApplication() 50 | { 51 | return $this->application; 52 | } 53 | 54 | /** 55 | * Gets the hardware device id used in registerDevice function call. 56 | * 57 | * @return string the hardware device id used in registerDevice function call. 58 | */ 59 | public function getHwid() 60 | { 61 | return $this->hwid; 62 | } 63 | 64 | /** 65 | * {@inheritDoc} 66 | */ 67 | public function isAuthSupported() 68 | { 69 | return true; 70 | } 71 | 72 | /** 73 | * {@inheritdoc} 74 | */ 75 | public function jsonSerialize() 76 | { 77 | // The 'application' parameter must have been defined. 78 | if (!isset($this->application)) { 79 | throw new PushwooshException('The \'application\' property is not set !'); 80 | } 81 | 82 | // The 'auth' parameter must have been set 83 | if (!isset($this->auth)) { 84 | throw new PushwooshException('The \'auth\' property is not set !'); 85 | } 86 | 87 | // The 'hwid' parameter must have been defined. 88 | if (!isset($this->hwid)) { 89 | throw new PushwooshException('The \'hwid\' property is not set !'); 90 | } 91 | 92 | return [ 93 | 'application' => $this->application, 94 | 'auth' => $this->auth, 95 | 'hwid' => $this->hwid 96 | ]; 97 | } 98 | 99 | /** 100 | * Sets the Pushwoosh application ID where to send the message to. 101 | * 102 | * @param string $application the Pushwoosh application ID where to send the message to. 103 | * 104 | * @return \Gomoob\Pushwoosh\Model\Request\CreateMessageRequest this instance. 105 | */ 106 | public function setApplication($application) 107 | { 108 | $this->application = $application; 109 | 110 | return $this; 111 | } 112 | 113 | /** 114 | * Sets the hardware device id used in registerDevice function call. 115 | * 116 | * @param string $hwid the the hardware device id used in registerDevice function call. 117 | * 118 | * @return \Gomoob\Pushwoosh\Model\Request\GetNearestZoneRequest this instance. 119 | */ 120 | public function setHwid($hwid) 121 | { 122 | $this->hwid = $hwid; 123 | 124 | return $this; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Request/PushStatRequest.php: -------------------------------------------------------------------------------- 1 | PushStatRequest. 43 | * 44 | * @return \Gomoob\Pushwoosh\Model\Request\PushStatRequest the new created instance. 45 | */ 46 | public static function create() 47 | { 48 | return new PushStatRequest(); 49 | } 50 | 51 | /** 52 | * Gets the Pushwoosh application ID where you send the message to. 53 | * 54 | * @return string Pushwoosh application ID where you send the message to. 55 | */ 56 | public function getApplication() 57 | { 58 | return $this->application; 59 | } 60 | 61 | /** 62 | * Gets the tag received in push notification. 63 | * 64 | * @return string the tag received in push notification. 65 | */ 66 | public function getHash() 67 | { 68 | return $this->hash; 69 | } 70 | 71 | /** 72 | * Gets the hardware device id used in registerDevice function call. 73 | * 74 | * @return string the hardware device id used in registerDevice function call. 75 | */ 76 | public function getHwid() 77 | { 78 | return $this->hwid; 79 | } 80 | 81 | /** 82 | * {@inheritDoc} 83 | */ 84 | public function isAuthSupported() 85 | { 86 | return false; 87 | } 88 | 89 | /** 90 | * {@inheritdoc} 91 | */ 92 | public function jsonSerialize() 93 | { 94 | // The 'application' parameter must have been defined. 95 | if (!isset($this->application)) { 96 | throw new PushwooshException('The \'application\' property is not set !'); 97 | } 98 | 99 | // The 'hash' parameter must have been defined. 100 | if (!isset($this->hash)) { 101 | throw new PushwooshException('The \'hash\' property is not set !'); 102 | } 103 | 104 | // The 'hwid' parameter must have been defined. 105 | if (!isset($this->hwid)) { 106 | throw new PushwooshException('The \'hwid\' property is not set !'); 107 | } 108 | 109 | return [ 110 | 'application' => $this->application, 111 | 'hash' => $this->hash, 112 | 'hwid' => $this->hwid 113 | ]; 114 | } 115 | 116 | /** 117 | * Sets the Pushwoosh application ID where you send the message to. 118 | * 119 | * @param string $application Pushwoosh application ID where you send the message to. 120 | * 121 | * @return \Gomoob\Pushwoosh\Model\Request\PushStatRequest this instance. 122 | */ 123 | public function setApplication($application) 124 | { 125 | $this->application = $application; 126 | 127 | return $this; 128 | } 129 | 130 | /** 131 | * Sets the tag received in push notification. 132 | * 133 | * @param string $hash the tag received in push notification. 134 | * 135 | * @return \Gomoob\Pushwoosh\Model\Request\PushStatRequest this instance. 136 | */ 137 | public function setHash($hash) 138 | { 139 | $this->hash = $hash; 140 | 141 | return $this; 142 | } 143 | 144 | /** 145 | * Sets the hardware device id used in registerDevice function call. 146 | * 147 | * @param string $hwid the the hardware device id used in registerDevice function call. 148 | * 149 | * @return \Gomoob\Pushwoosh\Model\Request\PushStatRequest this instance. 150 | */ 151 | public function setHwid($hwid) 152 | { 153 | $this->hwid = $hwid; 154 | 155 | return $this; 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Request/RegisterDeviceRequest.php: -------------------------------------------------------------------------------- 1 | RegisterDeviceRequest. 71 | * 72 | * @return \Gomoob\Pushwoosh\Model\Request\RegisterDeviceRequest the new created instance. 73 | */ 74 | public static function create() 75 | { 76 | return new RegisterDeviceRequest(); 77 | } 78 | 79 | /** 80 | * Gets the Pushwoosh application ID for which one to register a new device. 81 | * 82 | * @return string the Pushwoosh application ID for which one to register a new device. 83 | */ 84 | public function getApplication() 85 | { 86 | return $this->application; 87 | } 88 | 89 | /** 90 | * Gets the device type, this attribute can take the following values : 91 | * - 1 : iPhone 92 | * - 2 : Blackberry 93 | * - 3 : Android 94 | * - 4 : Nokia 95 | * - 5 : Windows Phone 7 96 | * - 7 : Mac 97 | * 98 | * @return int the device type. 99 | */ 100 | public function getDeviceType() 101 | { 102 | return $this->deviceType; 103 | } 104 | 105 | /** 106 | * Gets the Unique string to identify the device (Please note that accessing UDID on iOS is deprecated and not 107 | * allowed, one of the alternative ways now is to use MAC address). 108 | * 109 | * @return string the Unique string to identify the device (Please note that accessing UDID on iOS is deprecated and 110 | * not allowed, one of the alternative ways now is to use MAC address). 111 | */ 112 | public function getHwid() 113 | { 114 | return $this->hwid; 115 | } 116 | 117 | /** 118 | * Gets the language local of the device, this is a 2 letter local (for exempke "en"). 119 | * 120 | * @return string the language local of the device, this is a 2 letter local (for exempke "en"). 121 | */ 122 | public function getLanguage() 123 | { 124 | return $this->language; 125 | } 126 | 127 | /** 128 | * Gets the push token associated to the device. 129 | * 130 | * @return string the push token associated to the device. 131 | */ 132 | public function getPushToken() 133 | { 134 | return $this->pushToken; 135 | } 136 | 137 | /** 138 | * Gets the timezone offset in seconds for the device (optional). 139 | * 140 | * @return int the timezone offset in seconds for the device (optional). 141 | */ 142 | public function getTimezone() 143 | { 144 | return $this->timezone; 145 | } 146 | 147 | /** 148 | * {@inheritDoc} 149 | */ 150 | public function isAuthSupported() 151 | { 152 | return false; 153 | } 154 | 155 | /** 156 | * {@inheritdoc} 157 | */ 158 | public function jsonSerialize() 159 | { 160 | // The 'application' parameter must have been defined. 161 | if (!isset($this->application)) { 162 | throw new PushwooshException('The \'application\' property is not set !'); 163 | } 164 | 165 | // The 'deviceType' parameter must have been defined and must be valid. 166 | $this->checkDeviceType(); 167 | 168 | // The 'hwid' parameter must have been defined. 169 | if (!isset($this->hwid)) { 170 | throw new PushwooshException('The \'hwid\' property is not set !'); 171 | } 172 | 173 | // The 'pushToken' parameter must have been defined. 174 | if (!isset($this->pushToken)) { 175 | throw new PushwooshException('The \'pushToken\' property is not set !'); 176 | } 177 | 178 | $json = [ 179 | 'application' => $this->application, 180 | 'push_token' => $this->pushToken, 181 | 'language' => $this->language, 182 | 'hwid' => $this->hwid, 183 | 'timezone' => $this->timezone, 184 | 'device_type' => $this->deviceType 185 | ]; 186 | 187 | return $json; 188 | } 189 | 190 | /** 191 | * Sets the Pushwoosh application ID for which one to register a new device. 192 | * 193 | * @param string $application the the Pushwoosh application ID for which one to register a new device. 194 | * 195 | * @return \Gomoob\Pushwoosh\Model\Request\RegisterDeviceRequest this instance. 196 | */ 197 | public function setApplication($application) 198 | { 199 | $this->application = $application; 200 | 201 | return $this; 202 | } 203 | 204 | /** 205 | * Sets the device type, this attribute can take the following values : 206 | * - 1 : iPhone 207 | * - 2 : Blackberry 208 | * - 3 : Android 209 | * - 4 : Nokia 210 | * - 5 : Windows Phone 7 211 | * - 7 : Mac 212 | * 213 | * @param int $deviceType the device type to set. 214 | * 215 | * @return \Gomoob\Pushwoosh\Model\Request\RegisterDeviceRequest this instance. 216 | */ 217 | public function setDeviceType($deviceType) 218 | { 219 | $this->deviceType = $deviceType; 220 | 221 | return $this; 222 | } 223 | 224 | /** 225 | * Sets the Unique string to identify the device (Please note that accessing UDID on iOS is deprecated and not 226 | * allowed, one of the alternative ways now is to use MAC address). 227 | * 228 | * @param string $hwid the Unique string to identify the device (Please note that accessing UDID on iOS is 229 | * deprecated and not allowed, one of the alternative ways now is to use MAC address). 230 | * 231 | * @return \Gomoob\Pushwoosh\Model\Request\RegisterDeviceRequest this instance. 232 | */ 233 | public function setHwid($hwid) 234 | { 235 | $this->hwid = $hwid; 236 | 237 | return $this; 238 | } 239 | 240 | /** 241 | * Sets the the language local of the device, this is a 2 letter local (for exempke "en"). 242 | * 243 | * @param string $language the the language local of the device, this is a 2 letter local (for exempke "en"). 244 | * 245 | * @return \Gomoob\Pushwoosh\Model\Request\RegisterDeviceRequest this instance. 246 | */ 247 | public function setLanguage($language) 248 | { 249 | $this->language = $language; 250 | 251 | return $this; 252 | } 253 | 254 | /** 255 | * Sets the push token associated to the device. 256 | * 257 | * @param string $pushToken the push token associated to the device. 258 | * 259 | * @return \Gomoob\Pushwoosh\Model\Request\RegisterDeviceRequest this instance. 260 | */ 261 | public function setPushToken($pushToken) 262 | { 263 | $this->pushToken = $pushToken; 264 | 265 | return $this; 266 | } 267 | 268 | /** 269 | * Sets the timezone offset in seconds for the device (optional). 270 | * 271 | * @param int $timezone the timezone offset in seconds for the device (optional). 272 | * 273 | * @return \Gomoob\Pushwoosh\Model\Request\RegisterDeviceRequest this instance. 274 | */ 275 | public function setTimezone($timezone) 276 | { 277 | $this->timezone = $timezone; 278 | 279 | return $this; 280 | } 281 | 282 | /** 283 | * Function used to check if the device type is configured and is valid. 284 | * 285 | * @throws \Gomoob\Pushwoosh\Exception\PushwooshException if the device type is not configured or is not valid. 286 | */ 287 | private function checkDeviceType() 288 | { 289 | // The 'deviceType' parameter must have been defined. 290 | if (!isset($this->deviceType)) { 291 | throw new PushwooshException('The \'deviceType\' property is not set !'); 292 | } 293 | 294 | // The 'deviceType' must be valid 295 | switch ($this->deviceType) { 296 | // 1 - iOS 297 | case 1: 298 | break; 299 | 300 | // 2 - BlackBerry 301 | case 2: 302 | break; 303 | 304 | // 3 - Android 305 | case 3: 306 | break; 307 | 308 | // 4 - Nokia ASHA 309 | case 4: 310 | break; 311 | 312 | // 5 - Windows Phone 313 | case 5: 314 | break; 315 | 316 | // 6 - Error (not documented in the Pushwoosh documentation) 317 | case 6: 318 | throw new PushwooshException('The \'deviceType\' value \'' . $this->deviceType . '\' is invalid !'); 319 | break; 320 | 321 | // 7 - Mac OS X 322 | case 7: 323 | break; 324 | 325 | // 8 - Windows 8 326 | case 8: 327 | break; 328 | 329 | // 9 - Amazon 330 | case 9: 331 | break; 332 | 333 | // 10 - Safari 334 | case 10: 335 | break; 336 | 337 | // Invalid device type value 338 | default: 339 | throw new PushwooshException('The \'deviceType\' value \'' . $this->deviceType . '\' is invalid !'); 340 | break; 341 | } 342 | } 343 | } 344 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Request/SetBadgeRequest.php: -------------------------------------------------------------------------------- 1 | SetBadgeRequest. 43 | * 44 | * @return \Gomoob\Pushwoosh\Model\Request\SetBadgeRequest the new created instance. 45 | */ 46 | public static function create() 47 | { 48 | return new SetBadgeRequest(); 49 | } 50 | 51 | /** 52 | * Gets the Pushwoosh application ID where you send the message to. 53 | * 54 | * @return string Pushwoosh application ID where you send the message to. 55 | */ 56 | public function getApplication() 57 | { 58 | return $this->application; 59 | } 60 | 61 | /** 62 | * Gets the current badge on the application to use with auto-incrementing badges. 63 | * 64 | * @return int the current badge on the application to use with auto-incrementing badges. 65 | */ 66 | public function getBadge() 67 | { 68 | return $this->badge; 69 | } 70 | 71 | /** 72 | * Gets the hardware device id used in registerDevice function call. 73 | * 74 | * @return string the hardware device id used in registerDevice function call. 75 | */ 76 | public function getHwid() 77 | { 78 | return $this->hwid; 79 | } 80 | 81 | /** 82 | * {@inheritDoc} 83 | */ 84 | public function isAuthSupported() 85 | { 86 | return false; 87 | } 88 | 89 | /** 90 | * {@inheritdoc} 91 | */ 92 | public function jsonSerialize() 93 | { 94 | // The 'application' parameter must have been defined. 95 | if (!isset($this->application)) { 96 | throw new PushwooshException('The \'application\' property is not set !'); 97 | } 98 | 99 | // The 'badge' parameter must have been defined 100 | if (!isset($this->badge)) { 101 | throw new PushwooshException('The \'badge\' property is not set !'); 102 | } 103 | 104 | // The 'hwid' parameter must have been defined. 105 | if (!isset($this->hwid)) { 106 | throw new PushwooshException('The \'hwid\' property is not set !'); 107 | } 108 | 109 | return [ 110 | 'application' => $this->application, 111 | 'badge' => $this->badge, 112 | 'hwid' => $this->hwid 113 | ]; 114 | } 115 | 116 | /** 117 | * Sets the Pushwoosh application ID where you send the message to. 118 | * 119 | * @param string $application Pushwoosh application ID where you send the message to. 120 | * 121 | * @return \Gomoob\Pushwoosh\Model\Request\GetNearestZoneRequest this instance. 122 | */ 123 | public function setApplication($application) 124 | { 125 | $this->application = $application; 126 | 127 | return $this; 128 | } 129 | 130 | /** 131 | * Sets the current badge on the application to use with auto-incrementing badges. 132 | * 133 | * @param int $badge the current badge on the application to use with auto-incrementing badges. 134 | */ 135 | public function setBadge($badge) 136 | { 137 | $this->badge = $badge; 138 | 139 | return $this; 140 | } 141 | 142 | /** 143 | * Sets the hardware device id used in registerDevice function call. 144 | * 145 | * @param string $hwid the the hardware device id used in registerDevice function call. 146 | * 147 | * @return \Gomoob\Pushwoosh\Model\Request\GetNearestZoneRequest this instance. 148 | */ 149 | public function setHwid($hwid) 150 | { 151 | $this->hwid = $hwid; 152 | 153 | return $this; 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Request/SetTagsRequest.php: -------------------------------------------------------------------------------- 1 | SetTagsRequest. 44 | * 45 | * @return \Gomoob\Pushwoosh\Model\Request\SetTagsRequest the new created instance. 46 | */ 47 | public static function create() 48 | { 49 | return new SetTagsRequest(); 50 | } 51 | 52 | /** 53 | * Add a new tag to the Pushwoosh tags. 54 | * 55 | *

NOTE: This function cannot be used to overwrite an existing tag, use the '#setTag($tagName, $tagValue)' 56 | * function if you want to overwrite a tag.

57 | * 58 | * @param string $tagName the name of the tag to add or update. 59 | * @param mixed $tagValue the value of the tag to set. 60 | * 61 | * @throws \Gomoob\Pushwoosh\Exception\PushwooshException if a tag having the specified name has already been added. 62 | */ 63 | public function addTag($tagName, $tagValue) 64 | { 65 | if (!isset($this->tags)) { 66 | $this->tags = []; 67 | } 68 | 69 | // The same tag cannot be added 2 times 70 | if (array_key_exists($tagName, $this->tags)) { 71 | throw new PushwooshException( 72 | 'The tag \'' . $tagName . 73 | '\' has already been added, use the \'setTag\' method if you want to overwrite its value !' 74 | ); 75 | } 76 | 77 | $this->tags[$tagName] = $tagValue; 78 | } 79 | 80 | /** 81 | * Gets the Pushwoosh application ID for which one to set tags. 82 | * 83 | * @return string the Pushwoosh application ID for which one to set tags. 84 | */ 85 | public function getApplication() 86 | { 87 | return $this->application; 88 | } 89 | 90 | /** 91 | * Gets the Unique string to identify the device (Please note that accessing UDID on iOS is deprecated and not 92 | * allowed, one of the alternative ways now is to use MAC address). 93 | * 94 | * @return string the Unique string to identify the device (Please note that accessing UDID on iOS is deprecated and 95 | * not allowed, one of the alternative ways now is to use MAC address). 96 | */ 97 | public function getHwid() 98 | { 99 | return $this->hwid; 100 | } 101 | 102 | /** 103 | * Gets the Pushwoosh tags. 104 | * 105 | * @return array the Pushwoosh tags. 106 | */ 107 | public function getTags() 108 | { 109 | return $this->tags; 110 | } 111 | 112 | /** 113 | * Function used to check if a tag having a specified name exists. 114 | * 115 | * @param string $tagName the name of the tag. 116 | * 117 | * @return boolean true if a tag having a name equal to $tagName exists, false otherwise. 118 | */ 119 | public function hasTag($tagName) 120 | { 121 | return $this->tags !== null && array_key_exists($tagName, $this->tags); 122 | } 123 | 124 | /** 125 | * {@inheritDoc} 126 | */ 127 | public function isAuthSupported() 128 | { 129 | return false; 130 | } 131 | 132 | /** 133 | * {@inheritdoc} 134 | */ 135 | public function jsonSerialize() 136 | { 137 | // The 'application' parameter must have been defined. 138 | if (!isset($this->application)) { 139 | throw new PushwooshException('The \'application\' property is not set !'); 140 | } 141 | 142 | // The 'hwid' parameter must have been defined. 143 | if (!isset($this->hwid)) { 144 | throw new PushwooshException('The \'hwid\' property is not set !'); 145 | } 146 | 147 | // The 'tags' parameter must have been defined. 148 | if (!isset($this->tags)) { 149 | throw new PushwooshException('The \'tags\' property is not set !'); 150 | } 151 | 152 | $json = [ 153 | 'application' => $this->application, 154 | 'hwid' => $this->hwid, 155 | 'tags' => $this->tags 156 | ]; 157 | 158 | return $json; 159 | } 160 | 161 | /** 162 | * Function used to remove a tag from the Pushwoosh tags. 163 | * 164 | *

NOTE: If you try to remove a tag which does not exists the function has not effect.

165 | * 166 | * @param string $tagName the name of the tag to remove. 167 | */ 168 | public function removeTag($tagName) 169 | { 170 | if ($this->tags !== null && array_key_exists($tagName, $this->tags)) { 171 | unset($this->tags[$tagName]); 172 | } 173 | } 174 | 175 | /** 176 | * Sets the Pushwoosh application ID for which one to set tags. 177 | * 178 | * @param string $application the the Pushwoosh application ID for which one to set tags. 179 | * 180 | * @return \Gomoob\Pushwoosh\Model\Request\SetTagsRequest this instance. 181 | */ 182 | public function setApplication($application) 183 | { 184 | $this->application = $application; 185 | 186 | return $this; 187 | } 188 | 189 | /** 190 | * Sets the Unique string to identify the device (Please note that accessing UDID on iOS is deprecated and not 191 | * allowed, one of the alternative ways now is to use MAC address). 192 | * 193 | * @param string $hwid the Unique string to identify the device (Please note that accessing UDID on iOS is 194 | * deprecated and not allowed, one of the alternative ways now is to use MAC address). 195 | * 196 | * @return \Gomoob\Pushwoosh\Model\Request\SetTagsRequest this instance. 197 | */ 198 | public function setHwid($hwid) 199 | { 200 | $this->hwid = $hwid; 201 | 202 | return $this; 203 | } 204 | 205 | /** 206 | * Add a new tag to the Pushwoosh tags or overwrites the value of an existing tag. 207 | * 208 | * @param string $tagName the name of the tag to add or update. 209 | * @param mixed $tagValue the value of the tag to set. 210 | * 211 | * @return \Gomoob\Pushwoosh\Model\Request\SetTagsRequest this instance. 212 | */ 213 | public function setTag($tagName, $tagValue) 214 | { 215 | if (!isset($this->tags)) { 216 | $this->tags = []; 217 | } 218 | 219 | $this->tags[$tagName] = $tagValue; 220 | 221 | return $this; 222 | } 223 | 224 | /** 225 | * Sets the Pushwoosh tags. 226 | * 227 | * @param array $tags the Pushwoosh tags. 228 | * 229 | * @return \Gomoob\Pushwoosh\Model\Request\SetTagsRequest this instance. 230 | */ 231 | public function setTags(array $tags) 232 | { 233 | $this->tags = $tags; 234 | 235 | return $this; 236 | } 237 | } 238 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Request/UnregisterDeviceRequest.php: -------------------------------------------------------------------------------- 1 | UnregisterDeviceRequest. 37 | * 38 | * @return \Gomoob\Pushwoosh\Model\Request\UnregisterDeviceRequest the new created instance. 39 | */ 40 | public static function create() 41 | { 42 | return new UnregisterDeviceRequest(); 43 | } 44 | 45 | /** 46 | * Gets the Pushwoosh application ID for which one to register a new device. 47 | * 48 | * @return string the Pushwoosh application ID for which one to register a new device. 49 | */ 50 | public function getApplication() 51 | { 52 | return $this->application; 53 | } 54 | 55 | /** 56 | * Gets the Unique string to identify the device (Please note that accessing UDID on iOS is deprecated and not 57 | * allowed, one of the alternative ways now is to use MAC address). 58 | * 59 | * @return string the Unique string to identify the device (Please note that accessing UDID on iOS is deprecated and 60 | * not allowed, one of the alternative ways now is to use MAC address). 61 | */ 62 | public function getHwid() 63 | { 64 | return $this->hwid; 65 | } 66 | 67 | /** 68 | * {@inheritDoc} 69 | */ 70 | public function isAuthSupported() 71 | { 72 | return false; 73 | } 74 | 75 | /** 76 | * {@inheritdoc} 77 | */ 78 | public function jsonSerialize() 79 | { 80 | // The 'application' parameter must have been defined. 81 | if (!isset($this->application)) { 82 | throw new PushwooshException('The \'application\' property is not set !'); 83 | } 84 | 85 | // The 'hwid' parameter must have been defined. 86 | if (!isset($this->hwid)) { 87 | throw new PushwooshException('The \'hwid\' property is not set !'); 88 | } 89 | 90 | return [ 91 | 'application' => $this->application, 92 | 'hwid' => $this->hwid 93 | ]; 94 | } 95 | 96 | /** 97 | * Sets the Pushwoosh application ID for which one to register a new device. 98 | * 99 | * @param string $application the the Pushwoosh application ID for which one to register a new device. 100 | * 101 | * @return \Gomoob\Pushwoosh\Model\Request\UnregisterDeviceRequest this instance. 102 | */ 103 | public function setApplication($application) 104 | { 105 | $this->application = $application; 106 | 107 | return $this; 108 | } 109 | 110 | /** 111 | * Sets the Unique string to identify the device (Please note that accessing UDID on iOS is deprecated and not 112 | * allowed, one of the alternative ways now is to use MAC address). 113 | * 114 | * @param string $hwid the Unique string to identify the device (Please note that accessing UDID on iOS is 115 | * deprecated and not allowed, one of the alternative ways now is to use MAC address). 116 | * 117 | * @return \Gomoob\Pushwoosh\Model\Request\UnregisterDeviceRequest this instance. 118 | */ 119 | public function setHwid($hwid) 120 | { 121 | $this->hwid = $hwid; 122 | 123 | return $this; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Response/AbstractResponse.php: -------------------------------------------------------------------------------- 1 | statusCode; 44 | } 45 | 46 | /** 47 | * {@inheritDoc} 48 | */ 49 | public function getStatusMessage() 50 | { 51 | return $this->statusMessage; 52 | } 53 | 54 | /** 55 | * {@inheritDoc} 56 | */ 57 | public function isOk() 58 | { 59 | return $this->statusCode === 200; 60 | } 61 | 62 | /** 63 | * {@inheritDoc} 64 | */ 65 | public function setStatusCode($statusCode) 66 | { 67 | $this->statusCode = $statusCode; 68 | } 69 | 70 | /** 71 | * {@inheritDoc} 72 | */ 73 | public function setStatusMessage($statusMessage) 74 | { 75 | $this->statusMessage = $statusMessage; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Response/CreateMessageResponse.php: -------------------------------------------------------------------------------- 1 | setStatusCode($json['status_code']); 36 | $createMessageResponse->setStatusMessage($json['status_message']); 37 | 38 | // If a 'response' is provided 39 | if (array_key_exists('response', $json) && isset($json['response'])) { 40 | $createMessageResponseResponse = new CreateMessageResponseResponse(); 41 | 42 | // If 'Messages' are provided 43 | if (array_key_exists('Messages', $json['response'])) { 44 | $createMessageResponseResponse->setMessages($json['response']['Messages']); 45 | } 46 | 47 | $createMessageResponse->setResponse($createMessageResponseResponse); 48 | } 49 | 50 | return $createMessageResponse; 51 | } 52 | 53 | /** 54 | * Gets the Pushwoosh '/createMessage' response response. 55 | * 56 | * @return \Gomoob\Pushwoosh\Model\Response\CreateMessageResponseResponse the Pushwoosh '/createMessage' response 57 | * response. 58 | */ 59 | public function getResponse() 60 | { 61 | return $this->response; 62 | } 63 | 64 | /** 65 | * Sets the Pushwoosh '/createMessage' response response. 66 | * 67 | * @param \Gomoob\Pushwoosh\Model\Response\CreateMessageResponseResponse $response the Pushwoosh '/createMessage' 68 | * response response. 69 | */ 70 | public function setResponse(CreateMessageResponseResponse $response) 71 | { 72 | $this->response = $response; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Response/CreateMessageResponseResponse.php: -------------------------------------------------------------------------------- 1 | messages; 33 | 34 | } 35 | 36 | /** 37 | * Sets the Pushwoosh messages sent in response to a Create Message request. 38 | * 39 | * @param string[] $messages the Pushwoosh messages sent in response to a Create Message Request. 40 | */ 41 | public function setMessages($messages) 42 | { 43 | $this->messages = $messages; 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Response/CreateTargetedMessageResponse.php: -------------------------------------------------------------------------------- 1 | setStatusCode($json['status_code']); 36 | $createTargetedMessageResponse->setStatusMessage($json['status_message']); 37 | 38 | // If a 'response' is provided 39 | if (array_key_exists('response', $json) && isset($json['response'])) { 40 | $createTargetedMessageResponseResponse = new CreateTargetedMessageResponseResponse(); 41 | 42 | // If 'messageCode' is provided 43 | if (array_key_exists('messageCode', $json['response'])) { 44 | $createTargetedMessageResponseResponse->setMessageCode($json['response']['messageCode']); 45 | } 46 | 47 | $createTargetedMessageResponse->setResponse($createTargetedMessageResponseResponse); 48 | } 49 | 50 | return $createTargetedMessageResponse; 51 | } 52 | 53 | /** 54 | * Gets the Pushwoosh '/createTargetedMessage' response response. 55 | * 56 | * @return \Gomoob\Pushwoosh\Model\Response\CreateTargetedMessageResponseResponse the Pushwoosh 57 | * '/createTargetedMessage' response response. 58 | */ 59 | public function getResponse() 60 | { 61 | return $this->response; 62 | } 63 | 64 | /** 65 | * Sets the Pushwoosh '/createTargetedMessage' response response. 66 | * 67 | * @param \Gomoob\Pushwoosh\Model\Response\CreateTargetedMessageResponseResponse $response the Pushwoosh 68 | * '/createTargetedMessage' response response. 69 | */ 70 | public function setResponse(CreateTargetedMessageResponseResponse $response) 71 | { 72 | $this->response = $response; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Response/CreateTargetedMessageResponseResponse.php: -------------------------------------------------------------------------------- 1 | messageCode; 33 | } 34 | 35 | /** 36 | * Sets the Pushwoosh message code sent in response to a Create Targeted Message request. 37 | * 38 | * @param string $messageCode the Pushwoosh message code sent in response to a Create Targeted Message Request. 39 | */ 40 | public function setMessageCode($messageCode) 41 | { 42 | $this->messageCode = $messageCode; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Response/DeleteMessageResponse.php: -------------------------------------------------------------------------------- 1 | setStatusCode($json['status_code']); 29 | $deleteMessageResponse->setStatusMessage($json['status_message']); 30 | 31 | return $deleteMessageResponse; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Response/GetNearestZoneResponse.php: -------------------------------------------------------------------------------- 1 | setStatusCode($json['status_code']); 36 | $getNearestZoneResponse->setStatusMessage($json['status_message']); 37 | 38 | // If a 'response' is provided 39 | if (array_key_exists('response', $json) && isset($json['response'])) { 40 | $getNearestZoneResponseResponse = new GetNearestZoneResponseResponse(); 41 | $getNearestZoneResponseResponse->setDistance($json['response']['distance']); 42 | $getNearestZoneResponseResponse->setLat($json['response']['lat']); 43 | $getNearestZoneResponseResponse->setLng($json['response']['lng']); 44 | $getNearestZoneResponseResponse->setName($json['response']['name']); 45 | $getNearestZoneResponseResponse->setRange($json['response']['range']); 46 | $getNearestZoneResponse->setResponse($getNearestZoneResponseResponse); 47 | } 48 | 49 | return $getNearestZoneResponse; 50 | } 51 | 52 | /** 53 | * Gets the Pushwoosh '/getNearestZone' response response. 54 | * 55 | * @return \Gomoob\Pushwoosh\Model\Response\GetNearestZoneResponseResponse the Pushwoosh'/getNearestZone' response 56 | * response. 57 | */ 58 | public function getResponse() 59 | { 60 | return $this->response; 61 | } 62 | 63 | /** 64 | * Sets the Pushwoosh'/getNearestZone' response response. 65 | * 66 | * @param \Gomoob\Pushwoosh\Model\Response\GetNearestZoneResponseResponse $response the Pushwoosh '/getNearestZone' 67 | * response response. 68 | */ 69 | public function setResponse(GetNearestZoneResponseResponse $response) 70 | { 71 | $this->response = $response; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Response/GetNearestZoneResponseResponse.php: -------------------------------------------------------------------------------- 1 | 15 | * An instance of this objects represent the nearest zone to the position provided in the '/getNearestZone' request. 16 | *

17 | * 18 | * @author Baptiste GAILLARD (baptiste.gaillard@gomoob.com) 19 | */ 20 | class GetNearestZoneResponseResponse 21 | { 22 | /** 23 | * The distance of the device from the nearest zone in meters. 24 | * 25 | * @var int 26 | */ 27 | private $distance; 28 | 29 | /** 30 | * The latitude of the nearest zone. 31 | * 32 | * @var float 33 | */ 34 | private $lat; 35 | 36 | /** 37 | * The longitude of the nearest zone. 38 | * 39 | * @var float 40 | */ 41 | private $lng; 42 | 43 | /** 44 | * The name of the nearest zone. 45 | * 46 | * @var string 47 | */ 48 | private $name; 49 | 50 | /** 51 | * The range of the nearest zone in meters. 52 | * 53 | * @var int 54 | */ 55 | private $range; 56 | 57 | /** 58 | * Gets the distance of the device from the nearest zone in meters. 59 | * 60 | * @return int distance of the device from the nearest zone in meters. 61 | */ 62 | public function getDistance() 63 | { 64 | return $this->distance; 65 | 66 | } 67 | 68 | /** 69 | * Gets the latitude of the nearest zone. 70 | * 71 | * @return float the latitude of the nearest zone. 72 | */ 73 | public function getLat() 74 | { 75 | return $this->lat; 76 | 77 | } 78 | 79 | /** 80 | * Gets the longitude of the nearest zone. 81 | * 82 | * @return float the longitude of the nearest zone. 83 | */ 84 | public function getLng() 85 | { 86 | return $this->lng; 87 | 88 | } 89 | 90 | /** 91 | * Gets the name of the nearest zone. 92 | * 93 | * @return string the name of the nearest zone. 94 | */ 95 | public function getName() 96 | { 97 | return $this->name; 98 | 99 | } 100 | 101 | /** 102 | * Gets the range of the nearest zone in meters. 103 | * 104 | * @return int the range of the nearest zone in meters. 105 | */ 106 | public function getRange() 107 | { 108 | return $this->range; 109 | 110 | } 111 | 112 | /** 113 | * Sets the distance of the device from the nearest zone in meters. 114 | * 115 | * @param int $distance the distance of the device from the nearest zone in meters. 116 | */ 117 | public function setDistance($distance) 118 | { 119 | $this->distance = $distance; 120 | 121 | } 122 | 123 | /** 124 | * Sets the latitude of the nearest zone. 125 | * 126 | * @param float $lat the latitude of the nearest zone. 127 | */ 128 | public function setLat($lat) 129 | { 130 | $this->lat = $lat; 131 | 132 | } 133 | 134 | /** 135 | * Sets the longitude of the nearest zone. 136 | * 137 | * @param float $lng the longitude of the nearest zone. 138 | */ 139 | public function setLng($lng) 140 | { 141 | $this->lng = $lng; 142 | 143 | } 144 | 145 | /** 146 | * Sets the name of the nearest zone. 147 | * 148 | * @param string $name the name of the nearest zone. 149 | */ 150 | public function setName($name) 151 | { 152 | $this->name = $name; 153 | 154 | } 155 | 156 | /** 157 | * Sets the range of the nearest zone in meters. 158 | * 159 | * @param int $range the range of the nearest zone in meters. 160 | */ 161 | public function setRange($range) 162 | { 163 | $this->range = $range; 164 | 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Response/GetTagsResponse.php: -------------------------------------------------------------------------------- 1 | setStatusCode($json['status_code']); 36 | $getTagsResponse->setStatusMessage($json['status_message']); 37 | 38 | // If a 'response' is provided 39 | if (array_key_exists('response', $json) && isset($json['response'])) { 40 | $getTagsResponseResponse = new GetTagsResponseResponse(); 41 | 42 | // If a 'result' is provided 43 | if (array_key_exists('result', $json['response'])) { 44 | $getTagsResponseResponse->setResult($json['response']['result']); 45 | } 46 | 47 | $getTagsResponse->setResponse($getTagsResponseResponse); 48 | } 49 | 50 | return $getTagsResponse; 51 | } 52 | 53 | /** 54 | * Gets the Pushwoosh '/getTags' response response. 55 | * 56 | * @return \Gomoob\Pushwoosh\Model\Response\GetTagsResponseResponse the Pushwoosh '/createMessage' response 57 | * response. 58 | */ 59 | public function getResponse() 60 | { 61 | return $this->response; 62 | } 63 | 64 | /** 65 | * Sets the Pushwoosh '/getTags' response response. 66 | * 67 | * @param \Gomoob\Pushwoosh\Model\Response\GetTagsResponseResponse $response the Pushwoosh '/createMessage' 68 | * response response. 69 | */ 70 | public function setResponse(GetTagsResponseResponse $response) 71 | { 72 | $this->response = $response; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Response/GetTagsResponseResponse.php: -------------------------------------------------------------------------------- 1 | result; 33 | } 34 | 35 | /** 36 | * Gets the result sent in response to a Get Tags request. 37 | * 38 | * @return array the result sent in response to a Get Tags request. 39 | */ 40 | public function getResult() 41 | { 42 | return $this->result; 43 | } 44 | 45 | /** 46 | * Function used to check if a tag having a specified name exists. 47 | * 48 | * @param string $tagName the name of the tag. 49 | * 50 | * @return boolean true if a tag having a name equal to $tagName exists, false otherwise. 51 | */ 52 | public function hasTag($tagName) 53 | { 54 | return $this->result !== null && array_key_exists($tagName, $this->result); 55 | } 56 | 57 | /** 58 | * Sets the result sent in response to a Get Tags request. 59 | * 60 | * @param array $result the result sent in response to a Get Tags request. 61 | */ 62 | public function setResult(array $result) 63 | { 64 | $this->result = $result; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Response/PushStatResponse.php: -------------------------------------------------------------------------------- 1 | setStatusCode($json['status_code']); 29 | $pushStatResponse->setStatusMessage($json['status_message']); 30 | 31 | return $pushStatResponse; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Response/RegisterDeviceResponse.php: -------------------------------------------------------------------------------- 1 | setStatusCode($json['status_code']); 29 | $registerDeviceResponse->setStatusMessage($json['status_message']); 30 | 31 | return $registerDeviceResponse; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Response/SetBadgeResponse.php: -------------------------------------------------------------------------------- 1 | setStatusCode($json['status_code']); 29 | $setBadgeResponse->setStatusMessage($json['status_message']); 30 | 31 | return $setBadgeResponse; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Response/SetTagsResponse.php: -------------------------------------------------------------------------------- 1 | setStatusCode($json['status_code']); 29 | $setTagsResponse->setStatusMessage($json['status_message']); 30 | 31 | return $setTagsResponse; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/php/Gomoob/Pushwoosh/Model/Response/UnregisterDeviceResponse.php: -------------------------------------------------------------------------------- 1 | setStatusCode($json['status_code']); 29 | $unregisterDeviceResponse->setStatusMessage($json['status_message']); 30 | 31 | return $unregisterDeviceResponse; 32 | } 33 | } 34 | --------------------------------------------------------------------------------