Trendsic Platform Service

<back to all web services

ActivityDataRequest

Requires Authentication
Requires any of the roles:Agent, Administrator
The following routes are available for this service:
GET,OPTIONS/v1/ActivityData/{AgentId}/{DateFrom}/{DateTo}
<?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 ActivityPlan implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $Id=0,
        /** @var int */
        public int $AgentId=0,
        /** @var int */
        public int $EventTypeId=0,
        /** @var int */
        public int $Goal=0,
        /** @var DateTime */
        public DateTime $DateFrom=new DateTime(),
        /** @var DateTime */
        public DateTime $DateTo=new DateTime(),
        /** @var DateTime */
        public DateTime $DateCreated=new DateTime(),
        /** @var int */
        public int $MthlyCashFlow=0,
        /** @var int */
        public int $YTDCashFlow=0,
        /** @var int */
        public int $Recruit=0,
        /** @var string|null */
        public ?string $EventTypeName=null,
        /** @var int */
        public int $Actual=0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Id'])) $this->Id = $o['Id'];
        if (isset($o['AgentId'])) $this->AgentId = $o['AgentId'];
        if (isset($o['EventTypeId'])) $this->EventTypeId = $o['EventTypeId'];
        if (isset($o['Goal'])) $this->Goal = $o['Goal'];
        if (isset($o['DateFrom'])) $this->DateFrom = JsonConverters::from('DateTime', $o['DateFrom']);
        if (isset($o['DateTo'])) $this->DateTo = JsonConverters::from('DateTime', $o['DateTo']);
        if (isset($o['DateCreated'])) $this->DateCreated = JsonConverters::from('DateTime', $o['DateCreated']);
        if (isset($o['MthlyCashFlow'])) $this->MthlyCashFlow = $o['MthlyCashFlow'];
        if (isset($o['YTDCashFlow'])) $this->YTDCashFlow = $o['YTDCashFlow'];
        if (isset($o['Recruit'])) $this->Recruit = $o['Recruit'];
        if (isset($o['EventTypeName'])) $this->EventTypeName = $o['EventTypeName'];
        if (isset($o['Actual'])) $this->Actual = $o['Actual'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Id)) $o['Id'] = $this->Id;
        if (isset($this->AgentId)) $o['AgentId'] = $this->AgentId;
        if (isset($this->EventTypeId)) $o['EventTypeId'] = $this->EventTypeId;
        if (isset($this->Goal)) $o['Goal'] = $this->Goal;
        if (isset($this->DateFrom)) $o['DateFrom'] = JsonConverters::to('DateTime', $this->DateFrom);
        if (isset($this->DateTo)) $o['DateTo'] = JsonConverters::to('DateTime', $this->DateTo);
        if (isset($this->DateCreated)) $o['DateCreated'] = JsonConverters::to('DateTime', $this->DateCreated);
        if (isset($this->MthlyCashFlow)) $o['MthlyCashFlow'] = $this->MthlyCashFlow;
        if (isset($this->YTDCashFlow)) $o['YTDCashFlow'] = $this->YTDCashFlow;
        if (isset($this->Recruit)) $o['Recruit'] = $this->Recruit;
        if (isset($this->EventTypeName)) $o['EventTypeName'] = $this->EventTypeName;
        if (isset($this->Actual)) $o['Actual'] = $this->Actual;
        return empty($o) ? new class(){} : $o;
    }
}

class ActivityPlanExtended implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $AppCount=0,
        /** @var int */
        public int $AvgFlow=0,
        /** @var int */
        public int $AvgTransfer=0,
        /** @var int */
        public int $AvgLife=0,
        /** @var float */
        public float $LifePerAnnuity=0.0,
        /** @var float */
        public float $FlowTransfer=0.0,
        /** @var float */
        public float $TransferRatio=0.0
    ) {
    }

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

class ActivityPlanResponse implements JsonSerializable
{
    public function __construct(
        /** @var ResponseStatus|null */
        public ?ResponseStatus $ResponseStatus=null,
        /** @var array<ActivityPlan>|null */
        public ?array $ActivityPlans=null,
        /** @var ActivityPlanExtended|null */
        public ?ActivityPlanExtended $ActivityData=null
    ) {
    }

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

class ActivityDataRequest implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $AgentId=0,
        /** @var DateTime */
        public DateTime $DateFrom=new DateTime(),
        /** @var DateTime */
        public DateTime $DateTo=new DateTime()
    ) {
    }

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

PHP ActivityDataRequest 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.

GET /v1/ActivityData/{AgentId}/{DateFrom}/{DateTo} HTTP/1.1 
Host: api.dev.dynamics.trendsic.com 
Accept: application/xml
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<ActivityPlanResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
  <ActivityData>
    <AppCount>0</AppCount>
    <AvgFlow>0</AvgFlow>
    <AvgLife>0</AvgLife>
    <AvgTransfer>0</AvgTransfer>
    <FlowTransfer>0</FlowTransfer>
    <LifePerAnnuity>0</LifePerAnnuity>
    <TransferRatio>0</TransferRatio>
  </ActivityData>
  <ActivityPlans>
    <ActivityPlan>
      <Actual>0</Actual>
      <AgentId>0</AgentId>
      <DateCreated>0001-01-01T00:00:00</DateCreated>
      <DateFrom>0001-01-01T00:00:00</DateFrom>
      <DateTo>0001-01-01T00:00:00</DateTo>
      <EventTypeId>0</EventTypeId>
      <EventTypeName>String</EventTypeName>
      <Goal>0</Goal>
      <Id>0</Id>
      <MthlyCashFlow>0</MthlyCashFlow>
      <Recruit>0</Recruit>
      <YTDCashFlow>0</YTDCashFlow>
    </ActivityPlan>
  </ActivityPlans>
  <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>
</ActivityPlanResponse>