chore(repo): reinitialize repository
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package humantask
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Status string
|
||||
|
||||
const (
|
||||
StatusPending Status = "pending"
|
||||
StatusAnswered Status = "answered"
|
||||
StatusCancelled Status = "cancelled"
|
||||
)
|
||||
|
||||
type Record struct {
|
||||
ID string `json:"id"`
|
||||
WorkspaceID string `json:"workspace_id"`
|
||||
TopicID string `json:"topic_id"`
|
||||
RoleName string `json:"role_name"`
|
||||
PromptMessageID string `json:"prompt_message_id"`
|
||||
Status Status `json:"status"`
|
||||
AnsweredMessageID string `json:"answered_message_id,omitempty"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (r Record) Validate() error {
|
||||
if r.WorkspaceID == "" {
|
||||
return fmt.Errorf("workspace id is required")
|
||||
}
|
||||
if r.TopicID == "" {
|
||||
return fmt.Errorf("topic id is required")
|
||||
}
|
||||
if r.RoleName == "" {
|
||||
return fmt.Errorf("role name is required")
|
||||
}
|
||||
if r.PromptMessageID == "" {
|
||||
return fmt.Errorf("prompt message id is required")
|
||||
}
|
||||
switch r.Status {
|
||||
case StatusPending, StatusAnswered, StatusCancelled:
|
||||
default:
|
||||
return fmt.Errorf("invalid human task status %q", r.Status)
|
||||
}
|
||||
if r.Status == StatusAnswered && r.AnsweredMessageID == "" {
|
||||
return fmt.Errorf("answered message id is required")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user