Evo Voice

<back to all web services

InviteChatMember

Add a member to the chat session

Requires Authentication
Required role:User
The following routes are available for this service:
POST/sessions/{sessionId}/members
import Foundation
import ServiceStack

/**
* Add a member to the chat session
*/
// @Api(Description="Add a member to the chat session")
public class InviteChatMember : IPost, Codable
{
    /**
    * The ID of the session
    */
    // @ApiMember(Description="The ID of the session")
    public var sessionId:String?

    /**
    * The member to add. This can be a cell phone number, user ID (email)
    */
    // @ApiMember(Description="The member to add. This can be a cell phone number, user ID (email)")
    public var memberToAdd:String?

    /**
    * Outbound caller ID to use
    */
    // @ApiMember(Description="Outbound caller ID to use")
    public var callerId:String?

    required public init(){}
}

public class SessionInfo : EntityInfo
{
    /**
    * The state of the session
    */
    // @ApiMember(Description="The state of the session")
    public var dialState:SessionDialState?

    /**
    * The call state of the session
    */
    // @ApiMember(Description="The call state of the session")
    public var callState:SessionCallState?

    /**
    * The queue state of the session
    */
    // @ApiMember(Description="The queue state of the session")
    public var queueState:SessionQueueStates?

    /**
    * The ID of the account associated with the flow
    */
    // @ApiMember(Description="The ID of the account associated with the flow")
    public var accountId:String?

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

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

    /**
    * The customer breadcrumb this session is associated with
    */
    // @ApiMember(Description="The customer breadcrumb this session is associated with")
    public var customerBreadcrumb:[CustomerBreadcrumb] = []

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

    /**
    * The ID of the endpoint associated with this session
    */
    // @ApiMember(Description="The ID of the endpoint associated with this session")
    public var endpointId:String?

    /**
    * The name of the endpoint associated with this session
    */
    // @ApiMember(Description="The name of the endpoint associated with this session")
    public var endpointName:String?

    /**
    * The date the call completed
    */
    // @ApiMember(Description="The date the call completed")
    public var dateCompleted:String?

    /**
    * The destination of the session (e.g. what was entered into the Dial box)
    */
    // @ApiMember(Description="The destination of the session (e.g. what was entered into the Dial box)")
    public var destination:String?

    /**
    * The to address if any
    */
    // @ApiMember(Description="The to address if any")
    public var toAddress:String?

    /**
    * The from address if any
    */
    // @ApiMember(Description="The from address if any")
    public var fromAddress:String?

    /**
    * The from name if any
    */
    // @ApiMember(Description="The from name if any")
    public var fromName:String?

    /**
    * Answered by name (if any)
    */
    // @ApiMember(Description="Answered by name (if any)")
    public var answeredByName:String?

    /**
    * The ID of the queue member assigned to this call
    */
    // @ApiMember(Description="The ID of the queue member assigned to this call")
    public var queueMemberId:String?

    /**
    * The flow channel
    */
    // @ApiMember(Description="The flow channel")
    public var channel:FlowChannels?

    /**
    * Has the session ended
    */
    // @ApiMember(Description="Has the session ended")
    public var ended:Bool?

    /**
    * The outcome of the call
    */
    // @ApiMember(Description="The outcome of the call")
    public var outcome:String?

    /**
    * The twilio Call SID of this session
    */
    // @ApiMember(Description="The twilio Call SID of this session")
    public var callSid:String?

    /**
    * Any console data for this session
    */
    // @ApiMember(Description="Any console data for this session")
    public var consoleData:String?

    /**
    * The name of the hold queue for this call
    */
    // @ApiMember(Description="The name of the hold queue for this call")
    public var holdQueueName:String?

    /**
    * The user ID who put this call on hold
    */
    // @ApiMember(Description="The user ID who put this call on hold")
    public var heldByUserId:String?

    /**
    * The reason for the hold
    */
    // @ApiMember(Description="The reason for the hold")
    public var holdReason:SessionHoldReasons?

    /**
    * The SID of the conference if in a conference call
    */
    // @ApiMember(Description="The SID of the conference if in a conference call")
    public var conferenceSid:String?

    /**
    * The display name for this session
    */
    // @ApiMember(Description="The display name for this session")
    public var displayName:String?

    /**
    * The log entries for this session
    */
    // @ApiMember(Description="The log entries for this session")
    public var log:[SessionLogInfo] = []

    /**
    * The members of this session
    */
    // @ApiMember(Description="The members of this session")
    public var members:[SessionMemberInfo] = []

    /**
    * The callback number (typically used for SIP to User calls)
    */
    // @ApiMember(Description="The callback number (typically used for SIP to User calls)")
    public var callbackNumber:String?

    /**
    * The ID of the endpoint that answered
    */
    // @ApiMember(Description="The ID of the endpoint that answered")
    public var answeredById:String?

    /**
    * Is this session incoming or outgoing?
    */
    // @ApiMember(Description="Is this session incoming or outgoing?")
    public var direction:SessionDirections?

    /**
    * The phone number that this session is coming from (used with SMS chats)
    */
    // @ApiMember(Description="The phone number that this session is coming from (used with SMS chats)")
    public var fromPhoneNumber:String?

    /**
    * The Call SID of the most recently added conference participant
    */
    // @ApiMember(Description="The Call SID of the most recently added conference participant")
    public var mostRecentParticipantCallSid:String?

    /**
    * Was this session missed?
    */
    // @ApiMember(Description="Was this session missed?")
    public var wasMissed:Bool?

    /**
    * The ring queue that the call is currently in
    */
    // @ApiMember(Description="The ring queue that the call is currently in")
    public var ringQueueId:String?

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

    private enum CodingKeys : String, CodingKey {
        case dialState
        case callState
        case queueState
        case accountId
        case accountName
        case customerId
        case customerBreadcrumb
        case customerName
        case endpointId
        case endpointName
        case dateCompleted
        case destination
        case toAddress
        case fromAddress
        case fromName
        case answeredByName
        case queueMemberId
        case channel
        case ended
        case outcome
        case callSid
        case consoleData
        case holdQueueName
        case heldByUserId
        case holdReason
        case conferenceSid
        case displayName
        case log
        case members
        case callbackNumber
        case answeredById
        case direction
        case fromPhoneNumber
        case mostRecentParticipantCallSid
        case wasMissed
        case ringQueueId
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        dialState = try container.decodeIfPresent(SessionDialState.self, forKey: .dialState)
        callState = try container.decodeIfPresent(SessionCallState.self, forKey: .callState)
        queueState = try container.decodeIfPresent(SessionQueueStates.self, forKey: .queueState)
        accountId = try container.decodeIfPresent(String.self, forKey: .accountId)
        accountName = try container.decodeIfPresent(String.self, forKey: .accountName)
        customerId = try container.decodeIfPresent(String.self, forKey: .customerId)
        customerBreadcrumb = try container.decodeIfPresent([CustomerBreadcrumb].self, forKey: .customerBreadcrumb) ?? []
        customerName = try container.decodeIfPresent(String.self, forKey: .customerName)
        endpointId = try container.decodeIfPresent(String.self, forKey: .endpointId)
        endpointName = try container.decodeIfPresent(String.self, forKey: .endpointName)
        dateCompleted = try container.decodeIfPresent(String.self, forKey: .dateCompleted)
        destination = try container.decodeIfPresent(String.self, forKey: .destination)
        toAddress = try container.decodeIfPresent(String.self, forKey: .toAddress)
        fromAddress = try container.decodeIfPresent(String.self, forKey: .fromAddress)
        fromName = try container.decodeIfPresent(String.self, forKey: .fromName)
        answeredByName = try container.decodeIfPresent(String.self, forKey: .answeredByName)
        queueMemberId = try container.decodeIfPresent(String.self, forKey: .queueMemberId)
        channel = try container.decodeIfPresent(FlowChannels.self, forKey: .channel)
        ended = try container.decodeIfPresent(Bool.self, forKey: .ended)
        outcome = try container.decodeIfPresent(String.self, forKey: .outcome)
        callSid = try container.decodeIfPresent(String.self, forKey: .callSid)
        consoleData = try container.decodeIfPresent(String.self, forKey: .consoleData)
        holdQueueName = try container.decodeIfPresent(String.self, forKey: .holdQueueName)
        heldByUserId = try container.decodeIfPresent(String.self, forKey: .heldByUserId)
        holdReason = try container.decodeIfPresent(SessionHoldReasons.self, forKey: .holdReason)
        conferenceSid = try container.decodeIfPresent(String.self, forKey: .conferenceSid)
        displayName = try container.decodeIfPresent(String.self, forKey: .displayName)
        log = try container.decodeIfPresent([SessionLogInfo].self, forKey: .log) ?? []
        members = try container.decodeIfPresent([SessionMemberInfo].self, forKey: .members) ?? []
        callbackNumber = try container.decodeIfPresent(String.self, forKey: .callbackNumber)
        answeredById = try container.decodeIfPresent(String.self, forKey: .answeredById)
        direction = try container.decodeIfPresent(SessionDirections.self, forKey: .direction)
        fromPhoneNumber = try container.decodeIfPresent(String.self, forKey: .fromPhoneNumber)
        mostRecentParticipantCallSid = try container.decodeIfPresent(String.self, forKey: .mostRecentParticipantCallSid)
        wasMissed = try container.decodeIfPresent(Bool.self, forKey: .wasMissed)
        ringQueueId = try container.decodeIfPresent(String.self, forKey: .ringQueueId)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if dialState != nil { try container.encode(dialState, forKey: .dialState) }
        if callState != nil { try container.encode(callState, forKey: .callState) }
        if queueState != nil { try container.encode(queueState, forKey: .queueState) }
        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 customerBreadcrumb.count > 0 { try container.encode(customerBreadcrumb, forKey: .customerBreadcrumb) }
        if customerName != nil { try container.encode(customerName, forKey: .customerName) }
        if endpointId != nil { try container.encode(endpointId, forKey: .endpointId) }
        if endpointName != nil { try container.encode(endpointName, forKey: .endpointName) }
        if dateCompleted != nil { try container.encode(dateCompleted, forKey: .dateCompleted) }
        if destination != nil { try container.encode(destination, forKey: .destination) }
        if toAddress != nil { try container.encode(toAddress, forKey: .toAddress) }
        if fromAddress != nil { try container.encode(fromAddress, forKey: .fromAddress) }
        if fromName != nil { try container.encode(fromName, forKey: .fromName) }
        if answeredByName != nil { try container.encode(answeredByName, forKey: .answeredByName) }
        if queueMemberId != nil { try container.encode(queueMemberId, forKey: .queueMemberId) }
        if channel != nil { try container.encode(channel, forKey: .channel) }
        if ended != nil { try container.encode(ended, forKey: .ended) }
        if outcome != nil { try container.encode(outcome, forKey: .outcome) }
        if callSid != nil { try container.encode(callSid, forKey: .callSid) }
        if consoleData != nil { try container.encode(consoleData, forKey: .consoleData) }
        if holdQueueName != nil { try container.encode(holdQueueName, forKey: .holdQueueName) }
        if heldByUserId != nil { try container.encode(heldByUserId, forKey: .heldByUserId) }
        if holdReason != nil { try container.encode(holdReason, forKey: .holdReason) }
        if conferenceSid != nil { try container.encode(conferenceSid, forKey: .conferenceSid) }
        if displayName != nil { try container.encode(displayName, forKey: .displayName) }
        if log.count > 0 { try container.encode(log, forKey: .log) }
        if members.count > 0 { try container.encode(members, forKey: .members) }
        if callbackNumber != nil { try container.encode(callbackNumber, forKey: .callbackNumber) }
        if answeredById != nil { try container.encode(answeredById, forKey: .answeredById) }
        if direction != nil { try container.encode(direction, forKey: .direction) }
        if fromPhoneNumber != nil { try container.encode(fromPhoneNumber, forKey: .fromPhoneNumber) }
        if mostRecentParticipantCallSid != nil { try container.encode(mostRecentParticipantCallSid, forKey: .mostRecentParticipantCallSid) }
        if wasMissed != nil { try container.encode(wasMissed, forKey: .wasMissed) }
        if ringQueueId != nil { try container.encode(ringQueueId, forKey: .ringQueueId) }
    }
}

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 SessionDialState : String, Codable
{
    case None
    case Active
}

public enum SessionCallState : String, Codable
{
    case Disconnected
    case Ringing
    case Connected
    case Hold
    case Passive
}

public enum SessionQueueStates : String, Codable
{
    case None
    case Queued
    case Ringing
    case Connected
    case Hold
    case Disconnected
}

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

    required public init(){}
}

public enum FlowChannels : String, Codable
{
    case Voice
    case Chat
    case Fax
}

public enum SessionHoldReasons : String, Codable
{
    case None
    case Transferring
}

public class SessionLogInfo : Codable
{
    public var date:String?
    public var message:String?

    required public init(){}
}

public class SessionMemberInfo : Codable
{
    public var identity:String?
    public var endpointId:String?
    public var displayName:String?
    public var isOriginalMember:Bool?
    public var avatarUrl:String?
    public var applicationData:[String:String] = [:]
    public var callState:SessionMemberCallState?
    public var role:SessionMemberRoles?
    public var callSid:String?
    public var muted:Bool?

    required public init(){}
}

public enum SessionMemberCallState : String, Codable
{
    case None
    case Ringing
    case Connected
    case Hold
}

public enum SessionMemberRoles : String, Codable
{
    case None
    case Caller
    case Agent
    case Transfer
}

public enum SessionDirections : String, Codable
{
    case Incoming
    case Outgoing
}


Swift InviteChatMember 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 /sessions/{sessionId}/members HTTP/1.1 
Host: evovoice.io 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	sessionId: String,
	memberToAdd: String,
	callerId: String
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	dialState: None,
	callState: Disconnected,
	queueState: None,
	accountId: String,
	accountName: String,
	customerId: String,
	customerBreadcrumb: 
	[
		{
			id: String,
			name: String
		}
	],
	customerName: String,
	endpointId: String,
	endpointName: String,
	dateCompleted: String,
	destination: String,
	toAddress: String,
	fromAddress: String,
	fromName: String,
	answeredByName: String,
	queueMemberId: String,
	channel: Voice,
	ended: False,
	outcome: String,
	callSid: String,
	consoleData: String,
	holdQueueName: String,
	heldByUserId: String,
	holdReason: None,
	conferenceSid: String,
	displayName: String,
	log: 
	[
		{
			date: String,
			message: String
		}
	],
	members: 
	[
		{
			identity: String,
			endpointId: String,
			displayName: String,
			isOriginalMember: False,
			avatarUrl: String,
			applicationData: 
			{
				String: String
			},
			callState: None,
			role: None,
			callSid: String,
			muted: False
		}
	],
	callbackNumber: String,
	answeredById: String,
	direction: Incoming,
	fromPhoneNumber: String,
	mostRecentParticipantCallSid: String,
	wasMissed: False,
	ringQueueId: String,
	id: String,
	dateCreated: String,
	dateLastModified: String,
	createdBy: String,
	lastModifiedBy: String
}