Trendsic Platform Service

<back to all web services

CampaignRequest

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


// @Flags()
enum DeliveryChannel : int
{
    case None = 0;
    case Email = 1;
    case Sms = 2;
}

class Campaign implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $CampaignId=0,
        /** @var int */
        public int $CampaignTypeId=0,
        /** @var string|null */
        public ?string $CampaignName=null,
        /** @var int */
        public int $AgentID=0,
        /** @var string|null */
        public ?string $Subject=null,
        /** @var string|null */
        public ?string $Template=null,
        /** @var DateTime|null */
        public ?DateTime $DateCreated=null,
        /** @var DateTime|null */
        public ?DateTime $DateDeleted=null,
        /** @var string|null */
        public ?string $Frequency=null,
        /** @var DateTime */
        public DateTime $StartDate=new DateTime(),
        /** @var DateInterval|null */
        public ?DateInterval $TimeOfDay=null,
        /** @var DateTime|null */
        public ?DateTime $LastRunAtUtc=null,
        /** @var DateTime|null */
        public ?DateTime $NextRunAtUtc=null,
        /** @var string|null */
        public ?string $TimeZoneId=null,
        /** @var DayOfWeek|null */
        public ?DayOfWeek $DayOfWeek=null,
        /** @var int|null */
        public ?int $DayOfMonth=null,
        /** @var bool|null */
        public ?bool $IsActive=null,
        /** @var DateTime|null */
        public ?DateTime $CreatedUtc=null,
        /** @var DateTime|null */
        public ?DateTime $UpdatedUtc=null,
        /** @var DeliveryChannel|null */
        public ?DeliveryChannel $Channels=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['CampaignId'])) $this->CampaignId = $o['CampaignId'];
        if (isset($o['CampaignTypeId'])) $this->CampaignTypeId = $o['CampaignTypeId'];
        if (isset($o['CampaignName'])) $this->CampaignName = $o['CampaignName'];
        if (isset($o['AgentID'])) $this->AgentID = $o['AgentID'];
        if (isset($o['Subject'])) $this->Subject = $o['Subject'];
        if (isset($o['Template'])) $this->Template = $o['Template'];
        if (isset($o['DateCreated'])) $this->DateCreated = JsonConverters::from('DateTime', $o['DateCreated']);
        if (isset($o['DateDeleted'])) $this->DateDeleted = JsonConverters::from('DateTime', $o['DateDeleted']);
        if (isset($o['Frequency'])) $this->Frequency = $o['Frequency'];
        if (isset($o['StartDate'])) $this->StartDate = JsonConverters::from('DateTime', $o['StartDate']);
        if (isset($o['TimeOfDay'])) $this->TimeOfDay = JsonConverters::from('TimeSpan', $o['TimeOfDay']);
        if (isset($o['LastRunAtUtc'])) $this->LastRunAtUtc = JsonConverters::from('DateTime', $o['LastRunAtUtc']);
        if (isset($o['NextRunAtUtc'])) $this->NextRunAtUtc = JsonConverters::from('DateTime', $o['NextRunAtUtc']);
        if (isset($o['TimeZoneId'])) $this->TimeZoneId = $o['TimeZoneId'];
        if (isset($o['DayOfWeek'])) $this->DayOfWeek = JsonConverters::from('DayOfWeek', $o['DayOfWeek']);
        if (isset($o['DayOfMonth'])) $this->DayOfMonth = $o['DayOfMonth'];
        if (isset($o['IsActive'])) $this->IsActive = $o['IsActive'];
        if (isset($o['CreatedUtc'])) $this->CreatedUtc = JsonConverters::from('DateTime', $o['CreatedUtc']);
        if (isset($o['UpdatedUtc'])) $this->UpdatedUtc = JsonConverters::from('DateTime', $o['UpdatedUtc']);
        if (isset($o['Channels'])) $this->Channels = JsonConverters::from('DeliveryChannel', $o['Channels']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->CampaignId)) $o['CampaignId'] = $this->CampaignId;
        if (isset($this->CampaignTypeId)) $o['CampaignTypeId'] = $this->CampaignTypeId;
        if (isset($this->CampaignName)) $o['CampaignName'] = $this->CampaignName;
        if (isset($this->AgentID)) $o['AgentID'] = $this->AgentID;
        if (isset($this->Subject)) $o['Subject'] = $this->Subject;
        if (isset($this->Template)) $o['Template'] = $this->Template;
        if (isset($this->DateCreated)) $o['DateCreated'] = JsonConverters::to('DateTime', $this->DateCreated);
        if (isset($this->DateDeleted)) $o['DateDeleted'] = JsonConverters::to('DateTime', $this->DateDeleted);
        if (isset($this->Frequency)) $o['Frequency'] = $this->Frequency;
        if (isset($this->StartDate)) $o['StartDate'] = JsonConverters::to('DateTime', $this->StartDate);
        if (isset($this->TimeOfDay)) $o['TimeOfDay'] = JsonConverters::to('TimeSpan', $this->TimeOfDay);
        if (isset($this->LastRunAtUtc)) $o['LastRunAtUtc'] = JsonConverters::to('DateTime', $this->LastRunAtUtc);
        if (isset($this->NextRunAtUtc)) $o['NextRunAtUtc'] = JsonConverters::to('DateTime', $this->NextRunAtUtc);
        if (isset($this->TimeZoneId)) $o['TimeZoneId'] = $this->TimeZoneId;
        if (isset($this->DayOfWeek)) $o['DayOfWeek'] = JsonConverters::to('DayOfWeek', $this->DayOfWeek);
        if (isset($this->DayOfMonth)) $o['DayOfMonth'] = $this->DayOfMonth;
        if (isset($this->IsActive)) $o['IsActive'] = $this->IsActive;
        if (isset($this->CreatedUtc)) $o['CreatedUtc'] = JsonConverters::to('DateTime', $this->CreatedUtc);
        if (isset($this->UpdatedUtc)) $o['UpdatedUtc'] = JsonConverters::to('DateTime', $this->UpdatedUtc);
        if (isset($this->Channels)) $o['Channels'] = JsonConverters::to('DeliveryChannel', $this->Channels);
        return empty($o) ? new class(){} : $o;
    }
}

class CampaignExtended extends Campaign implements JsonSerializable
{
    /**
     * @param int $CampaignId
     * @param int $CampaignTypeId
     * @param string|null $CampaignName
     * @param int $AgentID
     * @param string|null $Subject
     * @param string|null $Template
     * @param DateTime|null $DateCreated
     * @param DateTime|null $DateDeleted
     * @param string|null $Frequency
     * @param DateTime $StartDate
     * @param DateInterval|null $TimeOfDay
     * @param DateTime|null $LastRunAtUtc
     * @param DateTime|null $NextRunAtUtc
     * @param string|null $TimeZoneId
     * @param DayOfWeek|null $DayOfWeek
     * @param int|null $DayOfMonth
     * @param bool|null $IsActive
     * @param DateTime|null $CreatedUtc
     * @param DateTime|null $UpdatedUtc
     * @param DeliveryChannel|null $Channels
     */
    public function __construct(
        int $CampaignId=0,
        int $CampaignTypeId=0,
        ?string $CampaignName=null,
        int $AgentID=0,
        ?string $Subject=null,
        ?string $Template=null,
        ?DateTime $DateCreated=null,
        ?DateTime $DateDeleted=null,
        ?string $Frequency=null,
        DateTime $StartDate=new DateTime(),
        ?DateInterval $TimeOfDay=null,
        ?DateTime $LastRunAtUtc=null,
        ?DateTime $NextRunAtUtc=null,
        ?string $TimeZoneId=null,
        ?DayOfWeek $DayOfWeek=null,
        ?int $DayOfMonth=null,
        ?bool $IsActive=null,
        ?DateTime $CreatedUtc=null,
        ?DateTime $UpdatedUtc=null,
        ?DeliveryChannel $Channels=null,
        /** @var string|null */
        public ?string $CampaignType=null,
        /** @var string|null */
        public ?string $AgentName=null
    ) {
        parent::__construct($CampaignId,$CampaignTypeId,$CampaignName,$AgentID,$Subject,$Template,$DateCreated,$DateDeleted,$Frequency,$StartDate,$TimeOfDay,$LastRunAtUtc,$NextRunAtUtc,$TimeZoneId,$DayOfWeek,$DayOfMonth,$IsActive,$CreatedUtc,$UpdatedUtc,$Channels);
    }

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

class CampaignResponse implements JsonSerializable
{
    public function __construct(
        /** @var ResponseStatus|null */
        public ?ResponseStatus $ResponseStatus=null,
        /** @var array<CampaignExtended>|null */
        public ?array $Campaign=null
    ) {
    }

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

class CampaignRequest implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $CampaignId=0,
        /** @var array<Campaign>|null */
        public ?array $Campaign=null
    ) {
    }

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

PHP CampaignRequest 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/Campaign/{CampaignId} HTTP/1.1 
Host: api.dev.dynamics.trendsic.com 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<CampaignRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
  <Campaign>
    <Campaign>
      <AgentID>0</AgentID>
      <CampaignId>0</CampaignId>
      <CampaignName>String</CampaignName>
      <CampaignTypeId>0</CampaignTypeId>
      <Channels>None</Channels>
      <CreatedUtc>0001-01-01T00:00:00</CreatedUtc>
      <DateCreated>0001-01-01T00:00:00</DateCreated>
      <DateDeleted>0001-01-01T00:00:00</DateDeleted>
      <DayOfMonth>0</DayOfMonth>
      <DayOfWeek>Sunday</DayOfWeek>
      <Frequency>String</Frequency>
      <IsActive>false</IsActive>
      <LastRunAtUtc>0001-01-01T00:00:00</LastRunAtUtc>
      <NextRunAtUtc>0001-01-01T00:00:00</NextRunAtUtc>
      <StartDate>0001-01-01T00:00:00</StartDate>
      <Subject>String</Subject>
      <Template>String</Template>
      <TimeOfDay>PT0S</TimeOfDay>
      <TimeZoneId>String</TimeZoneId>
      <UpdatedUtc>0001-01-01T00:00:00</UpdatedUtc>
    </Campaign>
  </Campaign>
  <CampaignId>0</CampaignId>
</CampaignRequest>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<CampaignResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
  <Campaign>
    <CampaignExtended>
      <AgentID>0</AgentID>
      <CampaignId>0</CampaignId>
      <CampaignName>String</CampaignName>
      <CampaignTypeId>0</CampaignTypeId>
      <Channels>None</Channels>
      <CreatedUtc>0001-01-01T00:00:00</CreatedUtc>
      <DateCreated>0001-01-01T00:00:00</DateCreated>
      <DateDeleted>0001-01-01T00:00:00</DateDeleted>
      <DayOfMonth>0</DayOfMonth>
      <DayOfWeek>Sunday</DayOfWeek>
      <Frequency>String</Frequency>
      <IsActive>false</IsActive>
      <LastRunAtUtc>0001-01-01T00:00:00</LastRunAtUtc>
      <NextRunAtUtc>0001-01-01T00:00:00</NextRunAtUtc>
      <StartDate>0001-01-01T00:00:00</StartDate>
      <Subject>String</Subject>
      <Template>String</Template>
      <TimeOfDay>PT0S</TimeOfDay>
      <TimeZoneId>String</TimeZoneId>
      <UpdatedUtc>0001-01-01T00:00:00</UpdatedUtc>
      <AgentName>String</AgentName>
      <CampaignType>String</CampaignType>
    </CampaignExtended>
  </Campaign>
  <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>
</CampaignResponse>