smartappcore

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2018 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CorrelationHeader = "X-ST-CORRELATION"
	CorrelationKey    = "loggingId"
	MediaTypeJsonV1   = "application/vnd.smartthings+json;v=1"
	SmartThingsHost   = "api.smartthings.com"
)

Variables

View Source
var (
	UnsupportedLifecyleError          = errors.New("unsupported_app_lifecycle")
	IllegalArgumentPingChallengeError = errors.New("illegal_argument_ping_challenge")
)

Functions

func DebugInterceptor

func DebugInterceptor(log logger.Logger, original http.RoundTripper) http.RoundTripper

func ParsePublicKeyBase64

func ParsePublicKeyBase64(publicKeyBase64 string) *rsa.PublicKey

*

  • Builds an rsa.PublicKey object for a pem formatted base64 encoded public key string.

func RequestInterceptor

func RequestInterceptor(original http.RoundTripper) http.RoundTripper

Types

type Authenticator

type Authenticator struct {
	Verifier *httpsig.Verifier
}

func NewAuthenticator

func NewAuthenticator(publicKey *rsa.PublicKey) *Authenticator

type DefaultEventHandler

type DefaultEventHandler struct {
	Chain       []PredicateEventHandler
	OnSuccess   OnSuccess
	OnError     OnError
	FailOnError FailOnError
}

func (*DefaultEventHandler) AddEventHandler

func (h *DefaultEventHandler) AddEventHandler(handler PredicateEventHandler)

func (*DefaultEventHandler) BuildHandler

func (h *DefaultEventHandler) BuildHandler() Handler

func (*DefaultEventHandler) DoOnError

func (h *DefaultEventHandler) DoOnError(onError OnError)

func (*DefaultEventHandler) DoOnSuccess

func (h *DefaultEventHandler) DoOnSuccess(onSuccess OnSuccess)

func (*DefaultEventHandler) GetChainSize

func (h *DefaultEventHandler) GetChainSize() int

func (*DefaultEventHandler) Handle

func (*DefaultEventHandler) SetFailOnErrorPredicate

func (h *DefaultEventHandler) SetFailOnErrorPredicate(failOnError FailOnError)

func (*DefaultEventHandler) SetHandlerChain

func (h *DefaultEventHandler) SetHandlerChain(chain []PredicateEventHandler)

func (*DefaultEventHandler) Test

func (h *DefaultEventHandler) Test(params *SmartAppParams) bool

type DefaultPredicateHandler

type DefaultPredicateHandler struct {
	Tester  Test
	Handler Handle
}

func (*DefaultPredicateHandler) Handle

func (*DefaultPredicateHandler) Test

func (h *DefaultPredicateHandler) Test(params *SmartAppParams) bool

type DefaultSmartApp

type DefaultSmartApp struct {
	Chain []PredicateHandler
}

func (*DefaultSmartApp) Handle

type DefaultSmartAppDefinition

type DefaultSmartAppDefinition struct {
	InstallHandler       PredicateHandler
	UpdateHandler        PredicateHandler
	UninstallHandler     PredicateHandler
	EventHandler         PredicateHandler
	PingHandler          PredicateHandler
	ConfigurationHandler PredicateHandler
	OAuthCallbackHandler PredicateHandler
	AdditionalHandlers   []PredicateHandler
}

func (*DefaultSmartAppDefinition) AddHandler

func (h *DefaultSmartAppDefinition) AddHandler(handler PredicateHandler)

func (*DefaultSmartAppDefinition) BuildChain

func (h *DefaultSmartAppDefinition) BuildChain() []PredicateHandler

func (*DefaultSmartAppDefinition) SetConfigurationHandler

func (h *DefaultSmartAppDefinition) SetConfigurationHandler(handler Handler)

func (*DefaultSmartAppDefinition) SetEventHandler

func (h *DefaultSmartAppDefinition) SetEventHandler(handler Handler)

func (*DefaultSmartAppDefinition) SetInstallHandler

func (h *DefaultSmartAppDefinition) SetInstallHandler(handler Handler)

func (*DefaultSmartAppDefinition) SetOAuthCallbackHandler

func (h *DefaultSmartAppDefinition) SetOAuthCallbackHandler(handler Handler)

func (*DefaultSmartAppDefinition) SetPingHandler

func (h *DefaultSmartAppDefinition) SetPingHandler(handler Handler)

func (*DefaultSmartAppDefinition) SetUninstallHandler

func (h *DefaultSmartAppDefinition) SetUninstallHandler(handler Handler)

func (*DefaultSmartAppDefinition) SetUpdateHandler

func (h *DefaultSmartAppDefinition) SetUpdateHandler(handler Handler)

type DefaultSmartThingsApi

type DefaultSmartThingsApi struct {
	Client         *apiclient.SmartThings
	RequestTimeout time.Duration
	Logger         logger.Logger
}

func (*DefaultSmartThingsApi) CreateDeviceEvents

func (s *DefaultSmartThingsApi) CreateDeviceEvents(params *devices.CreateDeviceEventsParams) error

func (*DefaultSmartThingsApi) CreateSchedule

func (*DefaultSmartThingsApi) ExecuteDeviceCommands

func (s *DefaultSmartThingsApi) ExecuteDeviceCommands(params *devices.ExecuteDeviceCommandsParams) error

func (*DefaultSmartThingsApi) ExecuteScene

func (s *DefaultSmartThingsApi) ExecuteScene(params *scenes.ExecuteSceneParams) error

func (*DefaultSmartThingsApi) GetLocation

func (*DefaultSmartThingsApi) InstallDevice

func (s *DefaultSmartThingsApi) InstallDevice(params *devices.InstallDeviceParams) (*models.Device, error)

func (*DefaultSmartThingsApi) SaveSubscription

func (s *DefaultSmartThingsApi) SaveSubscription(params *subscriptions.SaveSubscriptionParams) error

type EventHandler

type EventHandler interface {
	SetHandlerChain(chain []PredicateEventHandler)
	AddEventHandler(handler PredicateEventHandler)
	DoOnSuccess(onSuccess OnSuccess)
	DoOnError(onError OnError)
	SetFailOnErrorPredicate(failOnError FailOnError)
	GetChainSize() int
	BuildHandler() Handler
}

func NewEventHandler

func NewEventHandler() EventHandler

type FailOnError

type FailOnError func(err error) bool

type Handle

type Handle func(params *SmartAppParams) (*smartapp.ExecutionResponse, error)

type Handler

type Handler func(params *SmartAppParams) (*smartapp.ExecutionResponse, error)

type KeyResolver

type KeyResolver struct {
	PublicKey *rsa.PublicKey
}

func (KeyResolver) GetKey

func (k KeyResolver) GetKey(id string) interface{}

type NoopLifecycleHandler

type NoopLifecycleHandler struct {
	Lifecycle smartapp.AppLifecycle
}

func (*NoopLifecycleHandler) Handle

func (*NoopLifecycleHandler) Test

func (h *NoopLifecycleHandler) Test(params *SmartAppParams) bool

type NotFoundHandler

type NotFoundHandler struct {
}

func (*NotFoundHandler) Handle

func (*NotFoundHandler) Test

func (h *NotFoundHandler) Test(params *SmartAppParams) bool

type OnError

type OnError func(params *SmartAppParams, err error) (*smartapp.ExecutionResponse, error)

type OnSuccess

type OnSuccess func(params *SmartAppParams) (*smartapp.ExecutionResponse, error)

type PingHandler

type PingHandler struct {
}

func (*PingHandler) Handle

func (*PingHandler) Test

func (h *PingHandler) Test(params *SmartAppParams) bool

type PredicateEventHandler

type PredicateEventHandler interface {
	Test(event *smartapp.Event) bool
	Handle(params *SmartAppParams, event *smartapp.Event) error
}

type PredicateHandler

type PredicateHandler interface {
	Test(params *SmartAppParams) bool
	Handle(params *SmartAppParams) (*smartapp.ExecutionResponse, error)
}

type SmartApp

type SmartApp interface {
	Handle(request *SmartAppParams) (*smartapp.ExecutionResponse, error)
}

func NewSmartApp

func NewSmartApp(definition SmartAppDefinition) SmartApp

type SmartAppDefinition

type SmartAppDefinition interface {
	SetInstallHandler(handler Handler)
	SetUpdateHandler(handler Handler)
	SetUninstallHandler(handler Handler)
	SetEventHandler(handler Handler)
	SetPingHandler(handler Handler)
	SetConfigurationHandler(handler Handler)
	SetOAuthCallbackHandler(handler Handler)
	AddHandler(handler PredicateHandler)
	BuildChain() []PredicateHandler
}

func NewSmartAppDefinition

func NewSmartAppDefinition() SmartAppDefinition

type SmartAppParams

type SmartAppParams struct {
	Request *smartapp.ExecutionRequest
	Context context.Context
}

func (*SmartAppParams) GetSetting

func (p *SmartAppParams) GetSetting(key string) string

type SmartThingsApi

type SmartThingsApi interface {
	CreateSchedule(params *schedules.CreateScheduleParams) (*models.Schedule, error)
	SaveSubscription(params *subscriptions.SaveSubscriptionParams) error
	InstallDevice(params *devices.InstallDeviceParams) (*models.Device, error)
	CreateDeviceEvents(params *devices.CreateDeviceEventsParams) error
	ExecuteDeviceCommands(params *devices.ExecuteDeviceCommandsParams) error
	GetLocation(params *locations.GetLocationParams) (*models.Location, error)
	ExecuteScene(params *scenes.ExecuteSceneParams) error
}

func NewSmartThingsApi

func NewSmartThingsApi(params *SmartThingsApiParams) SmartThingsApi

type SmartThingsApiParams

type SmartThingsApiParams struct {
	Host    string
	Schemes []string
	Debug   bool
	Logger  logger.Logger
}

type Test

type Test func(params *SmartAppParams) bool

Jump to

Keyboard shortcuts

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