summaryrefslogtreecommitdiff
path: root/internal/actions/actions.go
blob: 7f707d303ef39c526daf56000caf63c302098895 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package actions

import (
	"context"

	"git.tjp.lol/punchcard/internal/queries"
)

// Actions provides high-level business operations for time tracking
type Actions interface {
	// Timer operations
	PunchIn(ctx context.Context, client, project, description string, billableRate *float64) (*TimerSession, error)
	PunchInMostRecent(ctx context.Context, description string, billableRate *float64) (*TimerSession, error)
	PunchOut(ctx context.Context) (*TimerSession, error)
	EditEntry(ctx context.Context, entry queries.TimeEntry) error

	// Client operations
	CreateClient(ctx context.Context, name, email string, billableRate *float64) (*queries.Client, error)
	EditClient(ctx context.Context, id int64, name, email string, billableRate *float64) (*queries.Client, error)
	FindClient(ctx context.Context, nameOrID string) (*queries.Client, error)

	// Project operations
	CreateProject(ctx context.Context, name, client string, billableRate *float64) (*queries.Project, error)
	EditProject(ctx context.Context, id int64, name string, billableRate *float64) (*queries.Project, error)
	FindProject(ctx context.Context, nameOrID string) (*queries.Project, error)
}

// New creates a new Actions instance
func New(q *queries.Queries) Actions {
	return &actions{queries: q}
}

// actions implements the Actions interface
type actions struct {
	queries *queries.Queries
}