ringapi

package
v0.0.0-...-f6a25d2 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureApiConfigDefaults

func EnsureApiConfigDefaults(config *ApiConfig) bool

EnsureApiConfigDefaults handles setting sane defaults and migrating the config forward. It returns `true` if any changes were made.

Types

type ApiConfig

type ApiConfig struct {
	HardwareId string `json:"hardware_id"`
}

ApiConfig provides a way to alter API behaviors. This is a serializable structure.

type Authenticator

type Authenticator interface {
	PromptCredentials() (string, string, error)
	Prompt2FACode() (string, error)
}

Authenticator implements routines for capturing info necessary to authenticate the user and authorize the token for use with this application.

type AuthorizedSession

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

AuthorizedSession is necessary to perform ring API calls. Retreive this instance by calling OpenAuthorizedSession.

func OpenAuthorizedSession

func OpenAuthorizedSession(cfg ApiConfig, t TokenHandler, a Authenticator) (*AuthorizedSession, error)

OpenAuthorizedSession creates a new AuthorizedSession instance by retreiving an OAUTH2 Token. This token might already exist, in which case the Authenticator is not needed. If the token does not exist and the Authenticator is nil (maybe because your application is not user-interactive) this function will fail.

func (*AuthorizedSession) GetChimeHealth

func (session *AuthorizedSession) GetChimeHealth(chime *ring_types.Chime) (*ring_types.DoorBotHealthResponse, error)

GetChimeHealth fetches the health info for a particular id.

func (*AuthorizedSession) GetDevices

func (session *AuthorizedSession) GetDevices() (*ring_types.DevicesResponse, error)

GetDevices fetches the ring devices in the current API session.

func (*AuthorizedSession) GetDoorBotHealth

func (session *AuthorizedSession) GetDoorBotHealth(id uint32) (*ring_types.DoorBotHealthResponse, error)

GetDoorBotHealth fetches the health info for a particular id.

func (*AuthorizedSession) GetDoorBotHistory

func (session *AuthorizedSession) GetDoorBotHistory(id uint32) ([]ring_types.DoorBotDing, error)

func (*AuthorizedSession) GetSessionInfo

func (session *AuthorizedSession) GetSessionInfo() (*ring_types.SessionResponse, error)

GetSessionInfo fetches information about the current API session

type TokenHandler

type TokenHandler interface {
	FetchToken() *oauth2.Token
	StoreToken(*oauth2.Token)
}

TokenHandler implements routines for Fetch'ing and Store'ing the OAUTH2 Token from some persistence. This is especially useful when 2FA is in use.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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