youlink

package
v0.0.0-...-5fea7ce Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TemplateTypeHttpCall = "HTTPRequestCall"
)
View Source
const (
	VariableTypeString = "string"
)

Variables

This section is empty.

Functions

func AbortErrorWithStatus

func AbortErrorWithStatus(err error, context *haruka.Context, status int)

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewYouLinkClient

func NewYouLinkClient() *Client

func (*Client) Callback

func (c *Client) Callback(id string, output []*Variable, err error) error

func (*Client) Init

func (c *Client) Init(baseUrl string)

func (*Client) RegisterFunctions

func (c *Client) RegisterFunctions(functions ...*Function) error

type Function

type Function struct {
	Endpoint          string                `json:"endpoint"`
	Name              string                `json:"name"`
	Desc              string                `json:"desc"`
	Template          string                `json:"template"`
	Inputs            []*Variable           `json:"inputs"`
	Outputs           []*Variable           `json:"outputs"`
	InputDefinitions  []*VariableDefinition `json:"inputDefinitions"`
	OutputDefinitions []*VariableDefinition `json:"outputDefinitions []"`
	HandlerFunc       func(f *Function) error
	CallbackFunc      func(variables []*Variable, err error) error
	Options           map[string]interface{} `json:"options"`
}

func (*Function) GetInput

func (f *Function) GetInput(key string) interface{}

func (*Function) GetInputInt

func (f *Function) GetInputInt(key string) int

func (*Function) GetInputString

func (f *Function) GetInputString(key string) string

type FunctionTemplate

type FunctionTemplate struct {
	Name     string                 `json:"name"`
	Template string                 `json:"template"`
	Desc     string                 `json:"desc"`
	Inputs   []*VariableDefinition  `json:"inputs"`
	Outputs  []*VariableDefinition  `json:"outputs"`
	Options  map[string]interface{} `json:"options"`
}

type RegisterFunctionsRequestBody

type RegisterFunctionsRequestBody struct {
	Func []*FunctionTemplate `json:"func"`
}

type ResponseBody

type ResponseBody struct {
	CallbackId string      `json:"callbackId"`
	Inputs     []*Variable `json:"inputs"`
	Output     []*Variable `json:"outputs"`
}

type Service

type Service struct {
	Functions  []*Function
	Client     *Client
	ServiceUrl string
}

func NewService

func NewService(baseUrl string, serviceUrl string) *Service

func (*Service) AddFunction

func (s *Service) AddFunction(function ...*Function)

func (*Service) RegisterFunction

func (s *Service) RegisterFunction() error

func (*Service) RegisterHarukaHandler

func (s *Service) RegisterHarukaHandler(engine *haruka.Engine)

type Variable

type Variable struct {
	Name  string      `json:"name"`
	Value interface{} `json:"value"`
	Type  string      `json:"type"`
}

type VariableDefinition

type VariableDefinition struct {
	Type string `json:"type"`
	Name string `json:"name"`
	Desc string `json:"desc"`
}

Jump to

Keyboard shortcuts

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