Esempio n. 1
0
 public function __construct(array $data, $callbacks = array())
 {
     //add expected keys
     $this->expected = array_merge($this->expected, array('request_id', 'number', 'request_price', 'remaining_balance', 'callback_total_parts'));
     parent::__construct($data);
     foreach ($callbacks as $callback) {
         if (!$callback instanceof Callback) {
             throw new \InvalidArgumentException('callback must be of type: Nexmo\\Network\\Number\\Callback');
         }
         if ($callback->getId() !== $this->getId()) {
             throw new \InvalidArgumentException('callback id must match request id');
         }
     }
     $this->callbacks = $callbacks;
 }
Esempio n. 2
0
 public function __construct(array $data, Receipt $receipt = null)
 {
     $this->expected = array('status', 'message-id', 'to', 'message-price', 'network');
     //default value
     $data = array_merge(array('client-ref' => null, 'remaining-balance' => null), $data);
     $return = parent::__construct($data);
     //validate receipt
     if (!$receipt) {
         return $return;
     }
     if ($receipt->getId() != $this->getId()) {
         throw new \UnexpectedValueException('receipt id must match message id');
     }
     $this->receipt = $receipt;
     return $receipt;
 }
Esempio n. 3
0
 public function __construct(array $data)
 {
     $this->expected = array('message-count', 'messages');
     $return = parent::__construct($data);
     $this->count = $data['message-count'];
     if (count($data['messages']) != $data['message-count']) {
         throw new \RuntimeException('invalid message count');
     }
     foreach ($data['messages'] as $message) {
         if (0 != $message['status']) {
             $this->messages[] = new Error($message);
         } else {
             $this->messages[] = new Message($message);
         }
     }
     $this->data = $data;
     return $return;
 }