Trendsic Platform Service

<back to all web services

DocumentSearchRequest

Requires Authentication
Requires any of the roles:Agent, Administrator
The following routes are available for this service:
POST,OPTIONS/v1/DocumentSearch
<?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 LineSearchResult implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $LineText=null,
        /** @var int */
        public int $PageNo=0,
        /** @var int */
        public int $PageLineNo=0,
        /** @var int */
        public int $DocLineNo=0,
        /** @var float */
        public float $BoxTop=0.0,
        /** @var float */
        public float $BoxLeft=0.0,
        /** @var float */
        public float $BoxWidth=0.0,
        /** @var float */
        public float $BoxHeight=0.0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['LineText'])) $this->LineText = $o['LineText'];
        if (isset($o['PageNo'])) $this->PageNo = $o['PageNo'];
        if (isset($o['PageLineNo'])) $this->PageLineNo = $o['PageLineNo'];
        if (isset($o['DocLineNo'])) $this->DocLineNo = $o['DocLineNo'];
        if (isset($o['BoxTop'])) $this->BoxTop = $o['BoxTop'];
        if (isset($o['BoxLeft'])) $this->BoxLeft = $o['BoxLeft'];
        if (isset($o['BoxWidth'])) $this->BoxWidth = $o['BoxWidth'];
        if (isset($o['BoxHeight'])) $this->BoxHeight = $o['BoxHeight'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->LineText)) $o['LineText'] = $this->LineText;
        if (isset($this->PageNo)) $o['PageNo'] = $this->PageNo;
        if (isset($this->PageLineNo)) $o['PageLineNo'] = $this->PageLineNo;
        if (isset($this->DocLineNo)) $o['DocLineNo'] = $this->DocLineNo;
        if (isset($this->BoxTop)) $o['BoxTop'] = $this->BoxTop;
        if (isset($this->BoxLeft)) $o['BoxLeft'] = $this->BoxLeft;
        if (isset($this->BoxWidth)) $o['BoxWidth'] = $this->BoxWidth;
        if (isset($this->BoxHeight)) $o['BoxHeight'] = $this->BoxHeight;
        return empty($o) ? new class(){} : $o;
    }
}

class DocumentSearchResult implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $AttachmentId='',
        /** @var DateTime */
        public DateTime $DateAdded=new DateTime(),
        /** @var string|null */
        public ?string $AttachmentName=null,
        /** @var string|null */
        public ?string $Description=null,
        /** @var string|null */
        public ?string $DocumentType=null,
        /** @var string|null */
        public ?string $DocumentGroup=null,
        /** @var string|null */
        public ?string $DropboxTableName=null,
        /** @var int */
        public int $DropboxRecordId=0,
        /** @var string|null */
        public ?string $AttachmentTableName=null,
        /** @var string|null */
        public ?string $AttachmentFieldName=null,
        /** @var int */
        public int $AttachmentRecordId=0,
        /** @var string|null */
        public ?string $FilePath=null,
        /** @var string|null */
        public ?string $OCRSource=null,
        /** @var string|null */
        public ?string $OCRResult=null,
        /** @var array<LineSearchResult>|null */
        public ?array $Lines=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['AttachmentId'])) $this->AttachmentId = $o['AttachmentId'];
        if (isset($o['DateAdded'])) $this->DateAdded = JsonConverters::from('DateTime', $o['DateAdded']);
        if (isset($o['AttachmentName'])) $this->AttachmentName = $o['AttachmentName'];
        if (isset($o['Description'])) $this->Description = $o['Description'];
        if (isset($o['DocumentType'])) $this->DocumentType = $o['DocumentType'];
        if (isset($o['DocumentGroup'])) $this->DocumentGroup = $o['DocumentGroup'];
        if (isset($o['DropboxTableName'])) $this->DropboxTableName = $o['DropboxTableName'];
        if (isset($o['DropboxRecordId'])) $this->DropboxRecordId = $o['DropboxRecordId'];
        if (isset($o['AttachmentTableName'])) $this->AttachmentTableName = $o['AttachmentTableName'];
        if (isset($o['AttachmentFieldName'])) $this->AttachmentFieldName = $o['AttachmentFieldName'];
        if (isset($o['AttachmentRecordId'])) $this->AttachmentRecordId = $o['AttachmentRecordId'];
        if (isset($o['FilePath'])) $this->FilePath = $o['FilePath'];
        if (isset($o['OCRSource'])) $this->OCRSource = $o['OCRSource'];
        if (isset($o['OCRResult'])) $this->OCRResult = $o['OCRResult'];
        if (isset($o['Lines'])) $this->Lines = JsonConverters::fromArray('LineSearchResult', $o['Lines']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->AttachmentId)) $o['AttachmentId'] = $this->AttachmentId;
        if (isset($this->DateAdded)) $o['DateAdded'] = JsonConverters::to('DateTime', $this->DateAdded);
        if (isset($this->AttachmentName)) $o['AttachmentName'] = $this->AttachmentName;
        if (isset($this->Description)) $o['Description'] = $this->Description;
        if (isset($this->DocumentType)) $o['DocumentType'] = $this->DocumentType;
        if (isset($this->DocumentGroup)) $o['DocumentGroup'] = $this->DocumentGroup;
        if (isset($this->DropboxTableName)) $o['DropboxTableName'] = $this->DropboxTableName;
        if (isset($this->DropboxRecordId)) $o['DropboxRecordId'] = $this->DropboxRecordId;
        if (isset($this->AttachmentTableName)) $o['AttachmentTableName'] = $this->AttachmentTableName;
        if (isset($this->AttachmentFieldName)) $o['AttachmentFieldName'] = $this->AttachmentFieldName;
        if (isset($this->AttachmentRecordId)) $o['AttachmentRecordId'] = $this->AttachmentRecordId;
        if (isset($this->FilePath)) $o['FilePath'] = $this->FilePath;
        if (isset($this->OCRSource)) $o['OCRSource'] = $this->OCRSource;
        if (isset($this->OCRResult)) $o['OCRResult'] = $this->OCRResult;
        if (isset($this->Lines)) $o['Lines'] = JsonConverters::toArray('LineSearchResult', $this->Lines);
        return empty($o) ? new class(){} : $o;
    }
}

class DocumentSearchResponse implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $DocumentSearchCount=0,
        /** @var array<DocumentSearchResult>|null */
        public ?array $DocumentSearchResults=null,
        /** @var ResponseStatus|null */
        public ?ResponseStatus $ResponseStatus=null
    ) {
    }

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

enum DocumentSearchMode : int
{
    case Exact = 1;
    case Contains = 2;
    case StartsWith = 3;
    case EndsWith = 4;
}

enum DocumentTermMode : int
{
    case All = 1;
    case Any = 2;
}

class DocumentSearchRequest implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $searchTerms=null,
        /** @var DocumentSearchMode|null */
        public ?DocumentSearchMode $searchMode=null,
        /** @var DocumentTermMode|null */
        public ?DocumentTermMode $termMode=null,
        /** @var string */
        public string $userId=''
    ) {
    }

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

PHP DocumentSearchRequest DTOs

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

HTTP + XML

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

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

<DocumentSearchRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
  <searchMode>Exact</searchMode>
  <searchTerms>String</searchTerms>
  <termMode>All</termMode>
  <userId>00000000-0000-0000-0000-000000000000</userId>
</DocumentSearchRequest>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<DocumentSearchResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
  <DocumentSearchCount>0</DocumentSearchCount>
  <DocumentSearchResults>
    <DocumentSearchResult>
      <AttachmentFieldName>String</AttachmentFieldName>
      <AttachmentId>00000000-0000-0000-0000-000000000000</AttachmentId>
      <AttachmentName>String</AttachmentName>
      <AttachmentRecordId>0</AttachmentRecordId>
      <AttachmentTableName>String</AttachmentTableName>
      <DateAdded>0001-01-01T00:00:00</DateAdded>
      <Description>String</Description>
      <DocumentGroup>String</DocumentGroup>
      <DocumentType>String</DocumentType>
      <DropboxRecordId>0</DropboxRecordId>
      <DropboxTableName>String</DropboxTableName>
      <FilePath>String</FilePath>
      <Lines>
        <LineSearchResult>
          <BoxHeight>0</BoxHeight>
          <BoxLeft>0</BoxLeft>
          <BoxTop>0</BoxTop>
          <BoxWidth>0</BoxWidth>
          <DocLineNo>0</DocLineNo>
          <LineText>String</LineText>
          <PageLineNo>0</PageLineNo>
          <PageNo>0</PageNo>
        </LineSearchResult>
      </Lines>
      <OCRResult>String</OCRResult>
      <OCRSource>String</OCRSource>
    </DocumentSearchResult>
  </DocumentSearchResults>
  <ResponseStatus xmlns:d2p1="http://schemas.servicestack.net/types">
    <d2p1:ErrorCode>String</d2p1:ErrorCode>
    <d2p1:Message>String</d2p1:Message>
    <d2p1:StackTrace>String</d2p1:StackTrace>
    <d2p1:Errors>
      <d2p1:ResponseError>
        <d2p1:ErrorCode>String</d2p1:ErrorCode>
        <d2p1:FieldName>String</d2p1:FieldName>
        <d2p1:Message>String</d2p1:Message>
        <d2p1:Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
          <d5p1:KeyValueOfstringstring>
            <d5p1:Key>String</d5p1:Key>
            <d5p1:Value>String</d5p1:Value>
          </d5p1:KeyValueOfstringstring>
        </d2p1:Meta>
      </d2p1:ResponseError>
    </d2p1:Errors>
    <d2p1:Meta xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
      <d3p1:KeyValueOfstringstring>
        <d3p1:Key>String</d3p1:Key>
        <d3p1:Value>String</d3p1:Value>
      </d3p1:KeyValueOfstringstring>
    </d2p1:Meta>
  </ResponseStatus>
</DocumentSearchResponse>