common

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2019 License: MIT Imports: 7 Imported by: 7

Documentation

Overview

Package common contains all models and interfaces necessary to access api

Index

Constants

This section is empty.

Variables

View Source
var ConstMessageID = ""

ConstMessageID is used to ensure a constant messageId for tests

Functions

This section is empty.

Types

type AlexaError

type AlexaError struct {
	Type      string
	Message   string
	Namespace string
}

AlexaError is an error which additional holds the alexa error type https://developer.amazon.com/de/docs/device-apis/alexa-errorresponse.html#example-errorresponse

func NewAcceptGrantFailedError

func NewAcceptGrantFailedError(message string) AlexaError

NewAcceptGrantFailedError creates an AlexaError to indicate that user authentication failed

func NewInternalError

func NewInternalError(message string) AlexaError

NewInternalError creates an AlexaError to indicate an error that cannot be accurately described as one of the other error types occurred while you were handling the directive. For example, a generic runtime exception occurred while handling a directive. Ideally, you will never send this error event, but instead send a more specific error type.

func NewInvalidDirectiveError

func NewInvalidDirectiveError(message string) AlexaError

NewInvalidDirectiveError creates an AlexaError to indicate a directive is not valid for this skill or is malformed.

func (AlexaError) Error

func (e AlexaError) Error() string

type Context

type Context struct {
	Properties []property `json:"properties"`
}

Context holds properties of an endpoint

func NewContext

func NewContext() *Context

NewContext creates a new empty Context

func (*Context) AddEndpointHealthProperty

func (c *Context) AddEndpointHealthProperty(health capabilities.HealthConscious, timeOfSample time.Time)

AddEndpointHealthProperty adds a connectivity property to context

func (*Context) AddPowerStateProperty

func (c *Context) AddPowerStateProperty(state bool, timeOfSample time.Time)

AddPowerStateProperty adds a powerState property to context

func (*Context) AddTemperatureProperty

func (c *Context) AddTemperatureProperty(temperature float32, timeOfSample time.Time)

AddTemperatureProperty adds a temperature property to context

type Cookie struct {
	ID   string `json:"id"`
	Type string `json:"type"`
	Name string `json:"name"`
}

The Cookie represents custom properties of an alexa endpoint and is used to create an device with the DeviceFactory which can be processed by the according directive processor.

type Directive

type Directive struct {
	Header   *Header                `json:"header"`
	Endpoint *Endpoint              `json:"endpoint,omitempty"`
	Payload  map[string]interface{} `json:"payload,omitempty"`
}

A Directive got sent by alexa

func NewDirective

func NewDirective(data []byte) (dir *Directive, err error)

NewDirective creates a new directive from json

func (Directive) String

func (d Directive) String() string

type Endpoint

type Endpoint struct {
	Scope struct {
		Type  string `json:"type"`
		Token string `json:"token"`
	} `json:"scope"`
	EndpointID string `json:"endpointId"`
	Cookie     Cookie `json:"cookie"`
}

An Endpoint object identifies the target for a directive and the origin of an event.

type Header struct {
	Namespace        string `json:"namespace"`
	Name             string `json:"name"`
	MessageID        string `json:"messageId"`
	CorrelationToken string `json:"correlationToken,omitempty"`
	PayloadVersion   string `json:"payloadVersion"`
}

A Header has a set of expected fields that are the same across message types. These provide different types of identifying information.

func NewHeader

func NewHeader(name string, namespace string) *Header

NewHeader creates a new header for given name and namespace

type Response

type Response struct {
	Context *Context `json:"context,omitempty"`
	Event   struct {
		Header   *Header     `json:"header"`
		Endpoint *Endpoint   `json:"endpoint,omitempty"`
		Payload  interface{} `json:"payload,omitempty"`
	} `json:"event"`
}

Response is used to respond to a request send by alexa

Directories

Path Synopsis
Package capabilities contains the interfaces which capable devices must satisfy
Package capabilities contains the interfaces which capable devices must satisfy

Jump to

Keyboard shortcuts

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