PUT | /RestApi/sitefinity/related-data/relations |
---|
<?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 RelationChangeMessage implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $ItemId=null,
/** @var string|null */
public ?string $ItemType=null,
/** @var string|null */
public ?string $ItemProvider=null,
/** @var ContentLinkChange[]|null */
public ?array $RelationChanges=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ItemId'])) $this->ItemId = $o['ItemId'];
if (isset($o['ItemType'])) $this->ItemType = $o['ItemType'];
if (isset($o['ItemProvider'])) $this->ItemProvider = $o['ItemProvider'];
if (isset($o['RelationChanges'])) $this->RelationChanges = JsonConverters::fromArray('ContentLinkChange', $o['RelationChanges']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ItemId)) $o['ItemId'] = $this->ItemId;
if (isset($this->ItemType)) $o['ItemType'] = $this->ItemType;
if (isset($this->ItemProvider)) $o['ItemProvider'] = $this->ItemProvider;
if (isset($this->RelationChanges)) $o['RelationChanges'] = JsonConverters::toArray('ContentLinkChange', $this->RelationChanges);
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
enum ContentLinkChangeState : string
{
case Added = 'Added';
case Removed = 'Removed';
case Updated = 'Updated';
}
// @DataContract
class ContentLinkChange implements JsonSerializable
{
public function __construct(
// @DataMember
/** @var ContentLinkChangeState|null */
public ?ContentLinkChangeState $State=null,
// @DataMember
/** @var string */
public string $ChildItemId='',
// @DataMember
/** @var string|null */
public ?string $ChildItemProviderName=null,
// @DataMember
/** @var string|null */
public ?string $ChildItemType=null,
// @DataMember
/** @var string|null */
public ?string $ChildItemAdditionalInfo=null,
// @DataMember
/** @var float|null */
public ?float $Ordinal=null,
// @DataMember
/** @var string|null */
public ?string $ComponentPropertyName=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['State'])) $this->State = JsonConverters::from('ContentLinkChangeState', $o['State']);
if (isset($o['ChildItemId'])) $this->ChildItemId = $o['ChildItemId'];
if (isset($o['ChildItemProviderName'])) $this->ChildItemProviderName = $o['ChildItemProviderName'];
if (isset($o['ChildItemType'])) $this->ChildItemType = $o['ChildItemType'];
if (isset($o['ChildItemAdditionalInfo'])) $this->ChildItemAdditionalInfo = $o['ChildItemAdditionalInfo'];
if (isset($o['Ordinal'])) $this->Ordinal = $o['Ordinal'];
if (isset($o['ComponentPropertyName'])) $this->ComponentPropertyName = $o['ComponentPropertyName'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->State)) $o['State'] = JsonConverters::to('ContentLinkChangeState', $this->State);
if (isset($this->ChildItemId)) $o['ChildItemId'] = $this->ChildItemId;
if (isset($this->ChildItemProviderName)) $o['ChildItemProviderName'] = $this->ChildItemProviderName;
if (isset($this->ChildItemType)) $o['ChildItemType'] = $this->ChildItemType;
if (isset($this->ChildItemAdditionalInfo)) $o['ChildItemAdditionalInfo'] = $this->ChildItemAdditionalInfo;
if (isset($this->Ordinal)) $o['Ordinal'] = $this->Ordinal;
if (isset($this->ComponentPropertyName)) $o['ComponentPropertyName'] = $this->ComponentPropertyName;
return empty($o) ? new class(){} : $o;
}
}
PHP RelationChangeMessage DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
PUT /RestApi/sitefinity/related-data/relations HTTP/1.1
Host: www.asg.com.au
Accept: application/json
Content-Type: application/json
Content-Length: length
{"ItemId":"String","ItemType":"String","ItemProvider":"String","RelationChanges":[{"State":"Added","ChildItemProviderName":"String","ChildItemType":"String","ChildItemAdditionalInfo":"String","Ordinal":0,"ComponentPropertyName":"String","IsChildDeleted":false}]}