Evo Voice

<back to all web services

PatchAlert

Update a specific alert

Requires Authentication
Requires any of the roles:SystemAdministrator, Manager, Customer
The following routes are available for this service:
PATCH/alerts/{alertId}
<?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 EntityInfo implements JsonSerializable
{
    public function __construct(
        /** @description The ID of the object */
        // @ApiMember(Description="The ID of the object")
        /** @var string|null */
        public ?string $id=null,

        /** @description The date the object was created */
        // @ApiMember(Description="The date the object was created")
        /** @var string|null */
        public ?string $dateCreated=null,

        /** @description The date the object was last modified */
        // @ApiMember(Description="The date the object was last modified")
        /** @var string|null */
        public ?string $dateLastModified=null,

        /** @description The user that created this object */
        // @ApiMember(Description="The user that created this object")
        /** @var string|null */
        public ?string $createdBy=null,

        /** @description The user that last modified this object */
        // @ApiMember(Description="The user that last modified this object")
        /** @var string|null */
        public ?string $lastModifiedBy=null
    ) {
    }

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

enum AlertTriggers : string
{
    case CallSpend = 'CallSpend';
}

class AlertInfo extends EntityInfo implements JsonSerializable
{
    /**
     * @param string|null $id
     * @param string|null $dateCreated
     * @param string|null $dateLastModified
     * @param string|null $createdBy
     * @param string|null $lastModifiedBy
     */
    public function __construct(
        ?string $id=null,
        ?string $dateCreated=null,
        ?string $dateLastModified=null,
        ?string $createdBy=null,
        ?string $lastModifiedBy=null,
        /** @description The ID of the account associated with this alert */
        // @ApiMember(Description="The ID of the account associated with this alert")
        /** @var string|null */
        public ?string $accountId=null,

        /** @description The name of the alert */
        // @ApiMember(Description="The name of the alert")
        /** @var string|null */
        public ?string $name=null,

        /** @description The trigger alert */
        // @ApiMember(Description="The trigger alert")
        /** @var AlertTriggers|null */
        public ?AlertTriggers $trigger=null,

        /** @description The number of hours for the window over which the alert will trigger */
        // @ApiMember(Description="The number of hours for the window over which the alert will trigger")
        /** @var float */
        public float $windowHours=0.0,

        /** @description The value at which the alert will trigger */
        // @ApiMember(Description="The value at which the alert will trigger")
        /** @var float */
        public float $threshold=0.0,

        /** @description The email addresses (one per line) to notify */
        // @ApiMember(Description="The email addresses (one per line) to notify")
        /** @var string|null */
        public ?string $notificationEmailAddresses=null
    ) {
        parent::__construct($id,$dateCreated,$dateLastModified,$createdBy,$lastModifiedBy);
    }

    /** @throws Exception */
    public function fromMap($o): void {
        parent::fromMap($o);
        if (isset($o['accountId'])) $this->accountId = $o['accountId'];
        if (isset($o['name'])) $this->name = $o['name'];
        if (isset($o['trigger'])) $this->trigger = JsonConverters::from('AlertTriggers', $o['trigger']);
        if (isset($o['windowHours'])) $this->windowHours = $o['windowHours'];
        if (isset($o['threshold'])) $this->threshold = $o['threshold'];
        if (isset($o['notificationEmailAddresses'])) $this->notificationEmailAddresses = $o['notificationEmailAddresses'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        if (isset($this->accountId)) $o['accountId'] = $this->accountId;
        if (isset($this->name)) $o['name'] = $this->name;
        if (isset($this->trigger)) $o['trigger'] = JsonConverters::to('AlertTriggers', $this->trigger);
        if (isset($this->windowHours)) $o['windowHours'] = $this->windowHours;
        if (isset($this->threshold)) $o['threshold'] = $this->threshold;
        if (isset($this->notificationEmailAddresses)) $o['notificationEmailAddresses'] = $this->notificationEmailAddresses;
        return empty($o) ? new class(){} : $o;
    }
}

/** @description Update a specific alert */
// @Api(Description="Update a specific alert")
class PatchAlert implements IPatch, JsonSerializable
{
    public function __construct(
        /** @description The ID of the alert you want to update */
        // @ApiMember(Description="The ID of the alert you want to update")
        /** @var string|null */
        public ?string $alertId=null,

        /** @description The name for the alert */
        // @ApiMember(Description="The name for the alert")
        /** @var string|null */
        public ?string $name=null,

        /** @description The trigger alert */
        // @ApiMember(Description="The trigger alert")
        /** @var AlertTriggers|null */
        public ?AlertTriggers $trigger=null,

        /** @description The number of hours for the window over which the alert will trigger */
        // @ApiMember(Description="The number of hours for the window over which the alert will trigger")
        /** @var float|null */
        public ?float $windowHours=null,

        /** @description The value at which the alert will trigger */
        // @ApiMember(Description="The value at which the alert will trigger")
        /** @var float|null */
        public ?float $threshold=null,

        /** @description The email addresses (one per line) to notify */
        // @ApiMember(Description="The email addresses (one per line) to notify")
        /** @var string|null */
        public ?string $notificationEmailAddresses=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['alertId'])) $this->alertId = $o['alertId'];
        if (isset($o['name'])) $this->name = $o['name'];
        if (isset($o['trigger'])) $this->trigger = JsonConverters::from('AlertTriggers', $o['trigger']);
        if (isset($o['windowHours'])) $this->windowHours = $o['windowHours'];
        if (isset($o['threshold'])) $this->threshold = $o['threshold'];
        if (isset($o['notificationEmailAddresses'])) $this->notificationEmailAddresses = $o['notificationEmailAddresses'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->alertId)) $o['alertId'] = $this->alertId;
        if (isset($this->name)) $o['name'] = $this->name;
        if (isset($this->trigger)) $o['trigger'] = JsonConverters::to('AlertTriggers', $this->trigger);
        if (isset($this->windowHours)) $o['windowHours'] = $this->windowHours;
        if (isset($this->threshold)) $o['threshold'] = $this->threshold;
        if (isset($this->notificationEmailAddresses)) $o['notificationEmailAddresses'] = $this->notificationEmailAddresses;
        return empty($o) ? new class(){} : $o;
    }
}

PHP PatchAlert 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

HTTP + JSON

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

PATCH /alerts/{alertId} HTTP/1.1 
Host: evovoice.io 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"alertId":"String","name":"String","trigger":"CallSpend","windowHours":0,"threshold":0,"notificationEmailAddresses":"String"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"accountId":"String","name":"String","trigger":"CallSpend","windowHours":0,"threshold":0,"notificationEmailAddresses":"String","id":"String","dateCreated":"String","dateLastModified":"String","createdBy":"String","lastModifiedBy":"String"}