| Requires any of the roles: | SystemAdministrator, Manager, Customer |
| GET | /alerts |
|---|
import Foundation
import ServiceStack
/**
* Retrieve alerts
*/
// @Api(Description="Retrieve alerts")
public class ListAlerts : ListRequest<AlertInfo>
{
/**
* Filter by accounts
*/
// @ApiMember(Description="Filter by accounts")
public var accountIds:[String]
/**
* Filter by name
*/
// @ApiMember(Description="Filter by name")
public var nameFilter:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case accountIds
case nameFilter
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
accountIds = try container.decodeIfPresent([String].self, forKey: .accountIds) ?? []
nameFilter = try container.decodeIfPresent(String.self, forKey: .nameFilter)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if accountIds != nil { try container.encode(accountIds, forKey: .accountIds) }
if nameFilter != nil { try container.encode(nameFilter, forKey: .nameFilter) }
}
}
public class ListRequest<T : Codable> : IGet, Codable
{
/**
* The page of data to retrieve
*/
// @ApiMember(Description="The page of data to retrieve")
public var page:Int
/**
* If you want all objects to be returned. This should be used with care
*/
// @ApiMember(Description="If you want all objects to be returned. This should be used with care")
public var all:Bool
/**
* The number per page to retrieve
*/
// @ApiMember(Description="The number per page to retrieve")
public var countPerPage:Int
/**
* Specific IDs
*/
// @ApiMember(Description="Specific IDs")
public var specificIds:[String]
/**
* Specify a sort field
*/
// @ApiMember(Description="Specify a sort field")
public var sortField:String
/**
* Specify a sort order
*/
// @ApiMember(Description="Specify a sort order")
public var sortOrder:SortOrders
/**
* Disables total / page counts - improves performance. Returns only data. If there is no more data, Items will be empty array
*/
// @ApiMember(Description="Disables total / page counts - improves performance. Returns only data. If there is no more data, Items will be empty array")
public var simplifiedPaging:Bool
required public init(){}
}
public enum SortOrders : String, Codable
{
case Ascend
case Descend
}
public class AlertInfo : EntityInfo
{
/**
* The ID of the account associated with this alert
*/
// @ApiMember(Description="The ID of the account associated with this alert")
public var accountId:String
/**
* The name of the alert
*/
// @ApiMember(Description="The name of the alert")
public var name:String
/**
* The trigger alert
*/
// @ApiMember(Description="The trigger alert")
public var trigger:AlertTriggers
/**
* 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")
public var windowHours:Double
/**
* The value at which the alert will trigger
*/
// @ApiMember(Description="The value at which the alert will trigger")
public var threshold:Double
/**
* The email addresses (one per line) to notify
*/
// @ApiMember(Description="The email addresses (one per line) to notify")
public var notificationEmailAddresses:String
/**
* Customer selection for this alert
*/
// @ApiMember(Description="Customer selection for this alert")
public var customerSelection:AlertCustomerSelection
/**
* The list of customer IDs for the selection model
*/
// @ApiMember(Description="The list of customer IDs for the selection model")
public var customerIds:[String]
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case accountId
case name
case trigger
case windowHours
case threshold
case notificationEmailAddresses
case customerSelection
case customerIds
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
accountId = try container.decodeIfPresent(String.self, forKey: .accountId)
name = try container.decodeIfPresent(String.self, forKey: .name)
trigger = try container.decodeIfPresent(AlertTriggers.self, forKey: .trigger)
windowHours = try container.decodeIfPresent(Double.self, forKey: .windowHours)
threshold = try container.decodeIfPresent(Double.self, forKey: .threshold)
notificationEmailAddresses = try container.decodeIfPresent(String.self, forKey: .notificationEmailAddresses)
customerSelection = try container.decodeIfPresent(AlertCustomerSelection.self, forKey: .customerSelection)
customerIds = try container.decodeIfPresent([String].self, forKey: .customerIds) ?? []
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if accountId != nil { try container.encode(accountId, forKey: .accountId) }
if name != nil { try container.encode(name, forKey: .name) }
if trigger != nil { try container.encode(trigger, forKey: .trigger) }
if windowHours != nil { try container.encode(windowHours, forKey: .windowHours) }
if threshold != nil { try container.encode(threshold, forKey: .threshold) }
if notificationEmailAddresses != nil { try container.encode(notificationEmailAddresses, forKey: .notificationEmailAddresses) }
if customerSelection != nil { try container.encode(customerSelection, forKey: .customerSelection) }
if customerIds != nil { try container.encode(customerIds, forKey: .customerIds) }
}
}
public class EntityInfo : Codable
{
/**
* The ID of the object
*/
// @ApiMember(Description="The ID of the object")
public var id:String
/**
* The date the object was created
*/
// @ApiMember(Description="The date the object was created")
public var dateCreated:String
/**
* The date the object was last modified
*/
// @ApiMember(Description="The date the object was last modified")
public var dateLastModified:String
/**
* The user that created this object
*/
// @ApiMember(Description="The user that created this object")
public var createdBy:String
/**
* The user that last modified this object
*/
// @ApiMember(Description="The user that last modified this object")
public var lastModifiedBy:String
required public init(){}
}
public enum AlertTriggers : String, Codable
{
case CallSpend
case CallCount
}
public enum AlertCustomerSelection : String, Codable
{
case AllCustomers
case ExcludeCustomers
case IncludeCustomers
}
public class ListResponse<T : Codable> : Codable
{
/**
* The items
*/
// @ApiMember(Description="The items")
public var items:[AccountInfo]
/**
* The total number of items
*/
// @ApiMember(Description="The total number of items")
public var totalCount:Int
/**
* The total number of pages
*/
// @ApiMember(Description="The total number of pages")
public var totalPages:Int
/**
* Are there more pages of items? Used with simplified paging
*/
// @ApiMember(Description="Are there more pages of items? Used with simplified paging")
public var hasMorePages:Bool
required public init(){}
}
public class AccountInfo : EntityInfo
{
/**
* The name of this account
*/
// @ApiMember(Description="The name of this account")
public var name:String
/**
* The ID of this account's parent
*/
// @ApiMember(Description="The ID of this account's parent")
public var parentAccountId:String
/**
* The twilio account SID
*/
// @ApiMember(Description="The twilio account SID")
public var twilioAccountSid:String
/**
* The ancestors of this account. Useful for breadcrumbs
*/
// @ApiMember(Description="The ancestors of this account. Useful for breadcrumbs")
public var ancestorIds:[String]
/**
* The max number of phone numbers this account can have
*/
// @ApiMember(Description="The max number of phone numbers this account can have")
public var maxPhoneNumbers:Int
/**
* This account is BYOA
*/
// @ApiMember(Description="This account is BYOA")
public var isBYOA:Bool
/**
* TrustHub Profile Sid
*/
// @ApiMember(Description="TrustHub Profile Sid")
public var trustHubProfileSid:String
/**
* The ID of the logo file
*/
// @ApiMember(Description="The ID of the logo file")
public var logoId:String
/**
* The URI of the logo file
*/
// @ApiMember(Description="The URI of the logo file")
public var logoUri:String
/**
* The billing settings for this account
*/
// @ApiMember(Description="The billing settings for this account")
public var billingSettings:BillingSettings
/**
* Enable international settings for the account?
*/
// @ApiMember(Description="Enable international settings for the account?")
public var enableInternationalSettings:Bool
/**
* The default list of country codes the account can dial when not specified on customer
*/
// @ApiMember(Description="The default list of country codes the account can dial when not specified on customer")
public var defaultInternationalCountryCodes:[String]
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case name
case parentAccountId
case twilioAccountSid
case ancestorIds
case maxPhoneNumbers
case isBYOA
case trustHubProfileSid
case logoId
case logoUri
case billingSettings
case enableInternationalSettings
case defaultInternationalCountryCodes
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
name = try container.decodeIfPresent(String.self, forKey: .name)
parentAccountId = try container.decodeIfPresent(String.self, forKey: .parentAccountId)
twilioAccountSid = try container.decodeIfPresent(String.self, forKey: .twilioAccountSid)
ancestorIds = try container.decodeIfPresent([String].self, forKey: .ancestorIds) ?? []
maxPhoneNumbers = try container.decodeIfPresent(Int.self, forKey: .maxPhoneNumbers)
isBYOA = try container.decodeIfPresent(Bool.self, forKey: .isBYOA)
trustHubProfileSid = try container.decodeIfPresent(String.self, forKey: .trustHubProfileSid)
logoId = try container.decodeIfPresent(String.self, forKey: .logoId)
logoUri = try container.decodeIfPresent(String.self, forKey: .logoUri)
billingSettings = try container.decodeIfPresent(BillingSettings.self, forKey: .billingSettings)
enableInternationalSettings = try container.decodeIfPresent(Bool.self, forKey: .enableInternationalSettings)
defaultInternationalCountryCodes = try container.decodeIfPresent([String].self, forKey: .defaultInternationalCountryCodes) ?? []
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if name != nil { try container.encode(name, forKey: .name) }
if parentAccountId != nil { try container.encode(parentAccountId, forKey: .parentAccountId) }
if twilioAccountSid != nil { try container.encode(twilioAccountSid, forKey: .twilioAccountSid) }
if ancestorIds != nil { try container.encode(ancestorIds, forKey: .ancestorIds) }
if maxPhoneNumbers != nil { try container.encode(maxPhoneNumbers, forKey: .maxPhoneNumbers) }
if isBYOA != nil { try container.encode(isBYOA, forKey: .isBYOA) }
if trustHubProfileSid != nil { try container.encode(trustHubProfileSid, forKey: .trustHubProfileSid) }
if logoId != nil { try container.encode(logoId, forKey: .logoId) }
if logoUri != nil { try container.encode(logoUri, forKey: .logoUri) }
if billingSettings != nil { try container.encode(billingSettings, forKey: .billingSettings) }
if enableInternationalSettings != nil { try container.encode(enableInternationalSettings, forKey: .enableInternationalSettings) }
if defaultInternationalCountryCodes != nil { try container.encode(defaultInternationalCountryCodes, forKey: .defaultInternationalCountryCodes) }
}
}
public class BillingSettings : Codable
{
public var base:BillingItem
public var localNumbers:BillingItem
public var tollFreeNumbers:BillingItem
public var inboundVoiceCalls:BillingItem
public var outboundVoiceCalls:BillingItem
public var inboundFaxes:BillingItem
public var outboundFaxes:BillingItem
public var inboundSmsMessages:BillingItem
public var outboundSmsMessages:BillingItem
public var aiInsights:BillingItem
public var aiLiveMinutes:BillingItem
public var aiMessages:BillingItem
public var aiTranscriptions:BillingItem
required public init(){}
}
public class BillingItem : Codable
{
public var baseCost:Double
public var rawUnitMultiplier:Double
public var unitCost:Double
public var allowance:Int
required public init(){}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /alerts HTTP/1.1 Host: evovoice.io Accept: application/xml
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length
<ListResponseOfAlertInfoLEzmHoIb xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Voice.Api">
<HasMorePages>false</HasMorePages>
<Items xmlns:d2p1="http://schemas.datacontract.org/2004/07/Voice.Api.Alerts">
<d2p1:AlertInfo>
<CreatedBy>String</CreatedBy>
<DateCreated>String</DateCreated>
<DateLastModified>String</DateLastModified>
<Id>String</Id>
<LastModifiedBy>String</LastModifiedBy>
<d2p1:AccountId>String</d2p1:AccountId>
<d2p1:CustomerIds xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d4p1:string>String</d4p1:string>
</d2p1:CustomerIds>
<d2p1:CustomerSelection>AllCustomers</d2p1:CustomerSelection>
<d2p1:Name>String</d2p1:Name>
<d2p1:NotificationEmailAddresses>String</d2p1:NotificationEmailAddresses>
<d2p1:Threshold>0</d2p1:Threshold>
<d2p1:Trigger>CallSpend</d2p1:Trigger>
<d2p1:WindowHours>0</d2p1:WindowHours>
</d2p1:AlertInfo>
</Items>
<TotalCount>0</TotalCount>
<TotalPages>0</TotalPages>
</ListResponseOfAlertInfoLEzmHoIb>