Evo Voice

<back to all web services

ListFiles

Query for files

Requires Authentication
Requires any of the roles:SystemAdministrator, Manager, Customer
The following routes are available for this service:
GET/files
import Foundation
import ServiceStack

/**
* Query for files
*/
// @Api(Description="Query for files")
public class ListFiles : ListRequest<FileInfo>
{
    /**
    * Filter by account id
    */
    // @ApiMember(Description="Filter by account id")
    public var accountIds:[String] = []

    /**
    * Filter by customer id
    */
    // @ApiMember(Description="Filter by customer id")
    public var customerIds:[String] = []

    /**
    * Filter by specific session
    */
    // @ApiMember(Description="Filter by specific session")
    public var sessionId:String?

    /**
    * Filter by file name (contains filter)
    */
    // @ApiMember(Description="Filter by file name (contains filter)")
    public var fileName:String?

    /**
    * Filter by content type (contains filter)
    */
    // @ApiMember(Description="Filter by content type (contains filter)")
    public var contentType:String?

    /**
    * Filter by type
    */
    // @ApiMember(Description="Filter by type")
    public var type:FileTypes?

    /**
    * Filter by date created (start of range)
    */
    // @ApiMember(Description="Filter by date created (start of range)")
    public var dateCreatedStart:String?

    /**
    * Filter by date created (end of range)
    */
    // @ApiMember(Description="Filter by date created (end of range)")
    public var dateCreatedEnd:String?

    /**
    * Filter by agent ID
    */
    // @ApiMember(Description="Filter by agent ID")
    public var userId:String?

    /**
    * Search transcription
    */
    // @ApiMember(Description="Search transcription")
    public var transcriptionContains:String?

    required public init(){ super.init() }

    private enum CodingKeys : String, CodingKey {
        case accountIds
        case customerIds
        case sessionId
        case fileName
        case contentType
        case type
        case dateCreatedStart
        case dateCreatedEnd
        case userId
        case transcriptionContains
    }

    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) ?? []
        customerIds = try container.decodeIfPresent([String].self, forKey: .customerIds) ?? []
        sessionId = try container.decodeIfPresent(String.self, forKey: .sessionId)
        fileName = try container.decodeIfPresent(String.self, forKey: .fileName)
        contentType = try container.decodeIfPresent(String.self, forKey: .contentType)
        type = try container.decodeIfPresent(FileTypes.self, forKey: .type)
        dateCreatedStart = try container.decodeIfPresent(String.self, forKey: .dateCreatedStart)
        dateCreatedEnd = try container.decodeIfPresent(String.self, forKey: .dateCreatedEnd)
        userId = try container.decodeIfPresent(String.self, forKey: .userId)
        transcriptionContains = try container.decodeIfPresent(String.self, forKey: .transcriptionContains)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if accountIds.count > 0 { try container.encode(accountIds, forKey: .accountIds) }
        if customerIds.count > 0 { try container.encode(customerIds, forKey: .customerIds) }
        if sessionId != nil { try container.encode(sessionId, forKey: .sessionId) }
        if fileName != nil { try container.encode(fileName, forKey: .fileName) }
        if contentType != nil { try container.encode(contentType, forKey: .contentType) }
        if type != nil { try container.encode(type, forKey: .type) }
        if dateCreatedStart != nil { try container.encode(dateCreatedStart, forKey: .dateCreatedStart) }
        if dateCreatedEnd != nil { try container.encode(dateCreatedEnd, forKey: .dateCreatedEnd) }
        if userId != nil { try container.encode(userId, forKey: .userId) }
        if transcriptionContains != nil { try container.encode(transcriptionContains, forKey: .transcriptionContains) }
    }
}

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 FileInfo : EntityInfo
{
    /**
    * The type of file this is
    */
    // @ApiMember(Description="The type of file this is")
    public var type:FileTypes?

    /**
    * The account ID this file is associated with
    */
    // @ApiMember(Description="The account ID this file is associated with")
    public var accountId:String?

    /**
    * The name of the account this file is associated with
    */
    // @ApiMember(Description="The name of the account this file is associated with")
    public var accountName:String?

    /**
    * The ID of the customer this file is associated with
    */
    // @ApiMember(Description="The ID of the customer this file is associated with")
    public var customerId:String?

    /**
    * The name of the customer this file is associated with
    */
    // @ApiMember(Description="The name of the customer this file is associated with")
    public var customerName:String?

    /**
    * The breadcrumb to the customer for this file
    */
    // @ApiMember(Description="The breadcrumb to the customer for this file")
    public var customerBreadcrumb:[CustomerBreadcrumb] = []

    /**
    * The ID of the user this file is assocaited with
    */
    // @ApiMember(Description="The ID of the user this file is assocaited with")
    public var userId:String?

    /**
    * The name of the user this file is associated with
    */
    // @ApiMember(Description="The name of the user this file is associated with")
    public var userName:String?

    /**
    * The original file name for the file
    */
    // @ApiMember(Description="The original file name for the file")
    public var fileName:String?

    /**
    * The URI of the file
    */
    // @ApiMember(Description="The URI of the file")
    public var uri:String?

    /**
    * The Content type of the file
    */
    // @ApiMember(Description="The Content type of the file")
    public var contentType:String?

    /**
    * The size of the file
    */
    // @ApiMember(Description="The size of the file")
    public var contentLength:Int?

    /**
    * The Twilio ID of the recording
    */
    // @ApiMember(Description="The Twilio ID of the recording")
    public var recordingSid:String?

    /**
    * The duration of the recording in seconds
    */
    // @ApiMember(Description="The duration of the recording in seconds")
    public var recordingDuration:Int?

    /**
    * Who is the recording from?
    */
    // @ApiMember(Description="Who is the recording from?")
    public var recordingFrom:String?

    /**
    * Transcription (if available)
    */
    // @ApiMember(Description="Transcription (if available)")
    public var transcription:String?

    /**
    * From Address (e.g. caller ID) for incoming calls
    */
    // @ApiMember(Description="From Address (e.g. caller ID) for incoming calls")
    public var fromAddress:String?

    /**
    * To Address (e.g. dialed number) for outgoing calls
    */
    // @ApiMember(Description="To Address (e.g. dialed number) for outgoing calls")
    public var toAddress:String?

    required public init(){ super.init() }

    private enum CodingKeys : String, CodingKey {
        case type
        case accountId
        case accountName
        case customerId
        case customerName
        case customerBreadcrumb
        case userId
        case userName
        case fileName
        case uri
        case contentType
        case contentLength
        case recordingSid
        case recordingDuration
        case recordingFrom
        case transcription
        case fromAddress
        case toAddress
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        type = try container.decodeIfPresent(FileTypes.self, forKey: .type)
        accountId = try container.decodeIfPresent(String.self, forKey: .accountId)
        accountName = try container.decodeIfPresent(String.self, forKey: .accountName)
        customerId = try container.decodeIfPresent(String.self, forKey: .customerId)
        customerName = try container.decodeIfPresent(String.self, forKey: .customerName)
        customerBreadcrumb = try container.decodeIfPresent([CustomerBreadcrumb].self, forKey: .customerBreadcrumb) ?? []
        userId = try container.decodeIfPresent(String.self, forKey: .userId)
        userName = try container.decodeIfPresent(String.self, forKey: .userName)
        fileName = try container.decodeIfPresent(String.self, forKey: .fileName)
        uri = try container.decodeIfPresent(String.self, forKey: .uri)
        contentType = try container.decodeIfPresent(String.self, forKey: .contentType)
        contentLength = try container.decodeIfPresent(Int.self, forKey: .contentLength)
        recordingSid = try container.decodeIfPresent(String.self, forKey: .recordingSid)
        recordingDuration = try container.decodeIfPresent(Int.self, forKey: .recordingDuration)
        recordingFrom = try container.decodeIfPresent(String.self, forKey: .recordingFrom)
        transcription = try container.decodeIfPresent(String.self, forKey: .transcription)
        fromAddress = try container.decodeIfPresent(String.self, forKey: .fromAddress)
        toAddress = try container.decodeIfPresent(String.self, forKey: .toAddress)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if type != nil { try container.encode(type, forKey: .type) }
        if accountId != nil { try container.encode(accountId, forKey: .accountId) }
        if accountName != nil { try container.encode(accountName, forKey: .accountName) }
        if customerId != nil { try container.encode(customerId, forKey: .customerId) }
        if customerName != nil { try container.encode(customerName, forKey: .customerName) }
        if customerBreadcrumb.count > 0 { try container.encode(customerBreadcrumb, forKey: .customerBreadcrumb) }
        if userId != nil { try container.encode(userId, forKey: .userId) }
        if userName != nil { try container.encode(userName, forKey: .userName) }
        if fileName != nil { try container.encode(fileName, forKey: .fileName) }
        if uri != nil { try container.encode(uri, forKey: .uri) }
        if contentType != nil { try container.encode(contentType, forKey: .contentType) }
        if contentLength != nil { try container.encode(contentLength, forKey: .contentLength) }
        if recordingSid != nil { try container.encode(recordingSid, forKey: .recordingSid) }
        if recordingDuration != nil { try container.encode(recordingDuration, forKey: .recordingDuration) }
        if recordingFrom != nil { try container.encode(recordingFrom, forKey: .recordingFrom) }
        if transcription != nil { try container.encode(transcription, forKey: .transcription) }
        if fromAddress != nil { try container.encode(fromAddress, forKey: .fromAddress) }
        if toAddress != nil { try container.encode(toAddress, forKey: .toAddress) }
    }
}

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 FileTypes : String, Codable
{
    case Upload
    case VoiceMessage
    case CallRecording
    case Fax
    case Attachment
    case FaxOutgoing
}

public class CustomerBreadcrumb : Codable
{
    public var id:String?
    public var name:String?

    required public init(){}
}

public class ListResponse<AccountInfo : 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?

    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
    }

    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)
    }

    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.count > 0 { 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) }
    }
}

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?

    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(){}
}


Swift ListFiles DTOs

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

HTTP + XML

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

GET /files HTTP/1.1 
Host: evovoice.io 
Accept: application/xml
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<ListResponseOfFileInfoS8MZGchS 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.Files">
    <d2p1:FileInfo>
      <CreatedBy>String</CreatedBy>
      <DateCreated>String</DateCreated>
      <DateLastModified>String</DateLastModified>
      <Id>String</Id>
      <LastModifiedBy>String</LastModifiedBy>
      <d2p1:AccountId>String</d2p1:AccountId>
      <d2p1:AccountName>String</d2p1:AccountName>
      <d2p1:ContentLength>0</d2p1:ContentLength>
      <d2p1:ContentType>String</d2p1:ContentType>
      <d2p1:CustomerBreadcrumb xmlns:d4p1="http://schemas.datacontract.org/2004/07/Voice.Api.Customers">
        <d4p1:CustomerBreadcrumb>
          <d4p1:Id>String</d4p1:Id>
          <d4p1:Name>String</d4p1:Name>
        </d4p1:CustomerBreadcrumb>
      </d2p1:CustomerBreadcrumb>
      <d2p1:CustomerId>String</d2p1:CustomerId>
      <d2p1:CustomerName>String</d2p1:CustomerName>
      <d2p1:FileName>String</d2p1:FileName>
      <d2p1:FromAddress>String</d2p1:FromAddress>
      <d2p1:RecordingDuration>0</d2p1:RecordingDuration>
      <d2p1:RecordingFrom>String</d2p1:RecordingFrom>
      <d2p1:RecordingSid>String</d2p1:RecordingSid>
      <d2p1:ToAddress>String</d2p1:ToAddress>
      <d2p1:Transcription>String</d2p1:Transcription>
      <d2p1:Type>Upload</d2p1:Type>
      <d2p1:Uri>String</d2p1:Uri>
      <d2p1:UserId>String</d2p1:UserId>
      <d2p1:UserName>String</d2p1:UserName>
    </d2p1:FileInfo>
  </Items>
  <TotalCount>0</TotalCount>
  <TotalPages>0</TotalPages>
</ListResponseOfFileInfoS8MZGchS>