ring

package
v1.9.9 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CloseReasonNormalClose          = 0
	CloseReasonAuthenticationFailed = 5
	CloseReasonTimeout              = 6
)

Close reason codes

Variables

This section is empty.

Functions

func AppAPI

func AppAPI(path string) string

func ClientAPI

func ClientAPI(path string) string

API URL helpers

func CommandsAPI

func CommandsAPI(path string) string

func DeviceAPI

func DeviceAPI(path string) string

Types

type AnswerMessage

type AnswerMessage struct {
	Method string `json:"method"` // "sdp"
	Body   struct {
		SessionBody
		SDP  string `json:"sdp"`
		Type string `json:"type"` // "answer"
	} `json:"body"`
}

type Auth2faResponse

type Auth2faResponse struct {
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description"`
	TSVState         string `json:"tsv_state"`
	Phone            string `json:"phone"`
	NextTimeInSecs   int    `json:"next_time_in_secs"`
}

type AuthConfig

type AuthConfig struct {
	RT  string `json:"rt"`  // Refresh Token
	HID string `json:"hid"` // Hardware ID
}

AuthConfig represents the decoded refresh token data

type AuthTokenResponse

type AuthTokenResponse struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	Scope        string `json:"scope"`      // Always "client"
	TokenType    string `json:"token_type"` // Always "Bearer"
}

AuthTokenResponse represents the response from the authentication endpoint

type BaseMessage

type BaseMessage struct {
	Method string         `json:"method"`
	Body   map[string]any `json:"body"`
}

type CameraData

type CameraData struct {
	ID          float64 `json:"id"`
	Description string  `json:"description"`
	DeviceID    string  `json:"device_id"`
	Kind        string  `json:"kind"`
	LocationID  string  `json:"location_id"`
}

CameraData contains common fields for all camera types

type CameraKind

type CameraKind string

CameraKind represents the different types of Ring cameras

const (
	Doorbot             CameraKind = "doorbot"
	Doorbell            CameraKind = "doorbell"
	DoorbellV3          CameraKind = "doorbell_v3"
	DoorbellV4          CameraKind = "doorbell_v4"
	DoorbellV5          CameraKind = "doorbell_v5"
	DoorbellOyster      CameraKind = "doorbell_oyster"
	DoorbellPortal      CameraKind = "doorbell_portal"
	DoorbellScallop     CameraKind = "doorbell_scallop"
	DoorbellScallopLite CameraKind = "doorbell_scallop_lite"
	DoorbellGraham      CameraKind = "doorbell_graham_cracker"
	LpdV1               CameraKind = "lpd_v1"
	LpdV2               CameraKind = "lpd_v2"
	LpdV4               CameraKind = "lpd_v4"
	JboxV1              CameraKind = "jbox_v1"
	StickupCam          CameraKind = "stickup_cam"
	StickupCamV3        CameraKind = "stickup_cam_v3"
	StickupCamElite     CameraKind = "stickup_cam_elite"
	StickupCamLongfin   CameraKind = "stickup_cam_longfin"
	StickupCamLunar     CameraKind = "stickup_cam_lunar"
	SpotlightV2         CameraKind = "spotlightw_v2"
	HpCamV1             CameraKind = "hp_cam_v1"
	HpCamV2             CameraKind = "hp_cam_v2"
	StickupCamV4        CameraKind = "stickup_cam_v4"
	FloodlightV1        CameraKind = "floodlight_v1"
	FloodlightV2        CameraKind = "floodlight_v2"
	FloodlightPro       CameraKind = "floodlight_pro"
	CocoaCamera         CameraKind = "cocoa_camera"
	CocoaDoorbell       CameraKind = "cocoa_doorbell"
	CocoaFloodlight     CameraKind = "cocoa_floodlight"
	CocoaSpotlight      CameraKind = "cocoa_spotlight"
	StickupCamMini      CameraKind = "stickup_cam_mini"
	OnvifCamera         CameraKind = "onvif_camera"
)

type Client

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

func Dial

func Dial(rawURL string) (*Client, error)

func (*Client) AddTrack

func (c *Client) AddTrack(media *core.Media, codec *core.Codec, track *core.Receiver) error

func (*Client) GetMedias

func (c *Client) GetMedias() []*core.Media

func (*Client) GetTrack

func (c *Client) GetTrack(media *core.Media, codec *core.Codec) (*core.Receiver, error)

func (*Client) MarshalJSON

func (c *Client) MarshalJSON() ([]byte, error)

func (*Client) Start

func (c *Client) Start() error

func (*Client) Stop

func (c *Client) Stop() error

type CloseMessage

type CloseMessage struct {
	Method string `json:"method"` // "close"
	Body   struct {
		SessionBody
		Reason struct {
			Code int    `json:"code"`
			Text string `json:"text"`
		} `json:"reason"`
	} `json:"body"`
}

type EmailAuth

type EmailAuth struct {
	Email    string
	Password string
}

type IceCandidateMessage

type IceCandidateMessage struct {
	Method string `json:"method"` // "ice"
	Body   struct {
		SessionBody
		Ice        string `json:"ice"`
		MLineIndex int    `json:"mlineindex"`
	} `json:"body"`
}

type NotificationMessage

type NotificationMessage struct {
	Method string `json:"method"` // "notification"
	Body   struct {
		SessionBody
		IsOK bool   `json:"is_ok"`
		Text string `json:"text"`
	} `json:"body"`
}

type PongMessage

type PongMessage struct {
	Method string      `json:"method"` // "pong"
	Body   SessionBody `json:"body"`
}

type RefreshTokenAuth

type RefreshTokenAuth struct {
	RefreshToken string
}

type RingDeviceType

type RingDeviceType string

RingDeviceType represents different types of Ring devices

const (
	IntercomHandsetAudio RingDeviceType = "intercom_handset_audio"
	OnvifCameraType      RingDeviceType = "onvif_camera"
)

type RingDevicesResponse

type RingDevicesResponse struct {
	Doorbots           []CameraData             `json:"doorbots"`
	AuthorizedDoorbots []CameraData             `json:"authorized_doorbots"`
	StickupCams        []CameraData             `json:"stickup_cams"`
	AllCameras         []CameraData             `json:"all_cameras"`
	Chimes             []CameraData             `json:"chimes"`
	Other              []map[string]interface{} `json:"other"`
}

RingDevicesResponse represents the response from the Ring API

type RingRestClient

type RingRestClient struct {
	Using2FA     bool
	PromptFor2FA string
	RefreshToken string
	// contains filtered or unexported fields
}

RingRestClient handles authentication and requests to Ring API

func NewRingRestClient

func NewRingRestClient(auth interface{}, onTokenRefresh func(string)) (*RingRestClient, error)

NewRingRestClient creates a new Ring client instance

func (*RingRestClient) FetchRingDevices

func (c *RingRestClient) FetchRingDevices() (*RingDevicesResponse, error)

FetchRingDevices gets all Ring devices and categorizes them

func (*RingRestClient) GetAuth

func (c *RingRestClient) GetAuth(twoFactorAuthCode string) (*AuthTokenResponse, error)

getAuth makes an authentication request to the Ring API

func (*RingRestClient) GetSocketTicket

func (c *RingRestClient) GetSocketTicket() (*SocketTicketResponse, error)

func (*RingRestClient) Request

func (c *RingRestClient) Request(method, url string, body interface{}) ([]byte, error)

Request makes an authenticated request to the Ring API

type SessionBody

type SessionBody struct {
	DoorbotID int    `json:"doorbot_id"`
	SessionID string `json:"session_id"`
}

type SessionMessage

type SessionMessage struct {
	Method string      `json:"method"` // "session_created" or "session_started"
	Body   SessionBody `json:"body"`
}

type SnapshotProducer

type SnapshotProducer struct {
	core.Connection
	// contains filtered or unexported fields
}

func NewSnapshotProducer

func NewSnapshotProducer(client *RingRestClient, camera *CameraData) *SnapshotProducer

func (*SnapshotProducer) Start

func (p *SnapshotProducer) Start() error

func (*SnapshotProducer) Stop

func (p *SnapshotProducer) Stop() error

type SocketTicketResponse

type SocketTicketResponse struct {
	Ticket            string `json:"ticket"`
	ResponseTimestamp int64  `json:"response_timestamp"`
}

SocketTicketRequest represents the request to get a socket ticket

type StreamInfoMessage

type StreamInfoMessage struct {
	Method string `json:"method"` // "stream_info"
	Body   struct {
		SessionBody
		Transcoding       bool   `json:"transcoding"`
		TranscodingReason string `json:"transcoding_reason"`
	} `json:"body"`
}

Jump to

Keyboard shortcuts

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