SimpleSoftwareIO\SMS\Drivers\ZenviaSMS::checkMessages PHP Method

checkMessages() public method

Checks the server for messages and returns their results.
public checkMessages ( array $options = [] ) : array
$options array
return array
    public function checkMessages(array $options = [])
    {
        $this->buildCall('/received/list');
        $this->buildBody($options);
        $jsonResponse = json_decode($this->postRequest()->getBody()->getContents());
        if (!isset($jsonResponse->receivedResponse)) {
            throw new \Exception('Invalid response from API. Missing mandatory object.');
        }
        $rawMessages = $jsonResponse->receivedResponse;
        if ($rawMessages->statusCode !== '00') {
            throw new \Exception('Unable to request from API. Status Code: ' . $rawMessages->statusCode . ' - ' . $rawMessages->detailDescription . ' (' . $rawMessages->detailCode . ')');
        }
        if ($rawMessages->detailCode === '300') {
            return $this->makeMessages($rawMessages->receivedMessages);
        }
        return [];
    }