コード例 #1
0
 /**
  * Send object
  * 
  * This method is used to send a Transactional Message to an email address.
  * The response indicates whether the send was successful.
  *
  * @param int $uniqueIdentifier
  * @param string $random
  * @param string $securityTag
  * @param string $email
  * @param array $dyn
  * @param array $content
  * @param string $type
  * @param string $sendDate
  * @param string $uidKey
  *
  * @throws \Exception
  * @return string
  */
 public function sendObject($uniqueIdentifier, $random, $securityTag, $email, array $dyn = null, array $content = null, $type = 'INSERT_UPDATE', $sendDate = null, $uidKey = 'email')
 {
     // List of valid type
     $allowedTypes = ['INSERT', 'UPDATE', 'INSERT_UPDATE', 'NOTHING'];
     // Check if type is valid
     if (!in_array($type, $allowedTypes)) {
         throw new \Exception('Invalid type (' . $type . '), allowed values are: ' . implode(', ', $allowedTypes) . '.');
     }
     $parameters['arg0'] = ['email' => (string) $email, 'encrypt' => (string) $securityTag, 'random' => (string) $random, 'notificationId' => (int) $uniqueIdentifier, 'senddate' => null !== $sendDate ? (int) $sendDate : time(), 'synchrotype' => (string) $type, 'uidkey' => (string) $uidKey];
     // Dynamic Personalization Parameters
     $parameters['arg0']['dyn'] = array();
     if (null !== $dyn) {
         foreach ($dyn as $key => $value) {
             $parameters['arg0']['dyn'] = ['entry' => ['key' => $key, 'value' => $value]];
         }
     }
     // Content Parameters
     $parameters['arg0']['content'] = array();
     if (null !== $content) {
         foreach ($content as $key => $value) {
             $parameters['arg0']['content'] = ['entry' => ['key' => $key, 'value' => $value]];
         }
     }
     return (string) $this->apiClient->doCall('sendObject', $parameters);
 }
コード例 #2
0
 public function testDoCallWithSoapFaultResponse()
 {
     $loginParameters = ['login' => $this->login, 'pwd' => $this->password, 'key' => $this->key];
     $loginResponse = new \stdClass();
     $loginResponse->return = 'TOKEN1234';
     $this->soapClient->expects($this->at(0))->method('__soapCall')->with('openApiConnection', [$loginParameters])->will($this->returnValue($loginResponse));
     $method = 'methodTest';
     $parameters = ['id' => '1234'];
     $this->soapClient->expects($this->at(1))->method('__soapCall')->will($this->throwException(new \SoapFault('SoapError', 0)));
     $this->setExpectedException('\\MyLittle\\CampaignCommander\\API\\SOAP\\APIException');
     $apiClient = new APIClient($this->soapClient, $this->login, $this->password, $this->key);
     $apiClient->doCall($method, $parameters);
 }