File size: 1,669 Bytes
83a59ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
package repositories

import (
	"context"

	"github.com/google/uuid"

	"github.com/NdoleStudio/httpsms/pkg/entities"
)

// PhoneAPIKeyRepository loads and persists an entities.PhoneAPIKey
type PhoneAPIKeyRepository interface {
	// Create a new entities.PhoneAPIKey
	Create(ctx context.Context, phone *entities.PhoneAPIKey) error

	// Load an entities.PhoneAPIKey by userID and phoneAPIKeyID
	Load(ctx context.Context, userID entities.UserID, phoneAPIKeyID uuid.UUID) (*entities.PhoneAPIKey, error)

	// LoadAuthContext fetches an entities.AuthContext by apiKey
	LoadAuthContext(ctx context.Context, apiKey string) (entities.AuthContext, error)

	// Index entities.PhoneAPIKey of a user
	Index(ctx context.Context, userID entities.UserID, params IndexParams) ([]*entities.PhoneAPIKey, error)

	// Delete an entities.PhoneAPIKey
	Delete(ctx context.Context, phoneAPIKey *entities.PhoneAPIKey) error

	// AddPhone adds an entities.Phone to an entities.PhoneAPIKey
	AddPhone(ctx context.Context, phoneAPIKey *entities.PhoneAPIKey, phone *entities.Phone) error

	// RemovePhone removes an entities.Phone to an entities.PhoneAPIKey
	RemovePhone(ctx context.Context, phoneAPIKey *entities.PhoneAPIKey, phone *entities.Phone) error

	// CountByUser returns the number of phone API keys owned by a user
	CountByUser(ctx context.Context, userID entities.UserID) (int, error)

	// DeleteAllForUser deletes all entities.PhoneAPIKey for a user
	DeleteAllForUser(ctx context.Context, userID entities.UserID) error

	// RemovePhoneByID removes a phone by ID and phone number
	RemovePhoneByID(ctx context.Context, userID entities.UserID, phoneID uuid.UUID, phoneNumber string) error
}