rest

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package rest implements stateless Roborock cloud authentication and inventory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeOTA

func DecodeOTA(encoded string) (*dependencymodels.InventoryOTA, error)

DecodeOTA decodes the JSON string in inventory datapoint 10007.

func DecodeProductInfo

func DecodeProductInfo(encoded string) (*dependencymodels.InventoryProductInfo, error)

DecodeProductInfo decodes the JSON string in inventory datapoint 10005.

func DecodeProgramState

func DecodeProgramState(encoded string) (*dependencymodels.InventoryProgramState, error)

DecodeProgramState decodes the JSON string in inventory datapoint 10001.

func DecodeProperty

func DecodeProperty(encoded string) (*dependencymodels.ProductPropertyConstraints, error)

DecodeProperty decodes JSON-encoded product constraints; JSON null returns nil.

Types

type AgreementRequest

type AgreementRequest struct{ Login LoginContext }

AgreementRequest retrieves current agreement versions for a country.

type AgreementResult

type AgreementResult struct{ Agreement dependencymodels.Agreement }

AgreementResult supplies the agreement version used at login.

type AuthContext

type AuthContext struct {
	Token    string
	ClientID string
	BaseURL  string
	RRiot    dependencymodels.RRiot
}

AuthContext holds caller-owned credentials for one account.

type Client

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

Client retains configuration only; credentials belong to each request.

func New

func New(opts ...Option) (*Client, error)

New constructs a client; a regional origin is supplied here or per request.

func (*Client) GetAgreement

func (c *Client) GetAgreement(ctx context.Context, request AgreementRequest) (AgreementResult, error)

GetAgreement retrieves the latest agreement; it does not conceal failures.

func (*Client) HomeData

func (c *Client) HomeData(ctx context.Context, request HomeDataRequest) (HomeDataResult, error)

HomeData retrieves a specified home's inventory using per-call Hawk credentials.

func (*Client) HomeDetail

func (c *Client) HomeDetail(ctx context.Context, request HomeDetailRequest) (HomeDetailResult, error)

HomeDetail uses plain token authentication against the regional IoT origin.

func (*Client) HomeRooms added in v0.2.0

func (c *Client) HomeRooms(ctx context.Context, request HomeRoomsRequest) (RoomsResult, error)

HomeRooms reads the rooms currently associated with a home.

func (*Client) LoginCode

func (c *Client) LoginCode(ctx context.Context, request LoginCodeRequest) (LoginResult, error)

LoginCode submits explicit country, signature, and agreement settings.

func (*Client) LoginLegacyCode

func (c *Client) LoginLegacyCode(ctx context.Context, request LoginLegacyCodeRequest) (LoginResult, error)

LoginLegacyCode submits an explicitly selected v1 email code login.

func (*Client) LoginPassword

func (c *Client) LoginPassword(ctx context.Context, request LoginPasswordRequest) (LoginResult, error)

LoginPassword uses the legacy v1 password exchange evidenced by the reference.

func (*Client) RequestCode

func (c *Client) RequestCode(ctx context.Context, request CodeRequest) (CodeResult, error)

RequestCode sends a v4 email code request without implicit fallback.

func (*Client) ResolveRegion

func (c *Client) ResolveRegion(ctx context.Context, request RegionRequest) (RegionResult, error)

ResolveRegion makes one explicit regional lookup; it never cycles regions.

func (*Client) SharedDeviceRooms added in v0.2.0

func (c *Client) SharedDeviceRooms(ctx context.Context, request SharedDeviceRoomsRequest) (RoomsResult, error)

SharedDeviceRooms accepts the provider's roomId alias when id is absent.

func (*Client) SignKey

func (c *Client) SignKey(ctx context.Context, request SignRequest) (SignResult, error)

SignKey generates a nonce and obtains its matching mercy key.

type CodeRequest

type CodeRequest struct{ Login LoginContext }

CodeRequest requests an email verification code.

type CodeResult

type CodeResult struct{}

CodeResult acknowledges acceptance of the email request.

type HTTPDoer

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

HTTPDoer makes every REST exchange injectable.

type HomeDataRequest

type HomeDataRequest struct {
	Auth    AuthContext
	HomeID  int64
	Version int
}

HomeDataRequest selects a home and a documented version (1, 2, or 3).

type HomeDataResult

type HomeDataResult struct{ Home dependencymodels.HomeData }

HomeDataResult contains inventory with absent fields preserved by pointers.

type HomeDetailRequest

type HomeDetailRequest struct{ Auth AuthContext }

HomeDetailRequest authenticates a home ID lookup using the caller's token.

type HomeDetailResult

type HomeDetailResult struct{ Home dependencymodels.HomeDetail }

HomeDetailResult contains the vendor home identifier.

type HomeRoomsRequest added in v0.2.0

type HomeRoomsRequest struct {
	Auth   AuthContext
	HomeID int64
}

HomeRoomsRequest refreshes rooms using a caller-owned home ID and account.

type LoginCodeRequest

type LoginCodeRequest struct {
	Login     LoginContext
	Code      string
	Signature SignResult
	Agreement dependencymodels.Agreement
}

LoginCodeRequest submits a code with caller-obtained mercy and agreement values.

type LoginContext

type LoginContext struct {
	Email       string
	ClientID    string
	Country     string
	CountryCode string
	BaseURL     string
}

LoginContext identifies one account and its explicit regional settings.

type LoginLegacyCodeRequest

type LoginLegacyCodeRequest struct {
	Login LoginContext
	Code  string
}

LoginLegacyCodeRequest selects the evidenced legacy code endpoint.

type LoginPasswordRequest

type LoginPasswordRequest struct {
	Login    LoginContext
	Password string
}

LoginPasswordRequest selects the evidenced legacy password endpoint.

type LoginResult

type LoginResult struct{ User dependencymodels.UserData }

LoginResult holds the newly returned credentials without mutating the client.

type Option

type Option func(*Client)

Option configures a reusable client at construction.

func WithBaseURL

func WithBaseURL(v string) Option

WithBaseURL sets the default explicit regional origin.

func WithClock

func WithClock(v func() time.Time) Option

WithClock supplies signing time.

func WithHTTPClient

func WithHTTPClient(v HTTPDoer) Option

WithHTTPClient supplies an HTTP transport owned by the caller.

func WithRandom

func WithRandom(v io.Reader) Option

WithRandom supplies signing entropy. The reader must support concurrent reads.

type RegionRequest

type RegionRequest struct {
	Email   string
	BaseURL string
}

RegionRequest resolves an email at the supplied origin only.

type RegionResult

type RegionResult struct{ Region dependencymodels.RegionData }

RegionResult contains the service's region and country discovery result.

type RoomsResult added in v0.2.0

type RoomsResult struct {
	Rooms []dependencymodels.RefreshedRoom
}

RoomsResult preserves missing room names and forward-compatible room fields.

type SharedDeviceRoomsRequest added in v0.2.0

type SharedDeviceRoomsRequest struct {
	Auth     AuthContext
	DeviceID string
}

SharedDeviceRoomsRequest selects a received device without changing account state.

type SignRequest

type SignRequest struct{ Login LoginContext }

SignRequest asks the service to sign a new 16-character mercy nonce.

type SignResult

type SignResult struct {
	Nonce string
	Key   string
}

SignResult contains the paired nonce and signature for one login.

Jump to

Keyboard shortcuts

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