Trendsic Platform Service

<back to all web services

Clients

Requires Authentication
Requires any of the roles:Agent, Administrator, Agent, Administrator, Agent, Administrator, Agent, Administrator
The following routes are available for this service:
GET,POST,PUT,DELETE,OPTIONS/v1/Clients/{Id}
GET,POST,PUT,DELETE,OPTIONS/v1/Clients
<?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 ClientObject implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $Id='',
        /** @var string|null */
        public ?string $Name=null,
        /** @var string|null */
        public ?string $Address1=null,
        /** @var string|null */
        public ?string $Address2=null,
        /** @var string|null */
        public ?string $City=null,
        /** @var string|null */
        public ?string $State=null,
        /** @var string|null */
        public ?string $Zip=null,
        /** @var string */
        public string $SubscriptionId='',
        /** @var bool|null */
        public ?bool $Active=null,
        /** @var DateTime */
        public DateTime $EntDate=new DateTime(),
        /** @var DateTime */
        public DateTime $ModDate=new DateTime()
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Id'])) $this->Id = $o['Id'];
        if (isset($o['Name'])) $this->Name = $o['Name'];
        if (isset($o['Address1'])) $this->Address1 = $o['Address1'];
        if (isset($o['Address2'])) $this->Address2 = $o['Address2'];
        if (isset($o['City'])) $this->City = $o['City'];
        if (isset($o['State'])) $this->State = $o['State'];
        if (isset($o['Zip'])) $this->Zip = $o['Zip'];
        if (isset($o['SubscriptionId'])) $this->SubscriptionId = $o['SubscriptionId'];
        if (isset($o['Active'])) $this->Active = $o['Active'];
        if (isset($o['EntDate'])) $this->EntDate = JsonConverters::from('DateTime', $o['EntDate']);
        if (isset($o['ModDate'])) $this->ModDate = JsonConverters::from('DateTime', $o['ModDate']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Id)) $o['Id'] = $this->Id;
        if (isset($this->Name)) $o['Name'] = $this->Name;
        if (isset($this->Address1)) $o['Address1'] = $this->Address1;
        if (isset($this->Address2)) $o['Address2'] = $this->Address2;
        if (isset($this->City)) $o['City'] = $this->City;
        if (isset($this->State)) $o['State'] = $this->State;
        if (isset($this->Zip)) $o['Zip'] = $this->Zip;
        if (isset($this->SubscriptionId)) $o['SubscriptionId'] = $this->SubscriptionId;
        if (isset($this->Active)) $o['Active'] = $this->Active;
        if (isset($this->EntDate)) $o['EntDate'] = JsonConverters::to('DateTime', $this->EntDate);
        if (isset($this->ModDate)) $o['ModDate'] = JsonConverters::to('DateTime', $this->ModDate);
        return empty($o) ? new class(){} : $o;
    }
}

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

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

class Clients extends ClientObject implements JsonSerializable
{
    /**
     * @param string $Id
     * @param string|null $Name
     * @param string|null $Address1
     * @param string|null $Address2
     * @param string|null $City
     * @param string|null $State
     * @param string|null $Zip
     * @param string $SubscriptionId
     * @param bool|null $Active
     * @param DateTime $EntDate
     * @param DateTime $ModDate
     */
    public function __construct(
        string $Id='',
        ?string $Name=null,
        ?string $Address1=null,
        ?string $Address2=null,
        ?string $City=null,
        ?string $State=null,
        ?string $Zip=null,
        string $SubscriptionId='',
        ?bool $Active=null,
        DateTime $EntDate=new DateTime(),
        DateTime $ModDate=new DateTime(),
        /** @var string */
        public string $ApiKey=''
    ) {
        parent::__construct($Id,$Name,$Address1,$Address2,$City,$State,$Zip,$SubscriptionId,$Active,$EntDate,$ModDate);
    }

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

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

<Clients xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
  <Active>false</Active>
  <Address1>String</Address1>
  <Address2>String</Address2>
  <City>String</City>
  <EntDate>0001-01-01T00:00:00</EntDate>
  <Id>00000000-0000-0000-0000-000000000000</Id>
  <ModDate>0001-01-01T00:00:00</ModDate>
  <Name>String</Name>
  <State>String</State>
  <SubscriptionId>00000000-0000-0000-0000-000000000000</SubscriptionId>
  <Zip>String</Zip>
  <ApiKey>00000000-0000-0000-0000-000000000000</ApiKey>
</Clients>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<ClientsResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
  <Clients>
    <ClientObject>
      <Active>false</Active>
      <Address1>String</Address1>
      <Address2>String</Address2>
      <City>String</City>
      <EntDate>0001-01-01T00:00:00</EntDate>
      <Id>00000000-0000-0000-0000-000000000000</Id>
      <ModDate>0001-01-01T00:00:00</ModDate>
      <Name>String</Name>
      <State>String</State>
      <SubscriptionId>00000000-0000-0000-0000-000000000000</SubscriptionId>
      <Zip>String</Zip>
    </ClientObject>
  </Clients>
  <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>
</ClientsResponse>