1// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
2//
3// SPDX-License-Identifier: AGPL-3.0-or-later
4
5package lunatask
6
7import (
8 "context"
9 "fmt"
10 "net/http"
11 "time"
12)
13
14// PersonTimelineNote represents a note on a person's memory timeline.
15// Note: content is E2EE and not returned by the API.
16type PersonTimelineNote struct {
17 ID string `json:"id"`
18 DateOn *Date `json:"date_on"`
19 CreatedAt time.Time `json:"created_at"`
20 UpdatedAt time.Time `json:"updated_at"`
21}
22
23// CreatePersonTimelineNoteRequest represents the request to create a timeline note.
24type CreatePersonTimelineNoteRequest struct {
25 // PersonID is the ID of the person to add the note to (required).
26 PersonID string `json:"person_id"`
27 // DateOn is the ISO-8601 date for the note (optional, defaults to today).
28 DateOn *Date `json:"date_on,omitempty"`
29 // Content is the Markdown content of the note (optional but impractical if empty).
30 Content *string `json:"content,omitempty"`
31}
32
33// personTimelineNoteResponse represents a single timeline note response from the API.
34type personTimelineNoteResponse struct {
35 PersonTimelineNote PersonTimelineNote `json:"person_timeline_note"`
36}
37
38// CreatePersonTimelineNote creates a new note on a person's memory timeline.
39func (c *Client) CreatePersonTimelineNote(ctx context.Context, note *CreatePersonTimelineNoteRequest) (*PersonTimelineNote, error) {
40 if note.PersonID == "" {
41 return nil, fmt.Errorf("%w: person_id is required", ErrBadRequest)
42 }
43
44 resp, _, err := doJSON[personTimelineNoteResponse](c, ctx, http.MethodPost, "/person_timeline_notes", note)
45 if err != nil {
46 return nil, err
47 }
48
49 return &resp.PersonTimelineNote, nil
50}