authorizer/server/db/providers/providers.go

92 lines
5.2 KiB
Go
Raw Normal View History

2022-01-21 06:48:07 +00:00
package providers
import (
2022-07-10 16:19:33 +00:00
"context"
"github.com/authorizerdev/authorizer/server/db/models"
"github.com/authorizerdev/authorizer/server/graph/model"
)
2022-01-21 06:48:07 +00:00
type Provider interface {
// AddUser to save user information in database
AddUser(ctx context.Context, user *models.User) (*models.User, error)
2022-01-21 06:48:07 +00:00
// UpdateUser to update user information in database
UpdateUser(ctx context.Context, user *models.User) (*models.User, error)
2022-01-21 06:48:07 +00:00
// DeleteUser to delete user information from database
DeleteUser(ctx context.Context, user *models.User) error
2022-01-21 06:48:07 +00:00
// ListUsers to get list of users from database
ListUsers(ctx context.Context, pagination *model.Pagination) (*model.Users, error)
2022-01-21 06:48:07 +00:00
// GetUserByEmail to get user information from database using email address
GetUserByEmail(ctx context.Context, email string) (*models.User, error)
2022-12-21 17:44:24 +00:00
// GetUserByPhoneNumber to get user information from database using phone number
GetUserByPhoneNumber(ctx context.Context, phoneNumber string) (*models.User, error)
2022-01-21 06:48:07 +00:00
// GetUserByID to get user information from database using user ID
GetUserByID(ctx context.Context, id string) (*models.User, error)
// UpdateUsers to update multiple users, with parameters of user IDs slice
// If ids set to nil / empty all the users will be updated
UpdateUsers(ctx context.Context, data map[string]interface{}, ids []string) error
2022-01-21 06:48:07 +00:00
// AddVerification to save verification request in database
AddVerificationRequest(ctx context.Context, verificationRequest *models.VerificationRequest) (*models.VerificationRequest, error)
2022-01-21 06:48:07 +00:00
// GetVerificationRequestByToken to get verification request from database using token
GetVerificationRequestByToken(ctx context.Context, token string) (*models.VerificationRequest, error)
2022-01-21 06:48:07 +00:00
// GetVerificationRequestByEmail to get verification request by email from database
GetVerificationRequestByEmail(ctx context.Context, email string, identifier string) (*models.VerificationRequest, error)
2022-01-21 06:48:07 +00:00
// ListVerificationRequests to get list of verification requests from database
ListVerificationRequests(ctx context.Context, pagination *model.Pagination) (*model.VerificationRequests, error)
2022-01-21 06:48:07 +00:00
// DeleteVerificationRequest to delete verification request from database
DeleteVerificationRequest(ctx context.Context, verificationRequest *models.VerificationRequest) error
2022-01-21 06:48:07 +00:00
// AddSession to save session information in database
AddSession(ctx context.Context, session *models.Session) error
2023-08-01 10:39:17 +00:00
// DeleteSession to delete session information from database
DeleteSession(ctx context.Context, userId string) error
2022-01-21 06:48:07 +00:00
// AddEnv to save environment information in database
AddEnv(ctx context.Context, env *models.Env) (*models.Env, error)
2022-01-21 06:48:07 +00:00
// UpdateEnv to update environment information in database
UpdateEnv(ctx context.Context, env *models.Env) (*models.Env, error)
2022-01-21 06:48:07 +00:00
// GetEnv to get environment information from database
GetEnv(ctx context.Context) (*models.Env, error)
// AddWebhook to add webhook
AddWebhook(ctx context.Context, webhook *models.Webhook) (*model.Webhook, error)
// UpdateWebhook to update webhook
UpdateWebhook(ctx context.Context, webhook *models.Webhook) (*model.Webhook, error)
// ListWebhooks to list webhook
ListWebhook(ctx context.Context, pagination *model.Pagination) (*model.Webhooks, error)
// GetWebhookByID to get webhook by id
2022-07-10 16:19:33 +00:00
GetWebhookByID(ctx context.Context, webhookID string) (*model.Webhook, error)
// GetWebhookByEventName to get webhook by event_name
GetWebhookByEventName(ctx context.Context, eventName string) ([]*model.Webhook, error)
// DeleteWebhook to delete webhook
2022-07-10 16:19:33 +00:00
DeleteWebhook(ctx context.Context, webhook *model.Webhook) error
// AddWebhookLog to add webhook log
AddWebhookLog(ctx context.Context, webhookLog *models.WebhookLog) (*model.WebhookLog, error)
// ListWebhookLogs to list webhook logs
ListWebhookLogs(ctx context.Context, pagination *model.Pagination, webhookID string) (*model.WebhookLogs, error)
2022-07-15 04:42:24 +00:00
// AddEmailTemplate to add EmailTemplate
AddEmailTemplate(ctx context.Context, emailTemplate *models.EmailTemplate) (*model.EmailTemplate, error)
2022-07-15 04:42:24 +00:00
// UpdateEmailTemplate to update EmailTemplate
UpdateEmailTemplate(ctx context.Context, emailTemplate *models.EmailTemplate) (*model.EmailTemplate, error)
2022-07-15 04:42:24 +00:00
// ListEmailTemplates to list EmailTemplate
ListEmailTemplate(ctx context.Context, pagination *model.Pagination) (*model.EmailTemplates, error)
2022-07-15 04:42:24 +00:00
// GetEmailTemplateByID to get EmailTemplate by id
GetEmailTemplateByID(ctx context.Context, emailTemplateID string) (*model.EmailTemplate, error)
// GetEmailTemplateByEventName to get EmailTemplate by event_name
GetEmailTemplateByEventName(ctx context.Context, eventName string) (*model.EmailTemplate, error)
// DeleteEmailTemplate to delete EmailTemplate
DeleteEmailTemplate(ctx context.Context, emailTemplate *model.EmailTemplate) error
// UpsertOTP to add or update otp
UpsertOTP(ctx context.Context, otp *models.OTP) (*models.OTP, error)
// GetOTPByEmail to get otp for a given email address
GetOTPByEmail(ctx context.Context, emailAddress string) (*models.OTP, error)
// GetOTPByPhoneNumber to get otp for a given phone number
GetOTPByPhoneNumber(ctx context.Context, phoneNumber string) (*models.OTP, error)
// DeleteOTP to delete otp
DeleteOTP(ctx context.Context, otp *models.OTP) error
2022-01-21 06:48:07 +00:00
}