builders.go

  1// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
  2//
  3// SPDX-License-Identifier: AGPL-3.0-or-later
  4
  5package lunatask
  6
  7import "time"
  8
  9// TaskBuilder provides a fluent interface for constructing CreateTaskRequest.
 10type TaskBuilder struct {
 11	req CreateTaskRequest
 12}
 13
 14// NewTask creates a new TaskBuilder with the required name field.
 15func NewTask(name string) *TaskBuilder {
 16	return &TaskBuilder{req: CreateTaskRequest{Name: name}}
 17}
 18
 19// InArea sets the area ID for the task.
 20func (b *TaskBuilder) InArea(areaID string) *TaskBuilder {
 21	b.req.AreaID = &areaID
 22	return b
 23}
 24
 25// InGoal sets the goal ID for the task.
 26func (b *TaskBuilder) InGoal(goalID string) *TaskBuilder {
 27	b.req.GoalID = &goalID
 28	return b
 29}
 30
 31// WithNote sets the note/description for the task.
 32func (b *TaskBuilder) WithNote(note string) *TaskBuilder {
 33	b.req.Note = &note
 34	return b
 35}
 36
 37// WithStatus sets the task status (later, next, started, waiting, completed).
 38func (b *TaskBuilder) WithStatus(status string) *TaskBuilder {
 39	b.req.Status = &status
 40	return b
 41}
 42
 43// WithMotivation sets the motivation (must, should, want).
 44func (b *TaskBuilder) WithMotivation(motivation string) *TaskBuilder {
 45	b.req.Motivation = &motivation
 46	return b
 47}
 48
 49// WithEstimate sets the time estimate in minutes (0-720).
 50func (b *TaskBuilder) WithEstimate(minutes int) *TaskBuilder {
 51	b.req.Estimate = &minutes
 52	return b
 53}
 54
 55// WithPriority sets the priority (-2 to 2: lowest, low, neutral, high, highest).
 56func (b *TaskBuilder) WithPriority(priority int) *TaskBuilder {
 57	b.req.Priority = &priority
 58	return b
 59}
 60
 61// WithEisenhower sets the Eisenhower matrix category (0-4).
 62func (b *TaskBuilder) WithEisenhower(eisenhower int) *TaskBuilder {
 63	b.req.Eisenhower = &eisenhower
 64	return b
 65}
 66
 67// ScheduledOn sets the scheduled date for the task.
 68func (b *TaskBuilder) ScheduledOn(date Date) *TaskBuilder {
 69	b.req.ScheduledOn = &date
 70	return b
 71}
 72
 73// CompletedAt sets the completion timestamp.
 74func (b *TaskBuilder) CompletedAt(t time.Time) *TaskBuilder {
 75	b.req.CompletedAt = &t
 76	return b
 77}
 78
 79// FromSource sets the external source integration.
 80func (b *TaskBuilder) FromSource(source, sourceID string) *TaskBuilder {
 81	b.req.Source = &source
 82	b.req.SourceID = &sourceID
 83	return b
 84}
 85
 86// Build returns the constructed CreateTaskRequest.
 87func (b *TaskBuilder) Build() *CreateTaskRequest {
 88	return &b.req
 89}
 90
 91// TaskUpdateBuilder provides a fluent interface for constructing UpdateTaskRequest.
 92type TaskUpdateBuilder struct {
 93	req UpdateTaskRequest
 94}
 95
 96// NewTaskUpdate creates a new TaskUpdateBuilder.
 97func NewTaskUpdate() *TaskUpdateBuilder {
 98	return &TaskUpdateBuilder{}
 99}
100
101// Name sets the task name.
102func (b *TaskUpdateBuilder) Name(name string) *TaskUpdateBuilder {
103	b.req.Name = &name
104	return b
105}
106
107// InArea sets the area ID for the task.
108func (b *TaskUpdateBuilder) InArea(areaID string) *TaskUpdateBuilder {
109	b.req.AreaID = &areaID
110	return b
111}
112
113// InGoal sets the goal ID for the task.
114func (b *TaskUpdateBuilder) InGoal(goalID string) *TaskUpdateBuilder {
115	b.req.GoalID = &goalID
116	return b
117}
118
119// WithNote sets the note/description for the task.
120func (b *TaskUpdateBuilder) WithNote(note string) *TaskUpdateBuilder {
121	b.req.Note = &note
122	return b
123}
124
125// WithStatus sets the task status (later, next, started, waiting, completed).
126func (b *TaskUpdateBuilder) WithStatus(status string) *TaskUpdateBuilder {
127	b.req.Status = &status
128	return b
129}
130
131// WithMotivation sets the motivation (must, should, want).
132func (b *TaskUpdateBuilder) WithMotivation(motivation string) *TaskUpdateBuilder {
133	b.req.Motivation = &motivation
134	return b
135}
136
137// WithEstimate sets the time estimate in minutes (0-720).
138func (b *TaskUpdateBuilder) WithEstimate(minutes int) *TaskUpdateBuilder {
139	b.req.Estimate = &minutes
140	return b
141}
142
143// WithPriority sets the priority (-2 to 2: lowest, low, neutral, high, highest).
144func (b *TaskUpdateBuilder) WithPriority(priority int) *TaskUpdateBuilder {
145	b.req.Priority = &priority
146	return b
147}
148
149// WithEisenhower sets the Eisenhower matrix category (0-4).
150func (b *TaskUpdateBuilder) WithEisenhower(eisenhower int) *TaskUpdateBuilder {
151	b.req.Eisenhower = &eisenhower
152	return b
153}
154
155// ScheduledOn sets the scheduled date for the task.
156func (b *TaskUpdateBuilder) ScheduledOn(date Date) *TaskUpdateBuilder {
157	b.req.ScheduledOn = &date
158	return b
159}
160
161// CompletedAt sets the completion timestamp.
162func (b *TaskUpdateBuilder) CompletedAt(t time.Time) *TaskUpdateBuilder {
163	b.req.CompletedAt = &t
164	return b
165}
166
167// Build returns the constructed UpdateTaskRequest.
168func (b *TaskUpdateBuilder) Build() *UpdateTaskRequest {
169	return &b.req
170}
171
172// NoteBuilder provides a fluent interface for constructing CreateNoteRequest.
173type NoteBuilder struct {
174	req CreateNoteRequest
175}
176
177// NewNote creates a new NoteBuilder.
178func NewNote() *NoteBuilder {
179	return &NoteBuilder{}
180}
181
182// WithName sets the note name/title.
183func (b *NoteBuilder) WithName(name string) *NoteBuilder {
184	b.req.Name = &name
185	return b
186}
187
188// WithContent sets the note content.
189func (b *NoteBuilder) WithContent(content string) *NoteBuilder {
190	b.req.Content = &content
191	return b
192}
193
194// InNotebook sets the notebook ID.
195func (b *NoteBuilder) InNotebook(notebookID string) *NoteBuilder {
196	b.req.NotebookID = &notebookID
197	return b
198}
199
200// FromSource sets the external source integration.
201func (b *NoteBuilder) FromSource(source, sourceID string) *NoteBuilder {
202	b.req.Source = &source
203	b.req.SourceID = &sourceID
204	return b
205}
206
207// Build returns the constructed CreateNoteRequest.
208func (b *NoteBuilder) Build() *CreateNoteRequest {
209	return &b.req
210}
211
212// JournalEntryBuilder provides a fluent interface for constructing CreateJournalEntryRequest.
213type JournalEntryBuilder struct {
214	req CreateJournalEntryRequest
215}
216
217// NewJournalEntry creates a new JournalEntryBuilder with the required date.
218func NewJournalEntry(date Date) *JournalEntryBuilder {
219	return &JournalEntryBuilder{req: CreateJournalEntryRequest{DateOn: date}}
220}
221
222// WithName sets the entry title (defaults to weekday name if omitted).
223func (b *JournalEntryBuilder) WithName(name string) *JournalEntryBuilder {
224	b.req.Name = &name
225	return b
226}
227
228// WithContent sets the Markdown content.
229func (b *JournalEntryBuilder) WithContent(content string) *JournalEntryBuilder {
230	b.req.Content = &content
231	return b
232}
233
234// Build returns the constructed CreateJournalEntryRequest.
235func (b *JournalEntryBuilder) Build() *CreateJournalEntryRequest {
236	return &b.req
237}
238
239// PersonBuilder provides a fluent interface for constructing CreatePersonRequest.
240type PersonBuilder struct {
241	req CreatePersonRequest
242}
243
244// NewPerson creates a new PersonBuilder.
245func NewPerson() *PersonBuilder {
246	return &PersonBuilder{}
247}
248
249// WithFirstName sets the person's first name.
250func (b *PersonBuilder) WithFirstName(name string) *PersonBuilder {
251	b.req.FirstName = &name
252	return b
253}
254
255// WithLastName sets the person's last name.
256func (b *PersonBuilder) WithLastName(name string) *PersonBuilder {
257	b.req.LastName = &name
258	return b
259}
260
261// WithRelationshipStrength sets the relationship strength category.
262func (b *PersonBuilder) WithRelationshipStrength(strength string) *PersonBuilder {
263	b.req.RelationshipStrength = &strength
264	return b
265}
266
267// FromSource sets the external source integration.
268func (b *PersonBuilder) FromSource(source, sourceID string) *PersonBuilder {
269	b.req.Source = &source
270	b.req.SourceID = &sourceID
271	return b
272}
273
274// Build returns the constructed CreatePersonRequest.
275func (b *PersonBuilder) Build() *CreatePersonRequest {
276	return &b.req
277}
278
279// TimelineNoteBuilder provides a fluent interface for constructing CreatePersonTimelineNoteRequest.
280type TimelineNoteBuilder struct {
281	req CreatePersonTimelineNoteRequest
282}
283
284// NewTimelineNote creates a new TimelineNoteBuilder with the required person ID.
285func NewTimelineNote(personID string) *TimelineNoteBuilder {
286	return &TimelineNoteBuilder{req: CreatePersonTimelineNoteRequest{PersonID: personID}}
287}
288
289// OnDate sets the date for the timeline note.
290func (b *TimelineNoteBuilder) OnDate(date Date) *TimelineNoteBuilder {
291	b.req.DateOn = &date
292	return b
293}
294
295// WithContent sets the Markdown content.
296func (b *TimelineNoteBuilder) WithContent(content string) *TimelineNoteBuilder {
297	b.req.Content = &content
298	return b
299}
300
301// Build returns the constructed CreatePersonTimelineNoteRequest.
302func (b *TimelineNoteBuilder) Build() *CreatePersonTimelineNoteRequest {
303	return &b.req
304}