/** * Test method for the <tt>getApplication()</tt> and <tt>setApplication($application)</tt> * functions. */ public function testGetSetApplication() { $createMessageRequest = new CreateMessageRequest(); $this->assertNull($createMessageRequest->getApplication()); $createMessageRequest->setApplication('APPLICATION'); $this->assertEquals('APPLICATION', $createMessageRequest->getApplication()); }
/** * {@inheritDoc} */ public function createMessage(CreateMessageRequest $createMessageRequest) { // If both the 'application' and 'applicationsGroup' attribute are not set in the request we try to get a // default one from the Pushwoosh client if ($createMessageRequest->getApplication() === null && $createMessageRequest->getApplicationsGroup() == null) { // Setting both 'application' and 'applicationsGroup' is forbidden if (!isset($this->application) && !isset($this->applicationsGroup)) { throw new PushwooshException('None of the \'application\' or \'applicationsGroup\' properties are set !'); // Setting both the 'application' and 'applicationsGroup' parameters is an error here } elseif (isset($this->application) && isset($this->applicationsGroup)) { throw new PushwooshException('Both \'application\' and \'applicationsGroup\' properties are set !'); // Sets the 'application' attribute } elseif (isset($this->application)) { $createMessageRequest->setApplication($this->application); // Sets the 'applicationsGroup' attribute } elseif (isset($this->applicationsGroup)) { $createMessageRequest->setApplicationsGroup($this->applicationsGroup); } } // If the 'auth' parameter is not set in the request we try to get it from the Pushwoosh client if ($createMessageRequest->getAuth() === null) { // The 'auth' parameter is expected here if (!isset($this->auth)) { throw new PushwooshException('The \'auth\' parameter is not set !'); // Use the 'auth' parameter defined in the Pushwoosh client } else { $createMessageRequest->setAuth($this->auth); } } $response = $this->cURLClient->pushwooshCall('createMessage', $createMessageRequest->jsonSerialize()); return CreateMessageResponse::create($response); }