iwt

package module
v0.1.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 12 Imported by: 0

README

go-iwt

GoVersion GoDoc License Report

An Interaction Web Tools API client for GENESYS PureConnect

Documentation

Index

Constants

View Source
const APP string = "IWT Agent"

APP is the name of the application

Variables

View Source
var (
	// StatusUnknownEntitySession means the provided session does not exist on the PureConnect Server
	StatusUnknownEntitySession = Status{"failure", "error.websvc.unknownEntity.session", nil}
	// StatusNotConnectedEntity means the client is not connected to any PureConnect Server
	StatusNotConnectedEntity = Status{"failure", "error.websvc.entity.notconnected", nil}
	// StatusUnavailableService means the PureConnect Server is not available for requests
	StatusUnavailableService = Status{"failure", "error.websvc.unavailable", nil}
)
View Source
var (
	// SystemParticipant is used for messages sent by PureConnect
	SystemParticipant = Participant{Type: "System", ID: "00000000-0000-0000-0000-000000000000", Name: "System", State: "active"}
)
View Source
var VERSION = "0.1.18" + commit

VERSION is the version of this application

Functions

This section is empty.

Types

type Chat

type Chat struct {
	ID                 string         `json:"chatID"`
	Queue              *Queue         `json:"queue"`
	Participants       []Participant  `json:"participants"`
	Guest              Participant    `json:"guest"` // used to store the id of the guest on their platform (LINE, KKT, etc)
	PollWaitSuggestion time.Duration  `json:"pollWaitSuggestion"`
	Language           string         `json:"language"`
	DateFormat         string         `json:"dateFormat"`
	TimeFormat         string         `json:"timeFormat"`
	EventChan          chan ChatEvent `json:"-"`
	PollTicker         *time.Ticker   `json:"-"`
	Client             *Client        `json:"-"`
	Logger             *logger.Logger `json:"-"`
}

Chat describes a live chat

func (*Chat) GetFile

func (chat *Chat) GetFile(path string) (reader *request.Content, err error)

GetFile download a file sent by an agent

func (Chat) GetFileURL added in v0.1.5

func (chat Chat) GetFileURL(path string) *url.URL

GetFileURL tells the Download URL for the given file path

func (*Chat) GetParticipant

func (chat *Chat) GetParticipant(id string) (*Participant, error)

GetParticipant fetches a participant from a chat by its ID

func (Chat) IsWebUser

func (chat Chat) IsWebUser(participantID string) bool

IsWebUser tells if the given participantID is the customer (WebUser)

func (*Chat) Reconnect

func (chat *Chat) Reconnect() error

Reconnect reconnects the current chat to another server (Switchover event, e.g.)

func (*Chat) SendMessage

func (chat *Chat) SendMessage(text, contentType string) error

SendMessage sends a message to the chat

func (*Chat) Stop

func (chat *Chat) Stop() error

Stop stops the current chat

func (*Chat) String

func (chat *Chat) String() string

type ChatEvent

type ChatEvent interface {
	GetType() string
	String() string
}

ChatEvent defines a Chat Event

func UnmarshalChatEvent added in v0.1.3

func UnmarshalChatEvent(payload []byte) (ChatEvent, error)

UnmarshalChatEvent unmarshals a JSON payload into a ChatEvent

type Client

type Client struct {
	APIEndpoints  []*url.URL      `json:"apiEndpoints"`
	EndPointIndex int             `json:"endpointIndex"`
	Proxy         *url.URL        `json:"proxy"`
	Language      string          `json:"language"`
	CACert        []byte          `json:"cacert"`
	Context       context.Context `json:"-"`
	Logger        *logger.Logger  `json:"-"`
}

Client is the IWT client to talk to PureConnect

func NewClient

func NewClient(ctx context.Context, options ClientOptions) *Client

NewClient instantiates a new IWT Client

func (Client) CurrentAPIEndpoint

func (client Client) CurrentAPIEndpoint() *url.URL

CurrentAPIEndpoint gives the current API Endpoint to use

func (*Client) GetServerConfiguration

func (client *Client) GetServerConfiguration() (*ServerConfiguration, error)

GetServerConfiguration fetches the configuration of the PureConnect server

func (*Client) NextAPIEndpoint

func (client *Client) NextAPIEndpoint() *url.URL

NextAPIEndpoint switches to the next API endpoint (or back at the beginning)

func (*Client) QueryQueue

func (client *Client) QueryQueue(queuename string, queuetype QueueType) (*Queue, error)

QueryQueue queries a queue for its status

func (*Client) StartChat

func (client *Client) StartChat(options StartChatOptions) (*Chat, error)

StartChat starts a chat Chat Events will be sent to Chat.EventChan

func (*Client) URLWithPath

func (client *Client) URLWithPath(path string) *url.URL

URLWithPath gets a full URL from a given path

type ClientOptions

type ClientOptions struct {
	PrimaryAPI *url.URL       `json:"primary"`
	BackupAPI  *url.URL       `json:"backup"`
	CACert     []byte         `json:"cacert"`
	Proxy      *url.URL       `json:"proxy"`
	Language   string         `json:"language"`
	Logger     *logger.Logger `json:"-"`
}

ClientOptions defines the options for instantiating a new IWT Client If you use https with the Primary/Backup API endpoint and they use a self-signed certificate, you must give the option CACert

type FileEvent

type FileEvent struct {
	SequenceNumber             int         `json:"sequenceNumber"`
	ConversationSequenceNumber int         `json:"conversationSequenceNumber"`
	Participant                Participant `json:"-"`
	ContentType                string      `json:"contentType"`
	Path                       string      `json:"value"`
}

FileEvent describes the Text event

func (FileEvent) GetType

func (event FileEvent) GetType() string

GetType returns the type of this event

func (FileEvent) MarshalJSON

func (event FileEvent) MarshalJSON() ([]byte, error)

MarshalJSON encodes into JSON

func (FileEvent) String

func (event FileEvent) String() string

func (*FileEvent) UnmarshalJSON added in v0.1.3

func (event *FileEvent) UnmarshalJSON(payload []byte) (err error)

UnmarshalJSON decodes JSON

type Participant

type Participant struct {
	Type        string   `json:"participantType"`
	ID          string   `json:"participantID"`
	Name        string   `json:"participantName"`
	Credentials string   `json:"credentials,omitempty"`
	Picture     *url.URL `json:"-"`
	State       string   `json:"state,omitempty"`
	Status      Status   `json:"status"`
}

Participant defines a chat participant

func (Participant) MarshalJSON

func (participant Participant) MarshalJSON() ([]byte, error)

MarshalJSON encodes into JSON

func (*Participant) UnmarshalJSON

func (participant *Participant) UnmarshalJSON(payload []byte) (err error)

UnmarshalJSON decodes JSON

type ParticipantStateChangedEvent

type ParticipantStateChangedEvent struct {
	SequenceNumber int         `json:"sequenceNumber"`
	Participant    Participant `json:"-"`
}

ParticipantStateChangedEvent describes the ParticipantStateChanged event

func (ParticipantStateChangedEvent) GetType

func (event ParticipantStateChangedEvent) GetType() string

GetType returns the type of this event

func (ParticipantStateChangedEvent) MarshalJSON

func (event ParticipantStateChangedEvent) MarshalJSON() ([]byte, error)

MarshalJSON encodes into JSON

func (ParticipantStateChangedEvent) String

func (event ParticipantStateChangedEvent) String() string

func (*ParticipantStateChangedEvent) UnmarshalJSON added in v0.1.3

func (event *ParticipantStateChangedEvent) UnmarshalJSON(payload []byte) (err error)

UnmarshalJSON decodes JSON

type Queue

type Queue struct {
	Name               string    `json:"queueName"`
	Type               QueueType `json:"queueType"`
	EstimatedWaitTime  int       `json:"estimatedWaitTime"`  // in H
	PollWaitSuggestion int       `json:"pollWaitSuggestion"` // in ms
	AvailableAgents    int       `json:"agentsAvailable"`
	Status             Status    `json:"status"`
}

Queue describe a queue

func NewQueue

func NewQueue(qualifiedqueue string) *Queue

NewQueue instantiates a new Queue The Qualified Queue name follows the PureConnect standard way of specifying a queue: "User Queue:Operator", "Workgroup Queue:Sales", "Station Queue:7001" Workgroup Queue is the default type, and if nothing was given, "Workgroup Queue:CompanyOperator" will be used

func (*Queue) String

func (queue *Queue) String() string

type QueueType

type QueueType int

QueueType defines the type of Queue

const (
	// StationQueue queue type
	StationQueue QueueType = iota
	// UserQueue queue type
	UserQueue
	// WorkgroupQueue queue type
	WorkgroupQueue
)

func (QueueType) MarshalJSON

func (queueType QueueType) MarshalJSON() ([]byte, error)

MarshalJSON encodes JSON

func (QueueType) Prefix

func (queueType QueueType) Prefix() string

Prefix returns the queue type as a prefix for Fully Qualified queues

func (QueueType) String

func (queueType QueueType) String() string

func (*QueueType) UnmarshalJSON

func (queueType *QueueType) UnmarshalJSON(payload []byte) (err error)

UnmarshalJSON decodes JSON

type RoutingContext

type RoutingContext struct {
	Category string `json:"category"`
	Context  string `json:"context"`
}

RoutingContext defines the routing context when starting a chat (see IWT documentation)

type ServerConfiguration

type ServerConfiguration struct {
	Version      int                 `json:"cfgVer"`
	Capabilities map[string][]string `json:"capabilities"`
}

ServerConfiguration contains information about a PureConnect server

type StartChatOptions

type StartChatOptions struct {
	Queue                 *Queue            `json:"-"`
	Guest                 Participant       `json:"participant"`
	Language              string            `json:"language,omitempty"`
	EmailAddress          string            `json:"emailAddress,omitempty"`
	SupportedContentTypes string            `json:"supportedContentTypes"`
	TranscriptRequired    bool              `json:"transcriptRequired"`
	Attributes            map[string]string `json:"attributes,omitempty"`
	RoutingContexts       []RoutingContext  `json:"routingContexts,omitempty"`
}

StartChatOptions defines the options when starting a chat

type StartEvent

type StartEvent struct {
	ChatID       string        `json:"chatID"`
	Participants []Participant `json:"participants"`
	Guest        Participant   `json:"guest"` // used to store the id of the guest on their platform (LINE, KKT, etc)
	Language     string        `json:"language"`
	DateFormat   string        `json:"dateFormat"`
	TimeFormat   string        `json:"timeFormat"`
}

StartEvent describes the Start event

func (StartEvent) GetType

func (event StartEvent) GetType() string

GetType returns the type of this event

func (StartEvent) MarshalJSON

func (event StartEvent) MarshalJSON() ([]byte, error)

MarshalJSON encodes into JSON

func (StartEvent) String

func (event StartEvent) String() string

type Status

type Status struct {
	Type   string                 `json:"type"`
	Reason string                 `json:"reason"`
	Params map[string]interface{} `json:"params"`
}

Status defines the status of a queue, chat, IWT request

func (Status) AsError

func (status Status) AsError() error

AsError converts a status to a GO error

func (Status) Error

func (status Status) Error() string

func (Status) IsA

func (status Status) IsA(ref Status) bool

IsA tells if the status is the same as the given status

func (Status) IsOK

func (status Status) IsOK() bool

IsOK tells if the status is a success

func (Status) Param

func (status Status) Param(key string, value interface{}) Status

Param adds a param

type StopEvent

type StopEvent struct {
	ChatID string `json:"chatID"`
}

StopEvent describes the Text event

func (StopEvent) GetType

func (event StopEvent) GetType() string

GetType returns the type of this event

func (StopEvent) MarshalJSON

func (event StopEvent) MarshalJSON() ([]byte, error)

MarshalJSON encodes into JSON

func (StopEvent) String

func (event StopEvent) String() string

type TextEvent

type TextEvent struct {
	SequenceNumber             int         `json:"sequenceNumber"`
	ConversationSequenceNumber int         `json:"conversationSequenceNumber"`
	Participant                Participant `json:"-"`
	ContentType                string      `json:"contentType"`
	Text                       string      `json:"value"`
}

TextEvent describes the Text event

func (TextEvent) GetType

func (event TextEvent) GetType() string

GetType returns the type of this event

func (TextEvent) MarshalJSON

func (event TextEvent) MarshalJSON() ([]byte, error)

MarshalJSON encodes into JSON

func (TextEvent) String

func (event TextEvent) String() string

func (*TextEvent) UnmarshalJSON added in v0.1.3

func (event *TextEvent) UnmarshalJSON(payload []byte) (err error)

UnmarshalJSON decodes JSON

type TypingIndicatorEvent

type TypingIndicatorEvent struct {
	SequenceNumber int         `json:"sequenceNumber"`
	Participant    Participant `json:"-"`
	Typing         bool        `json:"value"`
}

TypingIndicatorEvent describes the TypingIndicator event

func (TypingIndicatorEvent) GetType

func (event TypingIndicatorEvent) GetType() string

GetType returns the type of this event

func (TypingIndicatorEvent) MarshalJSON

func (event TypingIndicatorEvent) MarshalJSON() ([]byte, error)

MarshalJSON encodes into JSON

func (TypingIndicatorEvent) String

func (event TypingIndicatorEvent) String() string

func (*TypingIndicatorEvent) UnmarshalJSON added in v0.1.3

func (event *TypingIndicatorEvent) UnmarshalJSON(payload []byte) (err error)

UnmarshalJSON decodes JSON

type URLEvent

type URLEvent struct {
	SequenceNumber int         `json:"sequenceNumber"`
	Participant    Participant `json:"-"`
	URL            *url.URL    `json:"-"`
}

URLEvent describes the Text event

func (URLEvent) GetType

func (event URLEvent) GetType() string

GetType returns the type of this event

func (URLEvent) MarshalJSON

func (event URLEvent) MarshalJSON() ([]byte, error)

MarshalJSON encodes into JSON

func (URLEvent) String

func (event URLEvent) String() string

func (*URLEvent) UnmarshalJSON

func (event *URLEvent) UnmarshalJSON(payload []byte) (err error)

UnmarshalJSON decodes JSON

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL