Evo Voice

<back to all web services

SendMessage

Requires Authentication
Required role:User
The following routes are available for this service:
POST/sessions/{sessionId}/messages
All Verbs/messages
<?php namespace dtos;

use DateTime;
use Exception;
use DateInterval;
use JsonSerializable;
use ServiceStack\{IReturn,IReturnVoid,IGet,IPost,IPut,IDelete,IPatch,IMeta,IHasSessionId,IHasBearerToken,IHasVersion};
use ServiceStack\{ICrud,ICreateDb,IUpdateDb,IPatchDb,IDeleteDb,ISaveDb,AuditBase,QueryDb,QueryDb2,QueryData,QueryData2,QueryResponse};
use ServiceStack\{ResponseStatus,ResponseError,EmptyResponse,IdResponse,ArrayList,KeyValuePair2,StringResponse,StringsResponse,Tuple2,Tuple3,ByteArray};
use ServiceStack\{JsonConverters,Returns,TypeContext};


enum MessageDirections : string
{
    case Incoming = 'Incoming';
    case Outgoing = 'Outgoing';
}

class MessageInfo implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $id=null,
        /** @var string|null */
        public ?string $accountId=null,
        /** @var string|null */
        public ?string $customerId=null,
        /** @var string|null */
        public ?string $endpointId=null,
        /** @var string|null */
        public ?string $endpointDisplayName=null,
        /** @var string|null */
        public ?string $date=null,
        /** @var MessageDirections|null */
        public ?MessageDirections $direction=null,
        /** @var string|null */
        public ?string $otherAddress=null,
        /** @var string|null */
        public ?string $sender=null,
        /** @var string|null */
        public ?string $text=null,
        /** @var bool|null */
        public ?bool $isUnread=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['accountId'])) $this->accountId = $o['accountId'];
        if (isset($o['customerId'])) $this->customerId = $o['customerId'];
        if (isset($o['endpointId'])) $this->endpointId = $o['endpointId'];
        if (isset($o['endpointDisplayName'])) $this->endpointDisplayName = $o['endpointDisplayName'];
        if (isset($o['date'])) $this->date = $o['date'];
        if (isset($o['direction'])) $this->direction = JsonConverters::from('MessageDirections', $o['direction']);
        if (isset($o['otherAddress'])) $this->otherAddress = $o['otherAddress'];
        if (isset($o['sender'])) $this->sender = $o['sender'];
        if (isset($o['text'])) $this->text = $o['text'];
        if (isset($o['isUnread'])) $this->isUnread = $o['isUnread'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->accountId)) $o['accountId'] = $this->accountId;
        if (isset($this->customerId)) $o['customerId'] = $this->customerId;
        if (isset($this->endpointId)) $o['endpointId'] = $this->endpointId;
        if (isset($this->endpointDisplayName)) $o['endpointDisplayName'] = $this->endpointDisplayName;
        if (isset($this->date)) $o['date'] = $this->date;
        if (isset($this->direction)) $o['direction'] = JsonConverters::to('MessageDirections', $this->direction);
        if (isset($this->otherAddress)) $o['otherAddress'] = $this->otherAddress;
        if (isset($this->sender)) $o['sender'] = $this->sender;
        if (isset($this->text)) $o['text'] = $this->text;
        if (isset($this->isUnread)) $o['isUnread'] = $this->isUnread;
        return empty($o) ? new class(){} : $o;
    }
}

class SendMessage implements JsonSerializable
{
    public function __construct(
        /** @description The ID of the session you want to post a message to. Specify either this or EndpointId+ToAddress */
        // @ApiMember(Description="The ID of the session you want to post a message to. Specify either this or EndpointId+ToAddress")
        /** @var string|null */
        public ?string $sessionId=null,

        /** @description The ID of the endpoint you want to post a message to. Typically the ID of a phone number endpoint. Not used if SessionId is specified */
        // @ApiMember(Description="The ID of the endpoint you want to post a message to. Typically the ID of a phone number endpoint. Not used if SessionId is specified")
        /** @var string|null */
        public ?string $endpointId=null,

        /** @description The address of the party you want to send a message to, e.g. +15556667777. Not used if SessionId is specified */
        // @ApiMember(Description="The address of the party you want to send a message to, e.g. +15556667777. Not used if SessionId is specified")
        /** @var string|null */
        public ?string $toAddress=null,

        /** @description The body of the message */
        // @ApiMember(Description="The body of the message")
        /** @var string|null */
        public ?string $body=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['sessionId'])) $this->sessionId = $o['sessionId'];
        if (isset($o['endpointId'])) $this->endpointId = $o['endpointId'];
        if (isset($o['toAddress'])) $this->toAddress = $o['toAddress'];
        if (isset($o['body'])) $this->body = $o['body'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->sessionId)) $o['sessionId'] = $this->sessionId;
        if (isset($this->endpointId)) $o['endpointId'] = $this->endpointId;
        if (isset($this->toAddress)) $o['toAddress'] = $this->toAddress;
        if (isset($this->body)) $o['body'] = $this->body;
        return empty($o) ? new class(){} : $o;
    }
}

PHP SendMessage DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv

HTTP + CSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /sessions/{sessionId}/messages HTTP/1.1 
Host: team.evovoice.io 
Accept: text/csv
Content-Type: text/csv
Content-Length: length

{"sessionId":"String","endpointId":"String","toAddress":"String","body":"String"}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"id":"String","accountId":"String","customerId":"String","endpointId":"String","endpointDisplayName":"String","date":"String","direction":"Incoming","otherAddress":"String","sender":"String","text":"String","isUnread":false}