From ac612e69e9b0f308453b3c9a8849f9b5063b3c31 Mon Sep 17 00:00:00 2001 From: Amolith Date: Fri, 19 Dec 2025 00:31:58 -0700 Subject: [PATCH] feat(lunatask): add CreateJournalEntry endpoint Assisted-by: Claude Sonnet 4 via Crush --- lunatask/journal.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 lunatask/journal.go diff --git a/lunatask/journal.go b/lunatask/journal.go new file mode 100644 index 0000000000000000000000000000000000000000..a9dbda9083c27e7eb3efd59edb2696fd31a92266 --- /dev/null +++ b/lunatask/journal.go @@ -0,0 +1,45 @@ +// SPDX-FileCopyrightText: Amolith +// +// SPDX-License-Identifier: AGPL-3.0-or-later + +package lunatask + +import ( + "context" + "net/http" + "time" +) + +// JournalEntry represents a journal entry returned from the Lunatask API. +// Note: name and content are E2EE and not returned by the API. +type JournalEntry struct { + ID string `json:"id"` + DateOn Date `json:"date_on"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` +} + +// CreateJournalEntryRequest represents the request to create a journal entry. +type CreateJournalEntryRequest struct { + // DateOn is the date for the journal entry (required). + DateOn Date `json:"date_on"` + // Name is the title for the entry (optional, defaults to weekday name like "Tuesday, July 1st"). + Name *string `json:"name,omitempty"` + // Content is the Markdown content of the entry (optional). + Content *string `json:"content,omitempty"` +} + +// journalEntryResponse represents a single journal entry response from the API. +type journalEntryResponse struct { + JournalEntry JournalEntry `json:"journal_entry"` +} + +// CreateJournalEntry creates a new journal entry for a given date. +func (c *Client) CreateJournalEntry(ctx context.Context, entry *CreateJournalEntryRequest) (*JournalEntry, error) { + resp, _, err := doJSON[journalEntryResponse](c, ctx, http.MethodPost, "/journal_entries", entry) + if err != nil { + return nil, err + } + + return &resp.JournalEntry, nil +}