hanetai

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultAvatarSize = AvatarSize{
	Height: 736,
	Width:  1280,
}

Functions

func IsRetriable

func IsRetriable(err error) bool

IsRetriable checks if a given error is an Hanet retriable error

func NewOAuth2Config

func NewOAuth2Config(clientID, clientSecret, redirectURL string) *oauth2.Config

Types

type AvatarSize

type AvatarSize struct {
	Height int `json:"height"`
	Width  int `json:"width"`
}

AvatarSize store avatar size in height*width

func (AvatarSize) SetUrlValues

func (s AvatarSize) SetUrlValues(setter UrlValuesSetter)

type Client

type Client struct {

	// Base URL for API requests.
	BaseURL *url.URL

	// User agent used when communicating with the Hanet AI API.
	UserAgent string

	Devices *DeviceService
	Persons *PersonService
	Places  *PlaceService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient HttpClient, ts oauth2.TokenSource) *Client

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.

The provided ctx must be non-nil, if it is nil an error is returned. If it is canceled or times out, ctx.Err() will be returned.

func (*Client) NewRequest

func (c *Client) NewRequest(urlStr string, fn requestBodyFn) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type ConnectionStatusRequest

type ConnectionStatusRequest struct {
	DeviceIDs []string `json:"deviceIDs" url:"deviceIDs"`
}

type ConnectionStatusResponse

type ConnectionStatusResponse struct {
	Devices []DeviceStatus
}

type DeviceInfo

type DeviceInfo struct {
	DeviceID   string `json:"deviceID"`
	DeviceName string `json:"deviceName"`
	Address    string `json:"address"`

	PlaceID   int    `json:"placeID"`
	PlaceName string `json:"placeName"`
}

type DeviceService

type DeviceService service

func (*DeviceService) GetConnectionStatus

func (s *DeviceService) GetConnectionStatus(ctx context.Context, data *ConnectionStatusRequest) (*ConnectionStatusResponse, error)

func (*DeviceService) GetListDevices

func (s *DeviceService) GetListDevices(ctx context.Context) (*ListDevicesResponse, error)

func (*DeviceService) GetListDevicesByPlace

func (s *DeviceService) GetListDevicesByPlace(ctx context.Context, data *ListDevicesByPlaceRequest) (*ListDevicesResponse, error)

func (*DeviceService) UpdateDevice

func (s *DeviceService) UpdateDevice(ctx context.Context, data *UpdateDeviceRequest) error

type DeviceStatus

type DeviceStatus struct {
	DeviceID string
	IsOnline bool
}

type HttpClient

type HttpClient interface {
	Do(*http.Request) (*http.Response, error)
}

type ListDevicesByPlaceRequest

type ListDevicesByPlaceRequest struct {
	PlaceID int `url:"placeID"`
}

type ListDevicesResponse

type ListDevicesResponse struct {
	Devices []DeviceInfo
}

type Person

type Person struct {
	Name    string `json:"name"`
	AliasID string `json:"aliasID"`
	PlaceID int    `json:"placeID"`
	Title   string `json:"title"`
	Type    string `json:"type"`
}

type PersonFaceURLUpdateRequest added in v0.1.1

type PersonFaceURLUpdateRequest struct {
	AliasID string `json:"aliasID"`
	PlaceID int    `json:"placeID"`
	FileURL string `json:"url"`
}

type PersonFaceUpdateRequest

type PersonFaceUpdateRequest struct {
	AliasID string `json:"aliasID"`
	PlaceID int    `json:"placeID"`
	File    io.Reader
}

type PersonListByPlaceRequest

type PersonListByPlaceRequest struct {
	PlaceID int    `url:"placeID"`
	Type    string `url:"type"`
}

type PersonListItem

type PersonListItem struct {
	Name     string `json:"name"`
	AliasID  string `json:"aliasID"`
	PersonID string `json:"personID"`
	Title    string `json:"title"`
	Avatar   string `json:"avatar"`
}

type PersonRegisterRequest

type PersonRegisterRequest struct {
	*PersonFaceUpdateRequest
	Name  string `json:"name"`
	Title string `json:"title"`
	Type  string `json:"type"`
}

type PersonRegisterResponse

type PersonRegisterResponse struct {
	*Person
	ID   string `json:"personID"`
	File string `json:"file"`
}

type PersonRegisterURLRequest added in v0.1.1

type PersonRegisterURLRequest struct {
	*PersonFaceURLUpdateRequest
	Name  string `json:"name"`
	Title string `json:"title"`
	Type  string `json:"type"`
}

type PersonRemoveByPlaceRequest

type PersonRemoveByPlaceRequest struct {
	AliasID string `url:"aliasID"`
	PlaceID int    `url:"placeID"`
}

type PersonRemoveRequest

type PersonRemoveRequest struct {
	AliasID string `url:"aliasID"`
}

type PersonService

type PersonService service

func (*PersonService) ListByPlace

func (*PersonService) Register

func (*PersonService) RegisterByURL added in v0.1.1

func (*PersonService) Remove

func (s *PersonService) Remove(ctx context.Context, data PersonRemoveRequest) error

func (*PersonService) RemoveByPlace

func (s *PersonService) RemoveByPlace(ctx context.Context, data PersonRemoveByPlaceRequest) error

func (*PersonService) TakeFacePicture added in v0.1.1

func (s *PersonService) TakeFacePicture(ctx context.Context, data TakeFacePictureRequest) error

func (*PersonService) Update

func (s *PersonService) Update(ctx context.Context, data PersonUpdateRequest) error

func (*PersonService) UpdateAliasID

func (s *PersonService) UpdateAliasID(ctx context.Context, data PersonUpdateAliasRequest) error

func (*PersonService) UpdateByFaceImage

func (s *PersonService) UpdateByFaceImage(ctx context.Context, pu PersonFaceUpdateRequest) error

func (*PersonService) UpdateByFaceURL added in v0.1.1

func (s *PersonService) UpdateByFaceURL(ctx context.Context, pu PersonFaceURLUpdateRequest) error

type PersonUpdateAliasRequest

type PersonUpdateAliasRequest struct {
	// NOTE(giautm): persionID is typo from Hanet
	PersonID string `url:"persionID"`
	AliasID  string `url:"aliasID"`
}

type PersonUpdateRequest

type PersonUpdateRequest struct {
	Name    string `json:"name"`
	Title   string `json:"title"`
	AliasID string `json:"-"`
	PlaceID int    `json:"-"`
}

type Place

type Place struct {
	ID      int    `json:"id" url:"placeID"`
	Name    string `json:"name" url:"name"`
	Address string `json:"address" url:"address"`
}

type PlaceService

type PlaceService service

func (*PlaceService) AddPlace

func (s *PlaceService) AddPlace(ctx context.Context, place Place) (*Place, error)

func (*PlaceService) Places

func (s *PlaceService) Places(ctx context.Context) ([]Place, error)

func (*PlaceService) Remove

func (s *PlaceService) Remove(ctx context.Context, place Place) error

func (*PlaceService) UpdatePlace

func (s *PlaceService) UpdatePlace(ctx context.Context, place Place) error

type ServerError

type ServerError struct {
	Code    int
	Message string
}

func (ServerError) Error

func (se ServerError) Error() string

type TakeFacePictureRequest added in v0.1.1

type TakeFacePictureRequest struct {
	DeviceID string `url:"deviceID"`
}

type UpdateDeviceRequest

type UpdateDeviceRequest struct {
	DeviceID   string `json:"deviceID" url:"deviceID"`
	DeviceName string `json:"deviceName" url:"deviceName"`
}

type UrlValuesSetter

type UrlValuesSetter interface {
	Set(field string, value string)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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