public function testFromArray() { $str = ' { "DeliveryInfoList": { "DeliveryInfo": [ { "Id":"msg0", "Address":"+15555555992", "DeliveryStatus":"DeliveredToTerminal" } ], "ResourceUrl":"https://api.att.com/sms/v3/messaging/outbox/123" } } '; $arr = json_decode($str, true); $r = DeliveryStatus::fromArray($arr); $this->assertEquals($r->getResourceUrl(), 'https://api.att.com/sms/v3/messaging/outbox/123'); $di = $r->getDeliveryInfoList()[0]; $this->assertEquals($di->getId(), 'msg0'); $this->assertEquals($di->getAddress(), '+15555555992'); $this->assertEquals($di->getDeliveryStatus(), 'DeliveredToTerminal'); }
/** * Sends a request to the API for getting SMS Delivery status. * * @param string $smsId SMS id for which to get delivery status. * * @return SMSStatusResponse API response. * @throws ServiceException if API request was not successful. */ public function getSMSDeliveryStatus($smsId, $raw_response = false) { $encodedId = urlencode($smsId); $endpoint = $this->getFqdn() . '/sms/v3/messaging/outbox/' . $encodedId; $req = new RESTFulRequest($endpoint); $result = $req->setAuthorizationHeader($this->getToken())->setHeader('Accept', 'application/json')->setHeader('Content-Type', 'application/x-www-form-urlencoded')->sendHttpGet(); // Handle the flag to return json. if ($raw_response) { $body = Service::parseApiResposeBody($result); // Note: This could throw ServiceExeption return $body; } $arr = Service::parseJson($result); return DeliveryStatus::fromArray($arr); }
/** * Sends a request to the API for getting SMS Delivery status. * * @param string $smsId SMS id for which to get delivery status. * * @return SMSStatusResponse API response. * @throws ServiceException if API request was not successful. */ public function getSMSDeliveryStatus($smsId) { $encodedId = urlencode($smsId); $endpoint = $this->getFqdn() . '/sms/v3/messaging/outbox/' . $encodedId; $req = new RESTFulRequest($endpoint); $result = $req->setAuthorizationHeader($this->getToken())->setHeader('Accept', 'application/json')->setHeader('Content-Type', 'application/x-www-form-urlencoded')->sendHttpGet(); $arr = Service::parseJson($result); return DeliveryStatus::fromArray($arr); }