message

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SoundEventMessageType is for working with sound event messages
	SoundEventMessageType = "SOUND"
	// MotionEventMessageType is for working with motion event messages
	MotionEventMessageType = "MOTION"
	// TemperatureEventMessageType is for working with temperature event messages
	TemperatureEventMessageType = "TEMPERATURE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	// TODO: Determin format for ReadAt, SeenAt, and DismissedAt
	// TODO: unmarshall UpdatedAt and CreatedAt ISO8601 timestamp into time.Time
	// TODO: enumerate possible Data interface structures
	Id          int         `json:"id"`
	BabyUid     string      `json:"baby_uid"`
	UserId      int         `json:"user_id"`
	Type        string      `json:"type"`
	Time        UnixTime    `json:"time"`
	ReadAt      string      `json:"read_at"`
	SeenAt      string      `json:"seen_at"`
	DismissedAt string      `json:"dismissed_at"`
	UpdatedAt   string      `json:"updated_at"`
	CreatedAt   string      `json:"created_at"`
	Data        interface{} `json:"data"`
}

Message - message info (matching the Nanit API)

func FilterMessages

func FilterMessages(messages []Message, cond func(message Message) bool) []Message

FilterMessages allows a slice (?) of Messages to be filtered by an aribitrary function that returns true or false for each element, indicating whether it should be included in the filtered set or not

type UnixTime

type UnixTime time.Time

func (UnixTime) MarshalJSON

func (t UnixTime) MarshalJSON() ([]byte, error)

MarshalJSON is used to convert the timestamp to JSON

func (UnixTime) String

func (t UnixTime) String() string

String returns t as a formatted string

func (UnixTime) Time

func (t UnixTime) Time() time.Time

Time returns the JSON time as a time.Time instance in UTC

func (UnixTime) Unix

func (t UnixTime) Unix() int64

Unix returns t as a Unix time, the number of seconds elapsed since January 1, 1970 UTC. The result does not depend on the location associated with t.

func (*UnixTime) UnmarshalJSON

func (t *UnixTime) UnmarshalJSON(unixTimeBytes []byte) (err error)

UnmarshalJSON is used to convert the timestamp from JSON

Jump to

Keyboard shortcuts

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