sesame

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2022 License: MIT Imports: 12 Imported by: 0

README

Sesame

Go Reference

This package provides a client to the Sesame API.

This package API Client to lock the keys of Sesame API using signatures encrypted with the AES-CMAC method.

For more information about the API, please see the official documentation.

https://doc.candyhouse.co/ja/SesameAPI

Example

Toggle Sesame From Script


package main

import (
	"context"
	"fmt"
	"github.com/NerdyBoyCool/sesame"
)

func main() {
	cli := sesame.NewClient("your sesame api key", "sesame secret key for aes-cmac", "Sesame UUID assigned to each Sesame(Sesame UUID)")
	ctx := context.Background()
	err := cli.Toggle(ctx, "From API")
	if err != nil {
		fmt.Println(err)
	}
}

Get current sesame's information.


package main

import (
	"context"
	"fmt"
	"github.com/NerdyBoyCool/sesame"
)

func main() {
	cli := sesame.NewClient("your sesame api key", "sesame secret key for aes-cmac", "Sesame UUID assigned to each Sesame(Sesame UUID)")
	ctx := context.Background()
	s, err := cli.Device(ctx)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(s.BatteryPercentage)
}

Features

  • Add Test For client.go
  • Obtain Sesame locking history from client

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
}

APIError represents an error of connpass API.

func (*APIError) Error

func (err *APIError) Error() string

Error implements error.Error.

type BodyParams

type BodyParams struct {
	Cmd     int16  `json:"cmd"`
	History string `json:"history"`
	Sign    string `json:"sign"`
}

BodyParams is a Request Body for API Request

type Client

type Client struct {
	HTTPClient *http.Client
	APIKey     string
	SecretKey  string
	DeviseUUID string
	URL        string
}

Client is a client of sesame API.

func NewClient

func NewClient(apiKey, secretKey, deviseUUID string) *Client

NewClient creates a new sesame api client.

func (*Client) Device added in v0.1.0

func (client *Client) Device(ctx context.Context) (*Sesame, error)

Device Get the current status of the Sesame device

func (*Client) Lock

func (client *Client) Lock(ctx context.Context, history string) error

Lock Sesame

func (*Client) Toggle

func (client *Client) Toggle(ctx context.Context, history string) error

Toggle Sesame

func (*Client) Unlock

func (client *Client) Unlock(ctx context.Context, history string) error

Unlock Sesame

type Sesame added in v0.1.0

type Sesame struct {
	BatteryPercentage uint8   `json:"batteryPercentage"`
	BatteryVoltage    float64 `json:"batteryVoltage"`
	Position          uint16  `json:"position"`
	CHSesame2Status   string  `json:"chSesame2Status"`
	TimeStamp         uint32  `json:"timeStamp"`
}

Jump to

Keyboard shortcuts

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