icws

package module
v0.1.14 Latest Latest
Warning

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

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

README

go-icws

Go package to connect to CIC, from Interactive Intelligence, over ICWS

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VERSION = "0.1.14"

VERSION is the version of this application

Functions

func IDList

func IDList(identifiables interface{}) []string

IDList collects the Identifiers of items

If some of the given items are not identifiable, it panics

Types

type AdditionalLicense

type AdditionalLicense struct {
	ID      string `json:"id"`
	Name    string `json:"displayName"`
	SelfURI string `json:"uri"`
}

type AllocationLicense

type AllocationLicense uint32
const (
	AssignableAllocation AllocationLicense = iota
	ConcurrentAllocation
)

type EventSource

type EventSource struct {
	Type    string  `json:"__type"`
	ID      string  `json:"eventId"`
	Message Message `json:"message"`
}

EventSource describe an Server-Sent Event

type EventStream

type EventStream struct {
	Events chan EventSource // listen to this to process EventSource

	Logger *logger.Logger
	// contains filtered or unexported fields
}

EventStream describes an EventSource processor

func NewEventStream

func NewEventStream() *EventStream

NewEventStream creates a new EventStream

func (*EventStream) Connect

func (stream *EventStream) Connect(session *Session, path string) error

Connect connects to the PureConnect Server-Sent Event Service of the Session

Do not forget to call the closeEventStream when you are done

func (EventStream) Disconnect

func (stream EventStream) Disconnect()

Disconnect disconnects the EventStream

type IPALicense

type IPALicense uint32
const (
	IPADirectRoutedWorkItems IPALicense = iota
	IPAGroupRoutedWorkItems
	IPAProcessMonitor
	IPAProcessDesigner
)

type Identifiable

type Identifiable interface {
	GetID() string
}

type License

type License struct {
	Name       string `json:"name"`
	IsAssigned bool   `json:"isAssigned"`
}

License describes a PureConnect License

type LicenseMessage

type LicenseMessage struct {
	Licenses []License `json:"licenseAssignedStatusList"`
	IsDelta  bool      `json:"isDelta"`
}

func (LicenseMessage) GetType

func (message LicenseMessage) GetType() string

GetType tells the JSON type

implements core.TypeCarrier

func (LicenseMessage) MarshalJSON

func (message LicenseMessage) MarshalJSON() ([]byte, error)

MarshalJSON marshals into JSON

implements json.Marshaler

func (LicenseMessage) Subscribe

func (message LicenseMessage) Subscribe(session *Session, payload interface{}) error

Subscribe subscribe a Session to this type of messages

implements Subscriber

func (*LicenseMessage) UnmarshalJSON

func (message *LicenseMessage) UnmarshalJSON(payload []byte) (err error)

UnmarshalJSON unmarshals from JSON

implements json.Unmarshaler

func (LicenseMessage) Unsubscribe

func (message LicenseMessage) Unsubscribe(session *Session) error

Subscribe subscribe a Session to this type of messages

implements Unsubscriber

type LicenseProperties

type LicenseProperties struct {
	Active             bool                `json:"licenseActive"`
	HasClientAccess    bool                `json:"hasClientAccess"`
	MediaLicense       MediaLicense        `json:"mediaLevel"`
	AllocationType     AllocationLicense   `json:"allocationType"`
	IPALicense         IPALicense          `json:"interactionProcessorAutomationType"`
	AdditionalLicenses []AdditionalLicense `json:"additionalLicenses"`
}

type LicenseSubscription

type LicenseSubscription struct {
	Licenses []string `json:"licenseList"`
}

LicenseSubscription describes a License Subscription Request

type MediaLicense

type MediaLicense uint32
const (
	Media1 MediaLicense = iota
	Media2
	Media3Plus
)

type Message

type Message interface {
	core.TypeCarrier
}

func UnmarshalMessage

func UnmarshalMessage(payload []byte) (Message, error)

UnmarshalMessage unmarshals from a JSON payload

type QueryConditions

type QueryConditions []string

type QueryFieldSelector

type QueryFieldSelector []string

type QueryOptions

type QueryOptions struct {
	Fields                      QueryFieldSelector `json:"select"`
	Where                       QueryConditions    `json:"where"`
	Rights                      QueryRightsFilter  `json:"rightsFilter"`
	ActualValues                bool               `json:"actualValues"`
	InheritedValues             bool               `json:"inheritedValues"`
	SinglePropertyInheritedFrom bool               `json:"singlePropertyInheritedFrom"`
}

func (QueryOptions) AsQueryParameters

func (options QueryOptions) AsQueryParameters() map[string]string

AsQueryParameters return a parameter map for session.send

type QueryRightsFilter

type QueryRightsFilter string

type Range

type Range struct {
	Unit  string
	First int
	Last  int
	Total int
}

func GetRangeFromHeader

func GetRangeFromHeader(header http.Header) Range

Get a Range from an HTTP Header map

func NewRange

func NewRange(unit string) Range

NewRange creates a new Range

func (Range) IsAtEnd

func (r Range) IsAtEnd() bool

func (Range) IsCollapsed

func (r Range) IsCollapsed() bool

IsCollapsed tells if the range is collapsed

A range is considered collapsed if its First and Last Indices are the same

func (Range) ToHeader

func (r Range) ToHeader(header *http.Header)

ToHeader fills the HTTP Header with the range if it is not collapsed

func (Range) ToMap

func (r Range) ToMap(data map[string]string)

ToMap fills the headers with the range if it is not collapsed

type Session

type Session struct {
	ID                   string                  `json:"id"`
	Token                string                  `json:"token"`
	Cookies              []*http.Cookie          `json:"cookies"`
	Timezone             string                  `json:"timezone"` // ???
	APIRoot              *url.URL                `json:"-"`
	Version              VersionInfo             `json:"pureconnectVersion"`
	User                 User                    `json:"user"`
	DefaultWorkstationID string                  `json:"defaultWorkstationId"`
	StationSettings      StationSettings         `json:"stationSettings"`
	Status               SessionStatus           `json:"status"`
	Features             []SessionFeature        `json:"features"`
	Subscriptions        map[string]Subscription `json:"-"`

	Logger *logger.Logger `json:"-"`
	SessionOptions
	// contains filtered or unexported fields
}

Session describes a session connected to a PureConnect server

func NewSession

func NewSession(options SessionOptions) *Session

NewSession creates a new Session

Warning: The Session is NOT connected

To give a logger.Logger to the Session, pass it to the context.Context

func (*Session) Connect

func (session *Session) Connect() (err error)

Connect connects to a PureConnect Server

If the Session is currently connected, nothing is done

func (*Session) ConnectStation

func (session *Session) ConnectStation(settings StationSettings) error

ConnectStation connects to a Station

func (*Session) Disconnect

func (session *Session) Disconnect() error

Disconnect disconnects the Session from PureConnect

All subscriptions are canceled prior to the disconnection. Also disconnected the Station, if any.

func (Session) Events

func (session Session) Events() chan EventSource

Events gives the EventSource chan to read for new Server-Sent Events from PureConnect

func (Session) GetID

func (session Session) GetID() string

GetID tells the ID

implements Identifiable

func (*Session) GetUsers

func (session *Session) GetUsers() ([]User, error)

GetUsers retrieves a list of Users

func (*Session) GetUsersWithOptions

func (session *Session) GetUsersWithOptions(options QueryOptions) ([]User, error)

GetUsers retrieves a list of Users

func (*Session) GetVersion

func (session *Session) GetVersion() (*VersionInfo, error)

GetVersion retrieves the PureConnect version

func (Session) HasSupport

func (session Session) HasSupport(featureName string) bool

HasSupport tells if the Session supports the given PureConnect feature

func (Session) HasSupportWithAtLeastVersion

func (session Session) HasSupportWithAtLeastVersion(featureName string, minimumVersion int) bool

HasSupport tells if the Session supports the given PureConnect feature

func (Session) IsConnected

func (session Session) IsConnected() bool

IsConnected tells if the Session is connected to a PureConnect server

func (Session) MarshalJSON

func (session Session) MarshalJSON() ([]byte, error)

MarshalJSON marshals into JSON

implements json.Marshaler

func (Session) String

func (session Session) String() string

String gets a text representation

implements fmt.Stringer

func (*Session) Subscribe

func (session *Session) Subscribe(subscriber Subscription, payload interface{}) error

func (*Session) Unsubscribe

func (session *Session) Unsubscribe(unsubscriber Subscription) error

type SessionFeature

type SessionFeature struct {
	Name    string `json:"featureId"`
	Version int    `json:"version"`
}

SessionFeature describes a feature supported by PureConnect Servers

type SessionOptions

type SessionOptions struct {
	Context      context.Context   `json:"-"`
	Servers      []*url.URL        `json:"-"`
	UserID       string            `json:"-"`
	Password     string            `json:"-"`
	Application  string            `json:"applicationName"`
	Language     string            `json:"language"`
	TokenUpdated chan UpdatedToken `json:"-"`
}

SessionOptions describes the options of a Session

To give a Logger to the Session, pass it to the Context

The Context will be passed to the TokenUpdated chan (if any) when the Token changes allowing application to pass data through it.

type SessionStatus

type SessionStatus uint32

SessionStatus reflects the status of the Session

const (
	UnknownStatus SessionStatus = iota
	ConnectedStatus
	ConnectingStatus
	DisconnectedStatus
	DisconnectingStatus
	ChangingStatus
)

func (SessionStatus) MarshalText

func (status SessionStatus) MarshalText() ([]byte, error)

MarshalText marshals this SessionStatus into a textual form

implements encoding.TextMarshaler

func (SessionStatus) String

func (status SessionStatus) String() string

String gets a text representation

implements fmt.Stringer

type StationSettings

type StationSettings interface {
	Connect(session *Session) error
	Disconnect(session *Session) error
	core.TypeCarrier
}

func UnmarshalStationSettings

func UnmarshalStationSettings(payload []byte) (StationSettings, error)

UnmarshalStationSettings unmarshals from a JSON payload

type StatusMessage

type StatusMessage struct {
	ID              string `json:"statusId"`
	SystemID        string `json:"systemId"`
	Text            string `json:"messageText"`
	IconURI         string `json:"iconUri"`
	GroupTag        string `json:"groupTag"`
	CanHaveDate     bool   `json:"canHaveDate"`
	CanHaveTime     bool   `json:"canHaveTime"`
	IsDoNotDisturb  bool   `json:"isDoNotDisturbStatus"`
	IsSelectable    bool   `json:"isSelectableStatus"`
	IsPersistent    bool   `json:"isPersistentStatus"`
	IsForward       bool   `json:"isForwardStatus"`
	IsAfterCallWork bool   `json:"isAfterCallWorkStatus"`
	IsACD           bool   `json:"isACDStatus"`
	IsAllowFollowUp bool   `json:"isAllowFollowUpStatus"`
}

StatusMessage describes a Status Message

func (StatusMessage) GetID

func (status StatusMessage) GetID() string

GetID tells the ID

implements Identifiable

type StatusMessageMessage

type StatusMessageMessage struct {
	AddedMessages   []StatusMessage `json:"statusMessagesAdded"`
	ChangedMessages []StatusMessage `json:"statusMessagesChanged"`
	RemovedMessages []string        `json:"statusMessagesRemoved"`
	IsDelta         bool            `json:"isDelta"`
}

func (StatusMessageMessage) GetType

func (subscription StatusMessageMessage) GetType() string

GetType tells the JSON type

implements core.TypeCarrier

func (StatusMessageMessage) MarshalJSON

func (message StatusMessageMessage) MarshalJSON() ([]byte, error)

MarshalJSON marshals into JSON

implements json.Marshaler

func (StatusMessageMessage) Subscribe

func (subscription StatusMessageMessage) Subscribe(session *Session, payload interface{}) error

Subscribe subscribe a Session to this type of messages

implements Subscriber

func (*StatusMessageMessage) UnmarshalJSON

func (message *StatusMessageMessage) UnmarshalJSON(payload []byte) (err error)

UnmarshalJSON unmarshals from JSON

implements json.Unmarshaler

func (StatusMessageMessage) Unsubscribe

func (subscription StatusMessageMessage) Unsubscribe(session *Session) error

Subscribe subscribe a Session to this type of messages

implements Unsubscriber

type Subscription

type Subscription interface {
	core.TypeCarrier
	Subscribe(session *Session, payload interface{}) error
	Unsubscribe(session *Session) error
}

type Time

type Time time.Time

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON marshals into JSON

implements json.Marshaler

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(payload []byte) (err error)

UnmarshalJSON unmarshals from JSON

implements json.Unmarshaler

type UpdatedToken

type UpdatedToken struct {
	Token     string          `json:"token"`
	UpdatedAt time.Time       `json:"updatedAt"`
	Context   context.Context `json:"context"`
}

UpdatedToken describes the event sent to a chan letting applications know about new Token

type User

type User struct {
	ID          string `json:"id"`
	DisplayName string `json:"displayName,omitempty"`
	SelfUri     string `json:"uri"`
	License     LicenseProperties
}

User describes a PureConnect User

func (User) GetID

func (user User) GetID() string

GetID tells the ID

implements Identifiable

func (User) String

func (user User) String() string

String gets a text representation

implements fmt.Stringer

type UserStatus

type UserStatus struct {
	UserID           string    `json:"userId"`
	StatusID         string    `json:"statusId"`
	IsLoggedIn       bool      `json:"loggedIn"`
	IsOnPhone        bool      `json:"onPhone"`
	OnPhoneChangedAt time.Time `json:"-"`
	ChangedAt        time.Time `json:"-"`
	Servers          []string  `json:"icServers"`
	Stations         []string  `json:"stations"`
}

UserStatus describes a User Status

func (UserStatus) MarshalJSON

func (message UserStatus) MarshalJSON() ([]byte, error)

MarshalJSON marshals into JSON

implements json.Marshaler

func (UserStatus) String

func (message UserStatus) String() string

String gets a text representation

implements fmt.Stringer

func (*UserStatus) UnmarshalJSON

func (message *UserStatus) UnmarshalJSON(payload []byte) (err error)

UnmarshalJSON unmarshals from JSON

implements json.Unmarshaler

type UserStatusMessage

type UserStatusMessage struct {
	UserStatuses []UserStatus `json:"userStatusList"`
	IsDelta      bool         `json:"isDelta"`
}

func (UserStatusMessage) GetType

func (message UserStatusMessage) GetType() string

GetType tells the JSON type

implements core.TypeCarrier

func (UserStatusMessage) MarshalJSON

func (message UserStatusMessage) MarshalJSON() ([]byte, error)

MarshalJSON marshals into JSON

implements json.Marshaler

func (UserStatusMessage) String

func (message UserStatusMessage) String() string

String gets a text representation

implements fmt.Stringer

func (UserStatusMessage) Subscribe

func (message UserStatusMessage) Subscribe(session *Session, payload interface{}) error

Subscribe subscribe a Session to this type of messages

implements Subscriber

func (*UserStatusMessage) UnmarshalJSON

func (message *UserStatusMessage) UnmarshalJSON(payload []byte) (err error)

UnmarshalJSON unmarshals from JSON

implements json.Unmarshaler

func (UserStatusMessage) Unsubscribe

func (message UserStatusMessage) Unsubscribe(session *Session) error

Subscribe subscribe a Session to this type of messages

implements Unsubscriber

type UserStatusSubscription

type UserStatusSubscription struct {
	UserIDs    []string `json:"userIds"`
	Properties []string `json:"userStatusProperties,omitempty"`
}

UserStatusSubscription describes a UserStatus Subscription Request

type VersionInfo

type VersionInfo struct {
	Major          int    `json:"-"`
	Minor          int    `json:"-"`
	Patch          int    `json:"-"`
	Build          int    `json:"-"`
	Product        string `json:"productId"`
	Codebase       string `json:"codebaseId"`
	ProductRelease string `json:"productReleaseDisplayString"`
	ProductPath    string `json:"productPatchDisplayString"`
}

VersionInfo describes the PureConnect Version

func (*VersionInfo) UnmarshalJSON

func (version *VersionInfo) UnmarshalJSON(payload []byte) (err error)

UnmarshalJSON unmarshals from JSON

implements json.Unmarshaler

type WorkStationSettings

type WorkStationSettings struct {
}

func (WorkStationSettings) GetType

func (settings WorkStationSettings) GetType() string

GetType tells the JSON type

implements core.TypeCarrier

func (WorkStationSettings) MarshalJSON

func (message WorkStationSettings) MarshalJSON() ([]byte, error)

MarshalJSON marshals into JSON

implements json.Marshaler

func (*WorkStationSettings) UnmarshalJSON

func (message *WorkStationSettings) UnmarshalJSON(payload []byte) (err error)

UnmarshalJSON unmarshals from JSON

implements json.Unmarshaler

Jump to

Keyboard shortcuts

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