-
Notifications
You must be signed in to change notification settings - Fork 0
/
workspace.go
59 lines (47 loc) · 1.69 KB
/
workspace.go
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package malak
import (
"context"
"time"
"github.com/google/uuid"
)
var ErrWorkspaceNotFound = MalakError("workspace not found")
type Workspace struct {
ID uuid.UUID `bun:"type:uuid,default:uuid_generate_v4(),pk" json:"id,omitempty"`
WorkspaceName string `json:"workspace_name,omitempty"`
PlanID uuid.UUID `json:"plan_id,omitempty"`
Reference string `json:"reference,omitempty"`
// Not required
// Dummy values work really
StripeCustomerID string `json:"stripe_customer_id,omitempty"`
SubscriptionID string `json:"subscription_id,omitempty"`
Metadata PlanMetadata `json:"metadata,omitempty"`
CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp" json:"created_at,omitempty" bson:"created_at"`
UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp" json:"updated_at,omitempty" bson:"updated_at"`
DeletedAt *time.Time `bun:",soft_delete,nullzero" json:"-,omitempty" bson:"deleted_at"`
}
func NewWorkspace(name string, u *User,
plan *Plan, reference string) *Workspace {
return &Workspace{
WorkspaceName: name,
Reference: reference,
Metadata: plan.Metadata,
PlanID: plan.ID,
}
}
type FindWorkspaceOptions struct {
StripeCustomerID string
ID uuid.UUID
Reference Reference
}
type CreateWorkspaceOptions struct {
User *User
Workspace *Workspace
}
type WorkspaceRepository interface {
Create(context.Context, *CreateWorkspaceOptions) error
Get(context.Context, *FindWorkspaceOptions) (*Workspace, error)
Update(context.Context, *Workspace) error
List(context.Context, *User) ([]Workspace, error)
// MarkInActive(context.Context, *Workspace) error
// MarkActive(context.Context, *Workspace) error
}