39 lines
839 B
Go
39 lines
839 B
Go
|
|
package brandkit
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"encoding/json"
|
||
|
|
"errors"
|
||
|
|
"time"
|
||
|
|
)
|
||
|
|
|
||
|
|
var (
|
||
|
|
ErrInvalidInput = errors.New("invalid brand kit")
|
||
|
|
ErrNotFound = errors.New("brand kit not found")
|
||
|
|
ErrConflict = errors.New("brand kit conflict")
|
||
|
|
)
|
||
|
|
|
||
|
|
type Kit struct {
|
||
|
|
ID string
|
||
|
|
UserID string
|
||
|
|
Name string
|
||
|
|
Document json.RawMessage
|
||
|
|
IsDefault bool
|
||
|
|
CreatedAt time.Time
|
||
|
|
UpdatedAt time.Time
|
||
|
|
}
|
||
|
|
|
||
|
|
type Store interface {
|
||
|
|
List(ctx context.Context, userID string) ([]Kit, error)
|
||
|
|
Get(ctx context.Context, userID string, id string) (Kit, error)
|
||
|
|
GetDefault(ctx context.Context, userID string) (Kit, error)
|
||
|
|
Upsert(ctx context.Context, kit Kit) (Kit, error)
|
||
|
|
Delete(ctx context.Context, userID string, id string) error
|
||
|
|
Close() error
|
||
|
|
}
|
||
|
|
|
||
|
|
func Clone(kit Kit) Kit {
|
||
|
|
kit.Document = append(json.RawMessage(nil), kit.Document...)
|
||
|
|
return kit
|
||
|
|
}
|