Required role: | User |
POST | /app/files |
---|
<?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 EntityInfo implements JsonSerializable
{
public function __construct(
/** @description The ID of the object */
// @ApiMember(Description="The ID of the object")
/** @var string|null */
public ?string $id=null,
/** @description The date the object was created */
// @ApiMember(Description="The date the object was created")
/** @var string|null */
public ?string $dateCreated=null,
/** @description The date the object was last modified */
// @ApiMember(Description="The date the object was last modified")
/** @var string|null */
public ?string $dateLastModified=null,
/** @description The user that created this object */
// @ApiMember(Description="The user that created this object")
/** @var string|null */
public ?string $createdBy=null,
/** @description The user that last modified this object */
// @ApiMember(Description="The user that last modified this object")
/** @var string|null */
public ?string $lastModifiedBy=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['dateCreated'])) $this->dateCreated = $o['dateCreated'];
if (isset($o['dateLastModified'])) $this->dateLastModified = $o['dateLastModified'];
if (isset($o['createdBy'])) $this->createdBy = $o['createdBy'];
if (isset($o['lastModifiedBy'])) $this->lastModifiedBy = $o['lastModifiedBy'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->dateCreated)) $o['dateCreated'] = $this->dateCreated;
if (isset($this->dateLastModified)) $o['dateLastModified'] = $this->dateLastModified;
if (isset($this->createdBy)) $o['createdBy'] = $this->createdBy;
if (isset($this->lastModifiedBy)) $o['lastModifiedBy'] = $this->lastModifiedBy;
return empty($o) ? new class(){} : $o;
}
}
enum FileTypes : string
{
case Upload = 'Upload';
case VoiceMessage = 'VoiceMessage';
case CallRecording = 'CallRecording';
case Fax = 'Fax';
case Attachment = 'Attachment';
case FaxOutgoing = 'FaxOutgoing';
}
class CustomerBreadcrumb implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $id=null,
/** @var string|null */
public ?string $name=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['name'])) $this->name = $o['name'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->name)) $o['name'] = $this->name;
return empty($o) ? new class(){} : $o;
}
}
class FileInfo extends EntityInfo implements JsonSerializable
{
/**
* @param string|null $id
* @param string|null $dateCreated
* @param string|null $dateLastModified
* @param string|null $createdBy
* @param string|null $lastModifiedBy
*/
public function __construct(
?string $id=null,
?string $dateCreated=null,
?string $dateLastModified=null,
?string $createdBy=null,
?string $lastModifiedBy=null,
/** @description The type of file this is */
// @ApiMember(Description="The type of file this is")
/** @var FileTypes|null */
public ?FileTypes $type=null,
/** @description The account ID this file is associated with */
// @ApiMember(Description="The account ID this file is associated with")
/** @var string|null */
public ?string $accountId=null,
/** @description The name of the account this file is associated with */
// @ApiMember(Description="The name of the account this file is associated with")
/** @var string|null */
public ?string $accountName=null,
/** @description The ID of the customer this file is associated with */
// @ApiMember(Description="The ID of the customer this file is associated with")
/** @var string|null */
public ?string $customerId=null,
/** @description The name of the customer this file is associated with */
// @ApiMember(Description="The name of the customer this file is associated with")
/** @var string|null */
public ?string $customerName=null,
/** @description The breadcrumb to the customer for this file */
// @ApiMember(Description="The breadcrumb to the customer for this file")
/** @var array<CustomerBreadcrumb>|null */
public ?array $customerBreadcrumb=null,
/** @description The ID of the user this file is assocaited with */
// @ApiMember(Description="The ID of the user this file is assocaited with")
/** @var string|null */
public ?string $userId=null,
/** @description The name of the user this file is associated with */
// @ApiMember(Description="The name of the user this file is associated with")
/** @var string|null */
public ?string $userName=null,
/** @description The original file name for the file */
// @ApiMember(Description="The original file name for the file")
/** @var string|null */
public ?string $fileName=null,
/** @description The URI of the file */
// @ApiMember(Description="The URI of the file")
/** @var string|null */
public ?string $uri=null,
/** @description The Content type of the file */
// @ApiMember(Description="The Content type of the file")
/** @var string|null */
public ?string $contentType=null,
/** @description The size of the file */
// @ApiMember(Description="The size of the file")
/** @var int */
public int $contentLength=0,
/** @description The Twilio ID of the recording */
// @ApiMember(Description="The Twilio ID of the recording")
/** @var string|null */
public ?string $recordingSid=null,
/** @description The duration of the recording in seconds */
// @ApiMember(Description="The duration of the recording in seconds")
/** @var int */
public int $recordingDuration=0,
/** @description Who is the recording from? */
// @ApiMember(Description="Who is the recording from?")
/** @var string|null */
public ?string $recordingFrom=null,
/** @description Transcription (if available) */
// @ApiMember(Description="Transcription (if available)")
/** @var string|null */
public ?string $transcription=null,
/** @description From Address (e.g. caller ID) for incoming calls */
// @ApiMember(Description="From Address (e.g. caller ID) for incoming calls")
/** @var string|null */
public ?string $fromAddress=null,
/** @description To Address (e.g. dialed number) for outgoing calls */
// @ApiMember(Description="To Address (e.g. dialed number) for outgoing calls")
/** @var string|null */
public ?string $toAddress=null,
/** @description The AI transcription for this call */
// @ApiMember(Description="The AI transcription for this call")
/** @var string|null */
public ?string $aiTranscription=null
) {
parent::__construct($id,$dateCreated,$dateLastModified,$createdBy,$lastModifiedBy);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['type'])) $this->type = JsonConverters::from('FileTypes', $o['type']);
if (isset($o['accountId'])) $this->accountId = $o['accountId'];
if (isset($o['accountName'])) $this->accountName = $o['accountName'];
if (isset($o['customerId'])) $this->customerId = $o['customerId'];
if (isset($o['customerName'])) $this->customerName = $o['customerName'];
if (isset($o['customerBreadcrumb'])) $this->customerBreadcrumb = JsonConverters::fromArray('CustomerBreadcrumb', $o['customerBreadcrumb']);
if (isset($o['userId'])) $this->userId = $o['userId'];
if (isset($o['userName'])) $this->userName = $o['userName'];
if (isset($o['fileName'])) $this->fileName = $o['fileName'];
if (isset($o['uri'])) $this->uri = $o['uri'];
if (isset($o['contentType'])) $this->contentType = $o['contentType'];
if (isset($o['contentLength'])) $this->contentLength = $o['contentLength'];
if (isset($o['recordingSid'])) $this->recordingSid = $o['recordingSid'];
if (isset($o['recordingDuration'])) $this->recordingDuration = $o['recordingDuration'];
if (isset($o['recordingFrom'])) $this->recordingFrom = $o['recordingFrom'];
if (isset($o['transcription'])) $this->transcription = $o['transcription'];
if (isset($o['fromAddress'])) $this->fromAddress = $o['fromAddress'];
if (isset($o['toAddress'])) $this->toAddress = $o['toAddress'];
if (isset($o['aiTranscription'])) $this->aiTranscription = $o['aiTranscription'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->type)) $o['type'] = JsonConverters::to('FileTypes', $this->type);
if (isset($this->accountId)) $o['accountId'] = $this->accountId;
if (isset($this->accountName)) $o['accountName'] = $this->accountName;
if (isset($this->customerId)) $o['customerId'] = $this->customerId;
if (isset($this->customerName)) $o['customerName'] = $this->customerName;
if (isset($this->customerBreadcrumb)) $o['customerBreadcrumb'] = JsonConverters::toArray('CustomerBreadcrumb', $this->customerBreadcrumb);
if (isset($this->userId)) $o['userId'] = $this->userId;
if (isset($this->userName)) $o['userName'] = $this->userName;
if (isset($this->fileName)) $o['fileName'] = $this->fileName;
if (isset($this->uri)) $o['uri'] = $this->uri;
if (isset($this->contentType)) $o['contentType'] = $this->contentType;
if (isset($this->contentLength)) $o['contentLength'] = $this->contentLength;
if (isset($this->recordingSid)) $o['recordingSid'] = $this->recordingSid;
if (isset($this->recordingDuration)) $o['recordingDuration'] = $this->recordingDuration;
if (isset($this->recordingFrom)) $o['recordingFrom'] = $this->recordingFrom;
if (isset($this->transcription)) $o['transcription'] = $this->transcription;
if (isset($this->fromAddress)) $o['fromAddress'] = $this->fromAddress;
if (isset($this->toAddress)) $o['toAddress'] = $this->toAddress;
if (isset($this->aiTranscription)) $o['aiTranscription'] = $this->aiTranscription;
return empty($o) ? new class(){} : $o;
}
}
/** @description Create a new file and return the info */
// @Api(Description="Create a new file and return the info")
class UploadFile implements IPost, JsonSerializable
{
public function __construct(
/** @description The file data */
// @ApiMember(Description="The file data")
/** @var ByteArray|null */
public ?ByteArray $data=null,
/** @description The file name */
// @ApiMember(Description="The file name")
/** @var string|null */
public ?string $fileName=null,
/** @description The file's content type */
// @ApiMember(Description="The file's content type")
/** @var string|null */
public ?string $contentType=null,
/** @description Convert the file to WAV to be safe? */
// @ApiMember(Description="Convert the file to WAV to be safe?")
/** @var bool|null */
public ?bool $convertToWav=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['data'])) $this->data = JsonConverters::from('ByteArray', $o['data']);
if (isset($o['fileName'])) $this->fileName = $o['fileName'];
if (isset($o['contentType'])) $this->contentType = $o['contentType'];
if (isset($o['convertToWav'])) $this->convertToWav = $o['convertToWav'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->data)) $o['data'] = JsonConverters::to('ByteArray', $this->data);
if (isset($this->fileName)) $o['fileName'] = $this->fileName;
if (isset($this->contentType)) $o['contentType'] = $this->contentType;
if (isset($this->convertToWav)) $o['convertToWav'] = $this->convertToWav;
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /app/files HTTP/1.1
Host: team.evovoice.io
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<UploadFile xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Voice.Api.App">
<ContentType>String</ContentType>
<ConvertToWav>false</ConvertToWav>
<Data>AA==</Data>
<FileName>String</FileName>
</UploadFile>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <FileInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Voice.Api.Files"> <CreatedBy xmlns="http://schemas.datacontract.org/2004/07/Voice.Api">String</CreatedBy> <DateCreated xmlns="http://schemas.datacontract.org/2004/07/Voice.Api">String</DateCreated> <DateLastModified xmlns="http://schemas.datacontract.org/2004/07/Voice.Api">String</DateLastModified> <Id xmlns="http://schemas.datacontract.org/2004/07/Voice.Api">String</Id> <LastModifiedBy xmlns="http://schemas.datacontract.org/2004/07/Voice.Api">String</LastModifiedBy> <AITranscription>String</AITranscription> <AccountId>String</AccountId> <AccountName>String</AccountName> <ContentLength>0</ContentLength> <ContentType>String</ContentType> <CustomerBreadcrumb xmlns:d2p1="http://schemas.datacontract.org/2004/07/Voice.Api.Customers"> <d2p1:CustomerBreadcrumb> <d2p1:Id>String</d2p1:Id> <d2p1:Name>String</d2p1:Name> </d2p1:CustomerBreadcrumb> </CustomerBreadcrumb> <CustomerId>String</CustomerId> <CustomerName>String</CustomerName> <FileName>String</FileName> <FromAddress>String</FromAddress> <RecordingDuration>0</RecordingDuration> <RecordingFrom>String</RecordingFrom> <RecordingSid>String</RecordingSid> <ToAddress>String</ToAddress> <Transcription>String</Transcription> <Type>Upload</Type> <Uri>String</Uri> <UserId>String</UserId> <UserName>String</UserName> </FileInfo>