Пример #1
0
 /**
  * @return Struct\SMS
  */
 protected function makeItem()
 {
     $item = new Struct\SMS();
     $item->setTo(new Struct\NumberTo(self::GERMANY, '456456456'));
     $item->setFrom(new Struct\NumberFrom(self::GERMANY, '123456789'));
     $item->setMessage(new Struct\Message('Message content!'));
     return $item;
 }
Пример #2
0
 /**
  *
  */
 public function testSendWithValidItemsButNeededFilter()
 {
     $creditUsedPerOneSMS = 7;
     $obj = new SMS($this->makeSMSAPIMock("SUCCESS:2:{$creditUsedPerOneSMS}"));
     $obj->getAdapter()->setEventManager($this->makeEventManagerMock());
     $item = new Struct\SMS();
     $item->setTo(new Struct\NumberTo(self::GERMANY, '987654test321'));
     $item->setFrom(new Struct\NumberFrom(self::GERMANY, '123456test789'));
     $item->setMessage(new Struct\Message('My message'));
     $coll = $this->makeSMSCollection();
     $coll->attach($item);
     $actual = $obj->send($coll);
     $this->assertEquals($creditUsedPerOneSMS * $coll->count(), $actual->getCreditUsed());
 }
Пример #3
0
 /**
  * @param Struct\SMS $item
  * @return string
  */
 protected function prepareUrl(Struct\SMS $item)
 {
     $config = $this->getServiceLocator()->get('Config');
     $format = "%s?username=%s&password=%s&to=%s&message=%s";
     return sprintf($format, $config['smsapi']['url'], urlencode($config['smsapi']['username']), urlencode($config['smsapi']['password']), urlencode($item->getTo()->getNumber()), urlencode($item->getMessage()->getContent()));
 }
Пример #4
0
 /**
  * @param Struct\SMS $item
  * @return bool
  */
 public function isItemValid(Struct\SMS $item)
 {
     $isValid = $this->getInputFilter()->getInputFilter()->setData($item->toArray())->setValidationGroup(InputFilterInterface::VALIDATE_ALL)->isValid();
     $item->fromArray($this->getInputFilter()->getInputFilter()->getValues());
     return $isValid;
 }
Пример #5
0
 /**
  * @param Struct\SMS $item
  * @return string
  */
 protected function prepareUrl(Struct\SMS $item)
 {
     $config = $this->serviceLocator->get('Config');
     $format = "%s?account=%s&login=%s&password=%s&from=%s&to=%s&message=%s&contentType=application/json";
     return sprintf($format, $config['ovh']['url'], $config['ovh']['account'], $config['ovh']['username'], $config['ovh']['password'], urlencode($item->getFrom()->getNumber()), urlencode($item->getTo()->getNumber()), urlencode($item->getMessage()->getContent()));
 }