244 lines
11 KiB
Go
244 lines
11 KiB
Go
package models
|
|
|
|
// AnalyticsConversationWithAttributesQuery is used to bind the results of a paginated GenesysCloud API request.
|
|
type AnalyticsConversationWithAttributesQuery struct {
|
|
Conversations []AnalyticsConversationWithAttributes `json:"conversations"`
|
|
Cursor *string `json:"cursor"`
|
|
}
|
|
|
|
// AnalyticsConversationWithAttributes is used to bind the results of a GenesysCloud API request.
|
|
//
|
|
// It is a hierarchical structure (Participants has many Sessions has many Segments) and needs to be flattened into multiple tables prior to being saved in the database.
|
|
//
|
|
// The following payload JSON fields have an expected structure:
|
|
// - Participants
|
|
// - Participants.Sessions
|
|
// - Participants.Sessions.MediaEndpointStats
|
|
// - Participants.Sessions.Metrics
|
|
// - Participants.Sessions.Segments
|
|
type AnalyticsConversationWithAttributes struct {
|
|
ConversationEnd string `json:"conversationEnd"`
|
|
ConversationId string `json:"conversationId"`
|
|
ConversationStart string `json:"conversationStart"`
|
|
DivisionIds []string `json:"divisionIds"`
|
|
ExternalTag string `json:"externalTag"`
|
|
MediaStatsMinConversationMos float32 `json:"mediaStatsMinConversationMos"`
|
|
MediaStatsMinConversationRFactor float32 `json:"mediaStatsMinConversationRFactor"`
|
|
OriginatingDirection string `json:"originatingDirection"`
|
|
Participants []struct {
|
|
ExternalContactId string `json:"externalContactId"`
|
|
ParticipantId string `json:"id"`
|
|
ParticipantName string `json:"participantName"`
|
|
Purpose string `json:"purpose"`
|
|
Sessions []struct {
|
|
ANI string `json:"ani"`
|
|
Direction string `json:"direction"`
|
|
DNIS string `json:"dnis"`
|
|
EdgeId string `json:"edgeId"`
|
|
MediaType string `json:"mediaType"`
|
|
ProtocolCallId string `json:"protocolCallId"`
|
|
Provider string `json:"provider"`
|
|
Recording bool `json:"recording"`
|
|
RemoteNameDisplayable string `json:"remoteNameDisplayable"`
|
|
SessionDnis string `json:"sessionDnis"`
|
|
SessionId string `json:"sessionId"`
|
|
MediaEndpointStats []struct {
|
|
Codecs []string `json:"codecs"`
|
|
EventTime string `json:"eventTime"`
|
|
MaxLatencyMs int `json:"maxLatencyMs"`
|
|
MinMos float32 `json:"minMos"`
|
|
MinRFactor float32 `json:"minRFactor"`
|
|
ReceivedPackets int `json:"receivedPackets"`
|
|
} `json:"mediaEndpointStats"`
|
|
Metrics []struct {
|
|
EmitDate string `json:"emitDate"`
|
|
Name string `json:"name"`
|
|
Value int `json:"value"`
|
|
} `json:"metrics"`
|
|
Segments []struct {
|
|
Conference bool `json:"conference"`
|
|
DisconnectType string `json:"disconnectType"`
|
|
Q850ResponseCodes []int `json:"q850ResponseCodes"`
|
|
SegmentEnd string `json:"segmentEnd"`
|
|
SegmentStart string `json:"segmentStart"`
|
|
SegmentType string `json:"segmentType"`
|
|
WrapUpCode string `json:"wrapUpCode"`
|
|
} `json:"segments"`
|
|
} `json:"sessions"`
|
|
Attributes map[string]any `json:"attributes"`
|
|
} `json:"participants"`
|
|
}
|
|
|
|
// AnalyticsConversationWithoutAttributesQuery is used to bind the results of a paginated GenesysCloud API request.
|
|
type AnalyticsConversationWithoutAttributesQuery struct {
|
|
Conversations []AnalyticsConversationWithoutAttributes `json:"conversations"`
|
|
TotalHits int `json:"totalHits"`
|
|
}
|
|
|
|
// AnalyticsConversationWithoutAttributes is used to bind the results of a GenesysCloud API request.
|
|
//
|
|
// It is a hierarchical structure (Participants has many Sessions has many Segments) and needs to be flattened into multiple tables prior to being saved in the database.
|
|
//
|
|
// The following payload JSON fields have an expected structure:
|
|
// - Participants
|
|
// - Participants.Sessions
|
|
// - Participants.Sessions.Segments
|
|
// - Participants.Sessions.Flow
|
|
// - Participants.Sessions.Metrics
|
|
// - Participants.Sessions.MediaEndpointStats
|
|
type AnalyticsConversationWithoutAttributes struct {
|
|
ConversationId string `json:"conversationId"`
|
|
ConversationStart string `json:"conversationStart"`
|
|
ConversationEnd string `json:"conversationEnd"`
|
|
MediaStatsMinConversationMos float32 `json:"mediaStatsMinConversationMos"`
|
|
MediaStatsMinConversationRFactor float32 `json:"mediaStatsMinConversationRFactor"`
|
|
OriginatingDirection string `json:"originatingDirection"`
|
|
DivisionIds []string `json:"divisionIds"`
|
|
Participants []struct {
|
|
ParticipantId string `json:"participantId"`
|
|
UserId string `json:"userId"`
|
|
ParticipantName string `json:"participantName"`
|
|
Purpose string `json:"purpose"`
|
|
ExternalContactId string `json:"externalContactId"`
|
|
Sessions []struct {
|
|
MediaType string `json:"mediaType"`
|
|
SessionId string `json:"sessionId"`
|
|
ANI string `json:"ani"`
|
|
Direction string `json:"direction"`
|
|
DNIS string `json:"dnis"`
|
|
SessionDNIS string `json:"sessionDnis"`
|
|
EdgeId string `json:"edgeId"`
|
|
RemoteNameDisplayable string `json:"remoteNameDisplayable"`
|
|
Segments []struct {
|
|
SegmentStart string `json:"segmentStart"`
|
|
SegmentEnd string `json:"segmentEnd"`
|
|
WrapUpCode string `json:"wrapUpCode"`
|
|
DisconnectType string `json:"disconnectType"`
|
|
SegmentType string `json:"SegmentType"`
|
|
Q850ResponseCodes []int `json:"q850ResponseCodes"`
|
|
Conference bool `json:"conference"`
|
|
} `json:"segments"`
|
|
Flow struct {
|
|
EndingLanguage string `json:"endingLanguage"`
|
|
EntryReason string `json:"entryReason"`
|
|
EntryType string `json:"entryType"`
|
|
ExitReason string `json:"exitReason"`
|
|
FlowId string `json:"flowId"`
|
|
FlowName string `json:"flowName"`
|
|
FlowType string `json:"flowType"`
|
|
FlowVersion string `json:"flowVersion"`
|
|
StartingLanguage string `json:"startingLanguage"`
|
|
TransferTargetAddress string `json:"transferTargetAddress"`
|
|
TransferTargetName string `json:"transferTargetName"`
|
|
TransferType string `json:"transferType"`
|
|
} `json:"flow"`
|
|
Metrics []struct {
|
|
Name string `json:"name"`
|
|
Value int `json:"value"`
|
|
EmitDate string `json:"emitDate"`
|
|
} `json:"metrics"`
|
|
MediaEndpointStats []struct {
|
|
Codecs []string `json:"codecs"`
|
|
MinMos float32 `json:"minMos"`
|
|
MinRFactor float32 `json:"minRFactor"`
|
|
MaxLatencyMs int `json:"maxLatencyMs"`
|
|
ReceivedPackets int `json:"receivedPackets"`
|
|
} `json:"mediaEndpointStats"`
|
|
Recording bool `json:"recording"`
|
|
ProtocolCallId string `json:"protocolCallId"`
|
|
Provider string `json:"provider"`
|
|
} `json:"sessions"`
|
|
} `json:"participants"`
|
|
}
|
|
|
|
// NotificationConversationWithAttributes is used to bind the results of a GenesysCloud websocket notification.
|
|
//
|
|
// It is a hierarchical structure (Participants has many Sessions has many Segments) and needs to be flattened into multiple tables prior to being saved in the database.
|
|
//
|
|
// The following payload JSON fields have an expected structure:
|
|
// - Divisions
|
|
// - Divisions.Division
|
|
// - Divisions.Entities
|
|
// - Participants
|
|
// - Participants.Calls
|
|
type NotificationConversationWithAttributes struct {
|
|
Address string `json:"address"`
|
|
Divisions []struct {
|
|
Division struct {
|
|
Id string `json:"id"`
|
|
SelfUri string `json:"selfUri"`
|
|
} `json:"division"`
|
|
Entities []struct {
|
|
DateDivisionUpdated string `json:"dateDivisionUpdated"`
|
|
Id string `json:"id"`
|
|
SelfUri string `json:"selfUri"`
|
|
} `json:"entities"`
|
|
} `json:"divisions"`
|
|
ExternalTag string `json:"externalTag"`
|
|
Id string `json:"id"`
|
|
Participants []struct {
|
|
Address string `json:"address"`
|
|
Attributes map[string]any `json:"attributes"`
|
|
Calls []struct {
|
|
AfterCallWorkRequired bool `json:"afterCallWorkRequired"`
|
|
Confined bool `json:"confined"`
|
|
ConnectedTime string `json:"connectedTime"`
|
|
Direction string `json:"direction"`
|
|
DisconnectReasons []struct{} `json:"disconnectReasons"`
|
|
DisconnectType string `json:"disconnectType"`
|
|
DisconnectedTime string `json:"disconnectedTime"`
|
|
Held bool `json:"held"`
|
|
Id string `json:"id"`
|
|
InitialState string `json:"initialState"`
|
|
Muted bool `json:"muted"`
|
|
Other map[string]any `json:"other"`
|
|
PeerId string `json:"peerId"`
|
|
Provider string `json:"provider"`
|
|
Recording bool `json:"recording"`
|
|
RecordingState string `json:"recordingState"`
|
|
SecurePause bool `json:"securePause"`
|
|
Self map[string]any `json:"self"`
|
|
State string `json:"state"`
|
|
} `json:"calls"`
|
|
ConnectedTime string `json:"connectedTime"`
|
|
EndTime string `json:"endTime"`
|
|
ExternalContactId string `json:"externalContactId"`
|
|
ExternalContactInitialDivisionId string `json:"externalContactInitialDivisionId"`
|
|
Id string `json:"id"`
|
|
MediaRoles []string `json:"mediaRoles"`
|
|
Name string `json:"name"`
|
|
Purpose string `json:"purpose"`
|
|
QueueId string `json:"queueId"`
|
|
Wrapup map[string]any `json:"wrapup"`
|
|
WrapupExpected bool `json:"wrapupExpected"`
|
|
WrapupRequired bool `json:"wrapupRequired"`
|
|
} `json:"participants"`
|
|
RecentTransfers []map[string]any `json:"recentTransfers"`
|
|
RecordingState string `json:"recordingState"`
|
|
SecurePause bool `json:"securePause"`
|
|
UtilizationLabelId string `json:"utilizationLabelId"`
|
|
}
|
|
|
|
// UsersQuery is used to bind the results of an GenesysCloud API request to get all users.
|
|
type UsersQuery struct {
|
|
Entities []GCUser `json:"entities"`
|
|
PageSize int `json:"pageSize"`
|
|
Total int `json:"total"`
|
|
}
|
|
|
|
// GCUser is a model used to store the results of GenesysCloud users.
|
|
//
|
|
// Given the similarity between the API requests returned value and the desired database schema, the DB model is used in UsersQuery, and also to upload directly to the database. No additional formatting work is required.
|
|
type GCUser struct {
|
|
Id string `json:"id" gorm:"primaryKey"`
|
|
Name string `json:"name"`
|
|
Email string `json:"email"`
|
|
State string `json:"state"`
|
|
Username string `json:"username"`
|
|
AcdAutoAnswer bool `json:"acdAutoAnswer"`
|
|
}
|
|
|
|
func (GCUser) TableName() string {
|
|
return "gc_users"
|
|
}
|