Trendsic Platform Service

<back to all web services

ProductsRequest

Requires Authentication
Requires any of the roles:Agent, Administrator, Agent, Administrator, Agent, Administrator, Agent, Administrator
The following routes are available for this service:
GET/v1/Products/{UserID}
GET,POST,PUT,DELETE,OPTIONS/v1/Products/
<?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 Product implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $ID=0,
        /** @var string|null */
        public ?string $ProductName=null,
        /** @var int */
        public int $ProductTypeID=0,
        /** @var float */
        public float $UnitPrice=0.0,
        /** @var string|null */
        public ?string $Description=null,
        /** @var string|null */
        public ?string $ImageURL=null,
        /** @var string|null */
        public ?string $ImageKey=null,
        /** @var string|null */
        public ?string $SpecialSaleText=null,
        /** @var float */
        public float $ShipPrice=0.0,
        /** @var float */
        public float $SalePrice=0.0,
        /** @var string */
        public string $UID='',
        /** @var int */
        public int $ProductCategory=0,
        /** @var int */
        public int $ProductSubCategory=0,
        /** @var float */
        public float $ProductWeight=0.0,
        /** @var float */
        public float $FreightMarkupPercent=0.0,
        /** @var float */
        public float $FreightMarkUpAmount=0.0,
        /** @var float */
        public float $PointValue=0.0,
        /** @var bool|null */
        public ?bool $IsActive=null,
        /** @var string|null */
        public ?string $StripeProductId=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['ID'])) $this->ID = $o['ID'];
        if (isset($o['ProductName'])) $this->ProductName = $o['ProductName'];
        if (isset($o['ProductTypeID'])) $this->ProductTypeID = $o['ProductTypeID'];
        if (isset($o['UnitPrice'])) $this->UnitPrice = $o['UnitPrice'];
        if (isset($o['Description'])) $this->Description = $o['Description'];
        if (isset($o['ImageURL'])) $this->ImageURL = $o['ImageURL'];
        if (isset($o['ImageKey'])) $this->ImageKey = $o['ImageKey'];
        if (isset($o['SpecialSaleText'])) $this->SpecialSaleText = $o['SpecialSaleText'];
        if (isset($o['ShipPrice'])) $this->ShipPrice = $o['ShipPrice'];
        if (isset($o['SalePrice'])) $this->SalePrice = $o['SalePrice'];
        if (isset($o['UID'])) $this->UID = $o['UID'];
        if (isset($o['ProductCategory'])) $this->ProductCategory = $o['ProductCategory'];
        if (isset($o['ProductSubCategory'])) $this->ProductSubCategory = $o['ProductSubCategory'];
        if (isset($o['ProductWeight'])) $this->ProductWeight = $o['ProductWeight'];
        if (isset($o['FreightMarkupPercent'])) $this->FreightMarkupPercent = $o['FreightMarkupPercent'];
        if (isset($o['FreightMarkUpAmount'])) $this->FreightMarkUpAmount = $o['FreightMarkUpAmount'];
        if (isset($o['PointValue'])) $this->PointValue = $o['PointValue'];
        if (isset($o['IsActive'])) $this->IsActive = $o['IsActive'];
        if (isset($o['StripeProductId'])) $this->StripeProductId = $o['StripeProductId'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->ID)) $o['ID'] = $this->ID;
        if (isset($this->ProductName)) $o['ProductName'] = $this->ProductName;
        if (isset($this->ProductTypeID)) $o['ProductTypeID'] = $this->ProductTypeID;
        if (isset($this->UnitPrice)) $o['UnitPrice'] = $this->UnitPrice;
        if (isset($this->Description)) $o['Description'] = $this->Description;
        if (isset($this->ImageURL)) $o['ImageURL'] = $this->ImageURL;
        if (isset($this->ImageKey)) $o['ImageKey'] = $this->ImageKey;
        if (isset($this->SpecialSaleText)) $o['SpecialSaleText'] = $this->SpecialSaleText;
        if (isset($this->ShipPrice)) $o['ShipPrice'] = $this->ShipPrice;
        if (isset($this->SalePrice)) $o['SalePrice'] = $this->SalePrice;
        if (isset($this->UID)) $o['UID'] = $this->UID;
        if (isset($this->ProductCategory)) $o['ProductCategory'] = $this->ProductCategory;
        if (isset($this->ProductSubCategory)) $o['ProductSubCategory'] = $this->ProductSubCategory;
        if (isset($this->ProductWeight)) $o['ProductWeight'] = $this->ProductWeight;
        if (isset($this->FreightMarkupPercent)) $o['FreightMarkupPercent'] = $this->FreightMarkupPercent;
        if (isset($this->FreightMarkUpAmount)) $o['FreightMarkUpAmount'] = $this->FreightMarkUpAmount;
        if (isset($this->PointValue)) $o['PointValue'] = $this->PointValue;
        if (isset($this->IsActive)) $o['IsActive'] = $this->IsActive;
        if (isset($this->StripeProductId)) $o['StripeProductId'] = $this->StripeProductId;
        return empty($o) ? new class(){} : $o;
    }
}

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

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

class ProductsRequest implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $UserID='',
        /** @var array<Product>|null */
        public ?array $Products=null
    ) {
    }

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

PHP ProductsRequest DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv

HTTP + CSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /v1/Products/ HTTP/1.1 
Host: api.dev.dynamics.trendsic.com 
Accept: text/csv
Content-Type: text/csv
Content-Length: length

{"UserID":"00000000000000000000000000000000","Products":[{"ID":0,"ProductName":"String","ProductTypeID":0,"UnitPrice":0,"Description":"String","ImageURL":"String","ImageKey":"String","SpecialSaleText":"String","ShipPrice":0,"SalePrice":0,"UID":"00000000000000000000000000000000","ProductCategory":0,"ProductSubCategory":0,"ProductWeight":0,"FreightMarkupPercent":0,"FreightMarkUpAmount":0,"PointValue":0,"IsActive":false,"StripeProductId":"String"}]}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}},"Products":[{"ID":0,"ProductName":"String","ProductTypeID":0,"UnitPrice":0,"Description":"String","ImageURL":"String","ImageKey":"String","SpecialSaleText":"String","ShipPrice":0,"SalePrice":0,"UID":"00000000000000000000000000000000","ProductCategory":0,"ProductSubCategory":0,"ProductWeight":0,"FreightMarkupPercent":0,"FreightMarkUpAmount":0,"PointValue":0,"IsActive":false,"StripeProductId":"String"}]}