apollo-backend/internal/domain/account.go

43 lines
1.1 KiB
Go
Raw Normal View History

2021-07-24 19:44:26 +00:00
package domain
2021-08-08 18:19:47 +00:00
import (
"context"
"strings"
)
2021-07-24 19:44:26 +00:00
// Account represents an account we need to periodically check in the notifications worker.
type Account struct {
ID int64
// Reddit information
Username string
AccountID string
AccessToken string
RefreshToken string
ExpiresAt int64
// Tracking how far behind we are
LastMessageID string
LastCheckedAt float64
}
2021-08-08 18:19:47 +00:00
func (acct *Account) NormalizedUsername() string {
return strings.ToLower(acct.Username)
}
2021-07-24 19:44:26 +00:00
// AccountRepository represents the account's repository contract
type AccountRepository interface {
GetByID(ctx context.Context, id int64) (Account, error)
GetByRedditID(ctx context.Context, id string) (Account, error)
2021-08-08 18:19:47 +00:00
GetByAPNSToken(ctx context.Context, token string) ([]Account, error)
2021-07-24 19:44:26 +00:00
2021-07-26 16:34:26 +00:00
CreateOrUpdate(ctx context.Context, acc *Account) error
2021-07-24 20:17:54 +00:00
Update(ctx context.Context, acc *Account) error
Create(ctx context.Context, acc *Account) error
2021-07-24 19:44:26 +00:00
Delete(ctx context.Context, id int64) error
2021-07-27 14:05:50 +00:00
Associate(ctx context.Context, acc *Account, dev *Device) error
2021-08-08 18:19:47 +00:00
Disassociate(ctx context.Context, acc *Account, dev *Device) error
2021-07-24 19:44:26 +00:00
2021-08-08 18:19:47 +00:00
PruneStale(ctx context.Context) (int64, error)
2021-07-24 19:44:26 +00:00
}