Trendsic Platform Service

<back to all web services

ReportRunRequest

Requires Authentication
Requires any of the roles:Agent, Administrator
The following routes are available for this service:
POST,OPTIONS/v1/report/run
<?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 ReportMeasure implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $FieldCode=null,
        /** @var string|null */
        public ?string $Agg=null
    ) {
    }

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

class ReportSort implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $FieldCode=null,
        /** @var string|null */
        public ?string $Dir=null
    ) {
    }

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

class ReportDefinition implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $DatasetCode=null,
        /** @var array<string>|null */
        public ?array $Dimensions=null,
        /** @var array<ReportMeasure>|null */
        public ?array $Measures=null,
        /** @var array<string>|null */
        public ?array $Joins=null,
        /** @var string|null */
        public ?string $Filters=null,
        /** @var array<ReportSort>|null */
        public ?array $Sorts=null,
        /** @var int */
        public int $Limit=0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['DatasetCode'])) $this->DatasetCode = $o['DatasetCode'];
        if (isset($o['Dimensions'])) $this->Dimensions = JsonConverters::fromArray('string', $o['Dimensions']);
        if (isset($o['Measures'])) $this->Measures = JsonConverters::fromArray('ReportMeasure', $o['Measures']);
        if (isset($o['Joins'])) $this->Joins = JsonConverters::fromArray('string', $o['Joins']);
        if (isset($o['Filters'])) $this->Filters = $o['Filters'];
        if (isset($o['Sorts'])) $this->Sorts = JsonConverters::fromArray('ReportSort', $o['Sorts']);
        if (isset($o['Limit'])) $this->Limit = $o['Limit'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->DatasetCode)) $o['DatasetCode'] = $this->DatasetCode;
        if (isset($this->Dimensions)) $o['Dimensions'] = JsonConverters::toArray('string', $this->Dimensions);
        if (isset($this->Measures)) $o['Measures'] = JsonConverters::toArray('ReportMeasure', $this->Measures);
        if (isset($this->Joins)) $o['Joins'] = JsonConverters::toArray('string', $this->Joins);
        if (isset($this->Filters)) $o['Filters'] = $this->Filters;
        if (isset($this->Sorts)) $o['Sorts'] = JsonConverters::toArray('ReportSort', $this->Sorts);
        if (isset($this->Limit)) $o['Limit'] = $this->Limit;
        return empty($o) ? new class(){} : $o;
    }
}

class ReportColumnMeta implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $Code=null,
        /** @var string|null */
        public ?string $Name=null,
        /** @var string|null */
        public ?string $DataType=null,
        /** @var string|null */
        public ?string $FieldKind=null,
        /** @var string|null */
        public ?string $Agg=null
    ) {
    }

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

class ReportRunResult implements JsonSerializable
{
    public function __construct(
        /** @var array<ReportColumnMeta>|null */
        public ?array $Columns=null,
        /** @var array<array<string,Object>>|null */
        public ?array $Rows=null,
        /** @var int */
        public int $RowCount=0,
        /** @var bool|null */
        public ?bool $Truncated=null,
        /** @var array<string>|null */
        public ?array $Notes=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Columns'])) $this->Columns = JsonConverters::fromArray('ReportColumnMeta', $o['Columns']);
        if (isset($o['Rows'])) $this->Rows = JsonConverters::fromArray('Dictionary<String,Object>', $o['Rows']);
        if (isset($o['RowCount'])) $this->RowCount = $o['RowCount'];
        if (isset($o['Truncated'])) $this->Truncated = $o['Truncated'];
        if (isset($o['Notes'])) $this->Notes = JsonConverters::fromArray('string', $o['Notes']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Columns)) $o['Columns'] = JsonConverters::toArray('ReportColumnMeta', $this->Columns);
        if (isset($this->Rows)) $o['Rows'] = JsonConverters::toArray('Dictionary<String,Object>', $this->Rows);
        if (isset($this->RowCount)) $o['RowCount'] = $this->RowCount;
        if (isset($this->Truncated)) $o['Truncated'] = $this->Truncated;
        if (isset($this->Notes)) $o['Notes'] = JsonConverters::toArray('string', $this->Notes);
        return empty($o) ? new class(){} : $o;
    }
}

class ReportRunResponse implements JsonSerializable
{
    public function __construct(
        /** @var ResponseStatus|null */
        public ?ResponseStatus $ResponseStatus=null,
        /** @var ReportRunResult|null */
        public ?ReportRunResult $Result=null
    ) {
    }

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

class ReportRunRequest extends ReportDefinition implements JsonSerializable
{
    /**
     * @param string|null $DatasetCode
     * @param array<string>|null $Dimensions
     * @param array<ReportMeasure>|null $Measures
     * @param array<string>|null $Joins
     * @param string|null $Filters
     * @param array<ReportSort>|null $Sorts
     * @param int $Limit
     */
    public function __construct(
        ?string $DatasetCode=null,
        ?array $Dimensions=null,
        ?array $Measures=null,
        ?array $Joins=null,
        ?string $Filters=null,
        ?array $Sorts=null,
        int $Limit=0
    ) {
        parent::__construct($DatasetCode,$Dimensions,$Measures,$Joins,$Filters,$Sorts,$Limit);
    }

    /** @throws Exception */
    public function fromMap($o): void {
        parent::fromMap($o);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        return empty($o) ? new class(){} : $o;
    }
}

PHP ReportRunRequest 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/report/run HTTP/1.1 
Host: api.dev.dynamics.trendsic.com 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<ReportRunRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
  <DatasetCode>String</DatasetCode>
  <Dimensions xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:string>String</d2p1:string>
  </Dimensions>
  <Filters>String</Filters>
  <Joins xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:string>String</d2p1:string>
  </Joins>
  <Limit>0</Limit>
  <Measures>
    <ReportMeasure>
      <Agg>String</Agg>
      <FieldCode>String</FieldCode>
    </ReportMeasure>
  </Measures>
  <Sorts>
    <ReportSort>
      <Dir>String</Dir>
      <FieldCode>String</FieldCode>
    </ReportSort>
  </Sorts>
</ReportRunRequest>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<ReportRunResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
  <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>
  <Result>
    <Columns>
      <ReportColumnMeta>
        <Agg>String</Agg>
        <Code>String</Code>
        <DataType>String</DataType>
        <FieldKind>String</FieldKind>
        <Name>String</Name>
      </ReportColumnMeta>
    </Columns>
    <Notes xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
      <d3p1:string>String</d3p1:string>
    </Notes>
    <RowCount>0</RowCount>
    <Rows xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
      <d3p1:ArrayOfKeyValueOfstringanyType>
        <d3p1:KeyValueOfstringanyType>
          <d3p1:Key>String</d3p1:Key>
          <d3p1:Value />
        </d3p1:KeyValueOfstringanyType>
      </d3p1:ArrayOfKeyValueOfstringanyType>
    </Rows>
    <Truncated>false</Truncated>
  </Result>
</ReportRunResponse>