headset

package
v0.0.0-...-d330e10 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	abstractClient.AbstractClient
	StartSession(ctx context.Context, request EventRequest) (*EventResponse, error)
	SendEvent(ctx context.Context, request EventRequest) (*EventResponse, error)
	EndSession(ctx context.Context, request EventRequest) (*EventResponse, error)
}

Client is an interface that contains the methods of an AbstractClient and the methods of the headset service

func NewClient

func NewClient(config urlfinder.ClientConfig) Client

NewClient is a function that returns a new Client

func NewClientWithBasicAuth

func NewClientWithBasicAuth(username, password string, config urlfinder.ClientConfig) (Client, error)

NewClientWithBasicAuth is a function that returns a new Client with basic auth

type DoubleLegacyEventRequest

type DoubleLegacyEventRequest struct {
	Type      string  `json:"eventtype,omitempty"`
	SessionID int     `json:"sessionID,omitempty"`
	UserID    int     `json:"userid,omitempty"`
	ModuleID  int     `json:"moduleID,omitempty"`
	Payload   Payload `json:"jsonData,omitempty"`
}

DoubleLegacyEventRequest struct

type EventRequest

type EventRequest struct {
	UUID         *string                `json:"uuid,omitempty"`
	SessionID    *int                   `json:"sessionID,omitempty"`
	DeviceID     string                 `json:"deviceId,omitempty"`
	ModuleID     int                    `json:"moduleId,omitempty"`
	Type         string                 `json:"event_type,omitempty"`
	OtherType    string                 `json:"eventType,omitempty"`
	Payload      map[string]interface{} `json:"jsonData,omitempty"`
	OtherPayload string                 `json:"jsondata,omitempty"`
}

EventRequest is the request object for sending events to the platform

type EventResponse

type EventResponse struct {
	platform.Event
	LessonStatus *string `json:"lessonStatus,omitempty"`
}

EventResponse is the response object when sending events to the platform

type LoginRequest

type LoginRequest struct {
	Login    string `json:"login"`
	Password string `json:"password"`
}

LoginRequest is the request body for the login endpoint

type LoginResponse

type LoginResponse struct {
	Token string `json:"token"`
}

LoginResponse is the response body for the login endpoint

type MockClient

type MockClient struct {
	abstract.MockAbstractClient

	CalledStartSessionWith []EventRequest
	StartSessionError      error

	CalledSendEventWith []EventRequest
	SendEventError      error

	CalledEndSessionWith []EventRequest
	EndSessionError      error
}

MockClient is a mock implementation of the Client interface.

func (*MockClient) EndSession

func (m *MockClient) EndSession(ctx context.Context, request EventRequest) (*EventResponse, error)

EndSession returns an error if provided, otherwise returns a mock EventResponse.

func (*MockClient) SendEvent

func (m *MockClient) SendEvent(ctx context.Context, request EventRequest) (*EventResponse, error)

SendEvent returns an error if provided, otherwise returns a mock EventResponse.

func (*MockClient) StartSession

func (m *MockClient) StartSession(ctx context.Context, request EventRequest) (*EventResponse, error)

StartSession returns an error if provided, otherwise returns a mock EventResponse.

type Payload

type Payload struct {
	LessonStatus    *string `json:"lessonStatus,omitempty"`
	LessonStatusOld *string `json:"Lesson_status,omitempty"`

	Score    *float64 `json:"score,omitempty"`
	ScoreOld *float64 `json:"Score,omitempty"`

	ScoreMax    *float64 `json:"scoreMax,omitempty"`
	ScoreMaxOld *float64 `json:"Score_max,omitempty"`
	Success     *bool    `json:"success,omitempty"`

	TimeJoined *string `json:"TimeJoined,omitempty"`

	SessionDuration    *float64 `json:"sessionDuration,omitempty"` // this needs to be a float so that we can handle 1 and 1.0
	OldSessionDuration *float64 `json:"sessionduration,omitempty"`

	Result *struct {
		Completion bool   `json:"completion,omitempty"`
		Success    bool   `json:"success,omitempty"`
		Duration   string `json:"duration,omitempty"`
		Score      *struct {
			Raw float64 `json:"raw,omitempty"`
			Max float64 `json:"max,omitempty"`
		} `json:"score,omitempty"`
		Extensions map[string]interface{} `json:"extensions,omitempty"`
	} `json:"result,omitempty"`
	Object *struct {
		ID *string `json:"id,omitempty"`
	} `json:"object,omitempty"`
	Context *struct {
		Registration string                 `json:"registration,omitempty"`
		Revision     string                 `json:"revision,omitempty"`
		Extensions   map[string]interface{} `json:"extensions,omitempty"`
	} `json:"context,omitempty"`
}

Payload is the struct that represents common items in the event payload

type Response

type Response struct {
	Error   bool          `json:"error"`
	Message string        `json:"message"`
	Data    EventResponse `json:"data"`
}

Response is the response object for requests to the headset API

Jump to

Keyboard shortcuts

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