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 .other suffix or ?format=other

HTTP + OTHER

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: text/jsonl
Content-Type: text/jsonl
Content-Length: length

{"ApiKey":"00000000000000000000000000000000","Id":"00000000000000000000000000000000","Name":"String","Address1":"String","Address2":"String","City":"String","State":"String","Zip":"String","SubscriptionId":"00000000000000000000000000000000","Active":false,"EntDate":"0001-01-01T00:00:00.0000000","ModDate":"0001-01-01T00:00:00.0000000"}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

{"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}},"Clients":[{"Id":"00000000000000000000000000000000","Name":"String","Address1":"String","Address2":"String","City":"String","State":"String","Zip":"String","SubscriptionId":"00000000000000000000000000000000","Active":false,"EntDate":"0001-01-01T00:00:00.0000000","ModDate":"0001-01-01T00:00:00.0000000"}]}