skylight

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseID

func ParseID(s string) (int64, error)

func SplitChoreInstanceID

func SplitChoreInstanceID(choreID string) (baseID, instanceDate string)

Types

type APIError

type APIError struct {
	Status  int
	Method  string
	Path    string
	Body    []byte
	Message string
}

func (*APIError) Error

func (e *APIError) Error() string

type Category

type Category struct {
	ID         string `json:"id"`
	Attributes struct {
		Color                 string `json:"color"`
		Label                 string `json:"label"`
		SelectedForChoreChart bool   `json:"selected_for_chore_chart"`
		LinkedToProfile       bool   `json:"linked_to_profile"`
	} `json:"attributes"`
}

type Chore

type Chore struct {
	ID         string `json:"id"`
	Attributes struct {
		Summary        string   `json:"summary"`
		Description    *string  `json:"description"`
		Status         string   `json:"status"`
		Start          string   `json:"start"`
		RecurrenceSet  []string `json:"recurrence_set"`
		RecurringUntil *string  `json:"recurring_until"`
		CompletedOn    *string  `json:"completed_on"`
		RewardPoints   *int     `json:"reward_points"`
		EmojiIcon      *string  `json:"emoji_icon"`
		UpForGrabs     bool     `json:"up_for_grabs"`
		Recurring      bool     `json:"recurring"`
		Position       int      `json:"position"`
	} `json:"attributes"`
	Relationships struct {
		Category struct {
			Data *struct {
				ID string `json:"id"`
			} `json:"data"`
		} `json:"category"`
	} `json:"relationships"`
}

type ChoreCompletion

type ChoreCompletion struct {
	Status       string `json:"status"`
	InstanceDate string `json:"instance_date,omitempty"`
}

type ChoreCreate

type ChoreCreate struct {
	Summary       string   `json:"summary"`
	CategoryID    int64    `json:"category_id,omitempty"`
	Start         string   `json:"start"`
	RecurrenceSet []string `json:"recurrence_set,omitempty"`
	UpForGrabs    bool     `json:"up_for_grabs"`
	RewardPoints  *int     `json:"reward_points,omitempty"`
	Description   string   `json:"description,omitempty"`
	EmojiIcon     string   `json:"emoji_icon,omitempty"`
}

type ChoreFilter

type ChoreFilter struct {
	Date              string
	Status            string
	AssigneeID        string
	After             string
	Before            string
	IncludeLate       bool
	IncludeUpForGrabs bool
	OnlyUpForGrabs    bool
	LinkedToProfile   bool
}

type ChoreUpdate

type ChoreUpdate struct {
	Summary      *string `json:"summary,omitempty"`
	CategoryID   *int64  `json:"category_id,omitempty"`
	Start        *string `json:"start,omitempty"`
	Status       *string `json:"status,omitempty"`
	RewardPoints *int    `json:"reward_points,omitempty"`
	UpForGrabs   *bool   `json:"up_for_grabs,omitempty"`
}

type Client

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

func New

func New(baseURL, token string, opts ...Option) *Client

func (*Client) ClaimChore

func (c *Client) ClaimChore(ctx context.Context, frameID int64, choreID string, categoryID int64) (*Chore, error)

func (*Client) CreateChore

func (c *Client) CreateChore(ctx context.Context, frameID int64, in ChoreCreate) (*Chore, error)

func (*Client) CreateRewards

func (c *Client) CreateRewards(ctx context.Context, frameID int64, in RewardCreate) ([]Reward, error)

CreateRewards creates one reward per category_id; Skylight returns the array.

func (*Client) CreateUpForGrabsChore

func (c *Client) CreateUpForGrabsChore(ctx context.Context, frameID int64, in ChoreCreate) (*Chore, error)

func (*Client) DeleteChore

func (c *Client) DeleteChore(ctx context.Context, frameID, choreID int64, applyTo string) error

func (*Client) DeleteReward

func (c *Client) DeleteReward(ctx context.Context, frameID, rewardID int64) error

func (*Client) Do

func (c *Client) Do(ctx context.Context, method, path string, query url.Values, body any) ([]byte, error)

func (*Client) GetFrame

func (c *Client) GetFrame(ctx context.Context, frameID int64) (*Frame, error)

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context) (*User, error)

func (*Client) ListCategories

func (c *Client) ListCategories(ctx context.Context, frameID int64) ([]Category, error)

func (*Client) ListChores

func (c *Client) ListChores(ctx context.Context, frameID int64, f ChoreFilter) ([]Chore, error)

func (*Client) ListFrames added in v0.1.1

func (c *Client) ListFrames(ctx context.Context) ([]Frame, error)

func (*Client) ListRewardPoints

func (c *Client) ListRewardPoints(ctx context.Context, frameID int64) ([]RewardPoint, error)

func (*Client) ListRewards

func (c *Client) ListRewards(ctx context.Context, frameID int64) ([]Reward, error)

func (*Client) LoginOAuth

func (c *Client) LoginOAuth(ctx context.Context, email, password, fingerprint string) (*OAuthTokenResponse, error)

func (*Client) RedeemReward

func (c *Client) RedeemReward(ctx context.Context, frameID, rewardID int64) error

func (*Client) RefreshOAuthToken

func (c *Client) RefreshOAuthToken(ctx context.Context, refreshToken, fingerprint string) (*OAuthTokenResponse, error)

func (*Client) SetChoreCompletion

func (c *Client) SetChoreCompletion(ctx context.Context, frameID int64, choreID string, status string) (*Chore, error)

func (*Client) UnredeemReward

func (c *Client) UnredeemReward(ctx context.Context, frameID, rewardID int64) error

func (*Client) UpdateChore

func (c *Client) UpdateChore(ctx context.Context, frameID int64, choreID string, in ChoreUpdate) (*Chore, error)

func (*Client) UpdateReward

func (c *Client) UpdateReward(ctx context.Context, frameID, rewardID int64, in RewardUpdate) (*Reward, error)

type Frame

type Frame struct {
	ID         string `json:"id"`
	Attributes struct {
		Name          string `json:"name"`
		HouseholdName string `json:"household_name"`
		Timezone      string `json:"timezone"`
		HardwareModel string `json:"hardware_model"`
		Mine          bool   `json:"mine"`
		Plus          bool   `json:"plus"`
		Activated     bool   `json:"activated"`
	} `json:"attributes"`
}

type OAuthTokenResponse

type OAuthTokenResponse struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int    `json:"expires_in"`
	TokenType    string `json:"token_type"`
}

type Option

type Option func(*Client)

func WithAPIVersion

func WithAPIVersion(v string) Option

func WithAuthScheme

func WithAuthScheme(s string) Option

func WithDryRun

func WithDryRun(on bool) Option

func WithReadOnly added in v0.1.6

func WithReadOnly(on bool) Option

WithReadOnly makes Do refuse non-GET requests. This backstops the CLI-level command allowlist so --readonly cannot be bypassed by argv parsing drift.

func WithTimeout

func WithTimeout(d time.Duration) Option

func WithTrace

func WithTrace(fn func(method, url string, status int, dur time.Duration)) Option

func WithUserAgent

func WithUserAgent(ua string) Option

type Reward

type Reward struct {
	ID         string `json:"id"`
	Attributes struct {
		Name                string  `json:"name"`
		EmojiIcon           *string `json:"emoji_icon"`
		Description         *string `json:"description"`
		PointValue          int     `json:"point_value"`
		RespawnOnRedemption bool    `json:"respawn_on_redemption"`
		RedeemedAt          *string `json:"redeemed_at"`
	} `json:"attributes"`
	Relationships struct {
		Category struct {
			Data *struct {
				ID string `json:"id"`
			} `json:"data"`
		} `json:"category"`
	} `json:"relationships"`
}

type RewardCreate

type RewardCreate struct {
	Name                string  `json:"name"`
	PointValue          int     `json:"point_value"`
	CategoryIDs         []int64 `json:"category_ids"`
	EmojiIcon           string  `json:"emoji_icon,omitempty"`
	Description         string  `json:"description,omitempty"`
	RespawnOnRedemption bool    `json:"respawn_on_redemption,omitempty"`
}

type RewardPoint

type RewardPoint struct {
	CategoryID           int64 `json:"category_id"`
	CurrentPointBalance  int   `json:"current_point_balance"`
	LifetimePointsEarned int   `json:"lifetime_points_earned"`
}

type RewardUpdate

type RewardUpdate struct {
	Name                *string `json:"name,omitempty"`
	PointValue          *int    `json:"point_value,omitempty"`
	EmojiIcon           *string `json:"emoji_icon,omitempty"`
	Description         *string `json:"description,omitempty"`
	RespawnOnRedemption *bool   `json:"respawn_on_redemption,omitempty"`
}

type User

type User struct {
	ID         string `json:"id"`
	Attributes struct {
		Email              string `json:"email"`
		SubscriptionStatus string `json:"subscription_status"`
		Profile            struct {
			ID int64 `json:"id"`
		} `json:"profile"`
	} `json:"attributes"`
}

Jump to

Keyboard shortcuts

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