Trendsic Platform Service

<back to all web services

VirtualPhoneNumberRequest

Requires Authentication
Requires any of the roles:Agent, Administrator, Agent, Administrator
The following routes are available for this service:
GET,POST,OPTIONS/v1/VirtualPhoneNumber
<?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};


class VirtualPhoneNumber implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $Id='',
        /** @var string|null */
        public ?string $Phone=null,
        /** @var DateTime */
        public DateTime $DateCreated=new DateTime(),
        /** @var DateTime */
        public DateTime $DateCancelled=new DateTime()
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Id'])) $this->Id = $o['Id'];
        if (isset($o['Phone'])) $this->Phone = $o['Phone'];
        if (isset($o['DateCreated'])) $this->DateCreated = JsonConverters::from('DateTime', $o['DateCreated']);
        if (isset($o['DateCancelled'])) $this->DateCancelled = JsonConverters::from('DateTime', $o['DateCancelled']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Id)) $o['Id'] = $this->Id;
        if (isset($this->Phone)) $o['Phone'] = $this->Phone;
        if (isset($this->DateCreated)) $o['DateCreated'] = JsonConverters::to('DateTime', $this->DateCreated);
        if (isset($this->DateCancelled)) $o['DateCancelled'] = JsonConverters::to('DateTime', $this->DateCancelled);
        return empty($o) ? new class(){} : $o;
    }
}

class VirtualPhoneNumberResponse implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $UserId='',
        /** @var VirtualPhoneNumber|null */
        public ?VirtualPhoneNumber $VirtualPhoneNumber=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['UserId'])) $this->UserId = $o['UserId'];
        if (isset($o['VirtualPhoneNumber'])) $this->VirtualPhoneNumber = JsonConverters::from('VirtualPhoneNumber', $o['VirtualPhoneNumber']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->UserId)) $o['UserId'] = $this->UserId;
        if (isset($this->VirtualPhoneNumber)) $o['VirtualPhoneNumber'] = JsonConverters::to('VirtualPhoneNumber', $this->VirtualPhoneNumber);
        return empty($o) ? new class(){} : $o;
    }
}

class VirtualPhoneNumberRequest implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $UserId=''
    ) {
    }

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

PHP VirtualPhoneNumberRequest DTOs

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

To embed the response in a jsonp callback, append ?callback=myCallback

HTTP + JSON

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

POST /v1/VirtualPhoneNumber HTTP/1.1 
Host: api.dev.dynamics.trendsic.com 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"UserId":"00000000000000000000000000000000"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"UserId":"00000000000000000000000000000000","VirtualPhoneNumber":{"Id":"00000000000000000000000000000000","Phone":"String","DateCreated":"0001-01-01T00:00:00.0000000","DateCancelled":"0001-01-01T00:00:00.0000000"}}