tsk-19: Update status of scheduled message endpoint (#32)
Closes #19 Reviewed-on: phoenix/textsender-api#32 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
type ScheduledMessageStore interface {
|
||||
Get(ctx context.Context, id uuid.UUID) (*scheduling.ScheduledMessage, error)
|
||||
CreateScheduledMessage(ctx context.Context, schedMsg *scheduling.ScheduledMessage) error
|
||||
UpdateStatus(ctx context.Context, id uuid.UUID, updatedStatus string) (*string, error)
|
||||
}
|
||||
|
||||
type PGScheduledMessageStore struct {
|
||||
@@ -54,3 +55,18 @@ func (s *PGScheduledMessageStore) CreateScheduledMessage(ctx context.Context, sc
|
||||
&schedMsg.Id, &schedMsg.Created,
|
||||
)
|
||||
}
|
||||
|
||||
func (s *PGScheduledMessageStore) UpdateStatus(ctx context.Context, id uuid.UUID, updatedStatus string) (*string, error) {
|
||||
query := `
|
||||
UPDATE scheduled_messages set status = $1 WHERE id = $2
|
||||
RETURNING status
|
||||
`
|
||||
|
||||
var returnedStatus string
|
||||
|
||||
if err := s.db.QueryRow(ctx, query, updatedStatus, id).Scan(&returnedStatus); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return &returnedStatus, nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user