feat(lunatask): add CreateJournalEntry endpoint

Amolith created

Assisted-by: Claude Sonnet 4 via Crush

Change summary

lunatask/journal.go | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)

Detailed changes

lunatask/journal.go 🔗

@@ -0,0 +1,45 @@
+// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
+//
+// 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
+}