Platform Subscription API

<back to all web services

SaveContactGroup

Inserts or Updates a contact group and its contact connections.

Requires Authentication
<?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 RuleValidationResult implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $RuleCode=null,
        /** @var string|null */
        public ?string $Message=null,
        /** @var string|null */
        public ?string $Key=null,
        /** @var string|null */
        public ?string $Tag=null,
        /** @var string|null */
        public ?string $ErrorCode=null
    ) {
    }

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

class ValidationErrorList implements JsonSerializable
{
    public function __construct(
        /** @var array<RuleValidationResult>|null */
        public ?array $ValidationErrors=null
    ) {
    }

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

class SubscriptionLinkContact implements JsonSerializable
{
    public function __construct(
        /** @description Guid of the contact object within Eros. */
        // @ApiMember(DataType="Guid", Description="Guid of the contact object within Eros.", Name="ContactId", ParameterType="query")
        /** @var string */
        public string $ContactId='',

        /** @description The unique key that represents the contact on the external system. */
        // @ApiMember(DataType="string", Description="The unique key that represents the contact on the external system.", IsRequired=true, Name="ContactAlternateKey", ParameterType="query")
        /** @var string */
        public string $ContactAlternateKey='',

        /** @description Guid of the Role List Item object within Eros. */
        // @ApiMember(DataType="Guid", Description="Guid of the Role List Item object within Eros.", IsRequired=true, Name="RoleId", ParameterType="query")
        /** @var string */
        public string $RoleId='',

        /** @description The unique key that represents the role type on the external system. Note: Use of this is not currently implemented */
        // @ApiMember(DataType="string", Description="The unique key that represents the role type on the external system. Note: Use of this is not currently implemented", Name="RoleAlternateKey", ParameterType="query")
        /** @var string|null */
        public ?string $RoleAlternateKey=null
    ) {
    }

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

class SubscriptionContactGroupConnectionModel extends SubscriptionLinkContact implements JsonSerializable
{
    /**
     * @param string $ContactId
     * @param string $ContactAlternateKey
     * @param string $RoleId
     * @param string|null $RoleAlternateKey
     */
    public function __construct(
        string $ContactId='',
        string $ContactAlternateKey='',
        string $RoleId='',
        ?string $RoleAlternateKey=null,
        /** @description The order this contact is in priority.  1 would be the primary contact, 2 the secondary and so forth. */
        // @ApiMember(DataType="int", Description="The order this contact is in priority.  1 would be the primary contact, 2 the secondary and so forth.", Name="Index", ParameterType="query")
        /** @var int */
        public int $Index=0,

        /** @description Set this to be true if the contact connection to the group is to be deleted */
        // @ApiMember(DataType="bool", Description="Set this to be true if the contact connection to the group is to be deleted", Name="MarkAsDeleted", ParameterType="query")
        /** @var bool|null */
        public ?bool $MarkAsDeleted=null
    ) {
        parent::__construct($ContactId,$ContactAlternateKey,$RoleId,$RoleAlternateKey);
    }

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

class SubscriptionContactGroupModel implements JsonSerializable
{
    public function __construct(
        /** @description A name for the contact group. */
        // @ApiMember(DataType="string", Description="A name for the contact group.", IsRequired=true, Name="ContactGroupName", ParameterType="query")
        /** @var string */
        public string $ContactGroupName='',

        /** @description Guid of the Role List Item object within Eros that defines the role of the group. */
        // @ApiMember(DataType="Guid", Description="Guid of the Role List Item object within Eros that defines the role of the group.", IsRequired=true, Name="GroupRoleId", ParameterType="query")
        /** @var string */
        public string $GroupRoleId='',

        /** @description The unique key that represents the role type of the group on the external system. Note: Use of this is not currently implemented */
        // @ApiMember(DataType="string", Description="The unique key that represents the role type of the group on the external system. Note: Use of this is not currently implemented", Name="RoleAlternateKey", ParameterType="query")
        /** @var string|null */
        public ?string $RoleAlternateKey=null,

        /** @description A list of ContactGroupConnection records that link contacts (and their role in the contact group) to the contact group. */
        // @ApiMember(DataType="List<SubscriptionContactGroupConnectionModel>", Description="A list of ContactGroupConnection records that link contacts (and their role in the contact group) to the contact group.", Name="ContactConnections", ParameterType="query")
        /** @var array<SubscriptionContactGroupConnectionModel>|null */
        public ?array $ContactConnections=null,

        /** @description Set this to be true if the contact group is to be deleted */
        // @ApiMember(DataType="bool", Description="Set this to be true if the contact group is to be deleted", Name="MarkAsDeleted", ParameterType="query")
        /** @var bool|null */
        public ?bool $MarkAsDeleted=null,

        /** @description Set this to be true if the contact group is to be archived */
        // @ApiMember(DataType="bool", Description="Set this to be true if the contact group is to be archived", Name="MarkAsArchived", ParameterType="query")
        /** @var bool|null */
        public ?bool $MarkAsArchived=null,

        /** @description Set this to be true if the contact group is to be restored */
        // @ApiMember(DataType="bool", Description="Set this to be true if the contact group is to be restored", Name="MarkAsRestored", ParameterType="query")
        /** @var bool|null */
        public ?bool $MarkAsRestored=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['ContactGroupName'])) $this->ContactGroupName = $o['ContactGroupName'];
        if (isset($o['GroupRoleId'])) $this->GroupRoleId = $o['GroupRoleId'];
        if (isset($o['RoleAlternateKey'])) $this->RoleAlternateKey = $o['RoleAlternateKey'];
        if (isset($o['ContactConnections'])) $this->ContactConnections = JsonConverters::fromArray('SubscriptionContactGroupConnectionModel', $o['ContactConnections']);
        if (isset($o['MarkAsDeleted'])) $this->MarkAsDeleted = $o['MarkAsDeleted'];
        if (isset($o['MarkAsArchived'])) $this->MarkAsArchived = $o['MarkAsArchived'];
        if (isset($o['MarkAsRestored'])) $this->MarkAsRestored = $o['MarkAsRestored'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->ContactGroupName)) $o['ContactGroupName'] = $this->ContactGroupName;
        if (isset($this->GroupRoleId)) $o['GroupRoleId'] = $this->GroupRoleId;
        if (isset($this->RoleAlternateKey)) $o['RoleAlternateKey'] = $this->RoleAlternateKey;
        if (isset($this->ContactConnections)) $o['ContactConnections'] = JsonConverters::toArray('SubscriptionContactGroupConnectionModel', $this->ContactConnections);
        if (isset($this->MarkAsDeleted)) $o['MarkAsDeleted'] = $this->MarkAsDeleted;
        if (isset($this->MarkAsArchived)) $o['MarkAsArchived'] = $this->MarkAsArchived;
        if (isset($this->MarkAsRestored)) $o['MarkAsRestored'] = $this->MarkAsRestored;
        return empty($o) ? new class(){} : $o;
    }
}

/** @description Inserts or Updates a contact group and its contact connections. */
// @Api(Description="Inserts or Updates a contact group and its contact connections.")
class SaveContactGroup extends ValidationErrorList implements ISubscription, JsonSerializable
{
    /**
     * @param array<RuleValidationResult>|null $ValidationErrors
     */
    public function __construct(
        ?array $ValidationErrors=null,
        /** @description Guid representing the external systems datasource information. */
        // @ApiMember(DataType="Guid", Description="Guid representing the external systems datasource information.", IsRequired=true, Name="SuiteDataSourceInstanceId", ParameterType="query")
        /** @var string */
        public string $SuiteDataSourceInstanceId='',

        /** @description The unique key that represents the contact group on the external system. */
        // @ApiMember(DataType="string", Description="The unique key that represents the contact group on the external system.", IsRequired=true, Name="AlternateKey", ParameterType="query")
        /** @var string */
        public string $AlternateKey='',

        /** @description Guid of the contact group object within Eros.  If ObjectId is known, the external system may pass this insted of the alternate key. */
        // @ApiMember(DataType="Guid", Description="Guid of the contact group object within Eros.  If ObjectId is known, the external system may pass this insted of the alternate key.", Name="ObjectId", ParameterType="query")
        /** @var string */
        public string $ObjectId='',

        /** @description If set to true, the object will be updated/refreshed. If false, the hash representation of the ContactGroup model and its data will be compared with the current ContactGroup to determine if there are any changes to save. */
        // @ApiMember(DataType="bool", Description="If set to true, the object will be updated/refreshed. If false, the hash representation of the ContactGroup model and its data will be compared with the current ContactGroup to determine if there are any changes to save.", Name="IgnoreHash")
        /** @var bool|null */
        public ?bool $IgnoreHash=null,

        /** @description Object containing all details of the contact group to be inserted or updated. */
        // @ApiMember(DataType="SubscriptionContactGroupModel", Description="Object containing all details of the contact group to be inserted or updated.", IsRequired=true, Name="ContactGroup", ParameterType="query")
        /** @var SubscriptionContactGroupModel|null */
        public ?SubscriptionContactGroupModel $ContactGroup=null,

        /** @var bool|null */
        public ?bool $IgnoreValidation=null,
        /** @var string */
        public string $LicenseeId='',
        /** @var string */
        public string $SessionId=''
    ) {
        parent::__construct($ValidationErrors);
    }

    /** @throws Exception */
    public function fromMap($o): void {
        parent::fromMap($o);
        if (isset($o['SuiteDataSourceInstanceId'])) $this->SuiteDataSourceInstanceId = $o['SuiteDataSourceInstanceId'];
        if (isset($o['AlternateKey'])) $this->AlternateKey = $o['AlternateKey'];
        if (isset($o['ObjectId'])) $this->ObjectId = $o['ObjectId'];
        if (isset($o['IgnoreHash'])) $this->IgnoreHash = $o['IgnoreHash'];
        if (isset($o['ContactGroup'])) $this->ContactGroup = JsonConverters::from('SubscriptionContactGroupModel', $o['ContactGroup']);
        if (isset($o['IgnoreValidation'])) $this->IgnoreValidation = $o['IgnoreValidation'];
        if (isset($o['LicenseeId'])) $this->LicenseeId = $o['LicenseeId'];
        if (isset($o['SessionId'])) $this->SessionId = $o['SessionId'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        if (isset($this->SuiteDataSourceInstanceId)) $o['SuiteDataSourceInstanceId'] = $this->SuiteDataSourceInstanceId;
        if (isset($this->AlternateKey)) $o['AlternateKey'] = $this->AlternateKey;
        if (isset($this->ObjectId)) $o['ObjectId'] = $this->ObjectId;
        if (isset($this->IgnoreHash)) $o['IgnoreHash'] = $this->IgnoreHash;
        if (isset($this->ContactGroup)) $o['ContactGroup'] = JsonConverters::to('SubscriptionContactGroupModel', $this->ContactGroup);
        if (isset($this->IgnoreValidation)) $o['IgnoreValidation'] = $this->IgnoreValidation;
        if (isset($this->LicenseeId)) $o['LicenseeId'] = $this->LicenseeId;
        if (isset($this->SessionId)) $o['SessionId'] = $this->SessionId;
        return empty($o) ? new class(){} : $o;
    }
}

PHP SaveContactGroup 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 /jsv/reply/SaveContactGroup HTTP/1.1 
Host: production-eros-platform-apisubscription.azurewebsites.net 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	AlternateKey: String,
	IgnoreHash: False,
	ContactGroup: 
	{
		ContactGroupName: String,
		RoleAlternateKey: String,
		ContactConnections: 
		[
			{
				Index: 0,
				MarkAsDeleted: False,
				ContactAlternateKey: String,
				RoleAlternateKey: String
			}
		],
		MarkAsDeleted: False,
		MarkAsArchived: False,
		MarkAsRestored: False
	},
	IgnoreValidation: False,
	ValidationErrors: 
	[
		{
			RuleCode: String,
			Message: String,
			Key: String,
			Tag: String,
			ErrorCode: String
		}
	]
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	ErrorCode: String,
	Message: String,
	StackTrace: String,
	Errors: 
	[
		{
			ErrorCode: String,
			FieldName: String,
			Message: String,
			Meta: 
			{
				String: String
			}
		}
	],
	Meta: 
	{
		String: String
	}
}