<back to all web services

GetCustomMetricValuesMessage

The following routes are available for this service:
All Verbs/RestApi/Sitefinity/Analytics/GetCustomMetricValues
<?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 GetCustomMetricValuesMessage implements JsonSerializable
{
    public function __construct(
        /** @var string[]|null */
        public ?array $MetricNames=null,
        /** @var int */
        public int $LastNDays=0,
        /** @var int */
        public int $MaxNDays=0,
        /** @var string */
        public string $SiteId=''
    ) {
    }

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

// @DataContract
class DimensionItem implements JsonSerializable
{
    public function __construct(
        // @DataMember
        /** @var string|null */
        public ?string $Value=null,

        // @DataMember
        /** @var string|null */
        public ?string $Name=null
    ) {
    }

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

// @DataContract
class MetricItem implements JsonSerializable
{
    public function __construct(
        // @DataMember
        /** @var float */
        public float $Value=0.0
    ) {
    }

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

// @DataContract
class AnalyticsItem implements JsonSerializable
{
    public function __construct(
        // @DataMember
        /** @var array<DimensionItem>|null */
        public ?array $Dimensions=null,

        // @DataMember
        /** @var array<MetricItem>|null */
        public ?array $Metrics=null,

        // @DataMember
        /** @var float */
        public float $TotalItems=0.0
    ) {
    }

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

class GetCustomMetricValuesData implements JsonSerializable
{
    public function __construct(
        /** @var array<AnalyticsItem>|null */
        public ?array $Result=null,
        /** @var array<string>|null */
        public ?array $MetricDisplayNames=null
    ) {
    }

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

PHP GetCustomMetricValuesMessage DTOs

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

HTTP + JSV

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

POST /RestApi/Sitefinity/Analytics/GetCustomMetricValues HTTP/1.1 
Host: www.asg.com.au 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	MetricNames: 
	[
		String
	],
	LastNDays: 0,
	MaxNDays: 0
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	Result: 
	[
		{
			
		}
	],
	MetricDisplayNames: 
	[
		String
	]
}