Files
hanko/backend/dto/email.go
lfleischmann eec7a473a5 feat: add third party integrations
add third party integrations
2023-02-23 13:05:05 +01:00

34 lines
786 B
Go

package dto
import (
"github.com/gofrs/uuid"
"github.com/teamhanko/hanko/backend/persistence/models"
)
type EmailResponse struct {
ID uuid.UUID `json:"id"`
Address string `json:"address"`
IsVerified bool `json:"is_verified"`
IsPrimary bool `json:"is_primary"`
Identity *Identity `json:"identity"`
}
type EmailCreateRequest struct {
Address string `json:"address"`
}
type EmailUpdateRequest struct {
IsPrimary *bool `json:"is_primary"`
}
// FromEmailModel Converts the DB model to a DTO object
func FromEmailModel(email *models.Email) *EmailResponse {
return &EmailResponse{
ID: email.ID,
Address: email.Address,
IsVerified: email.Verified,
IsPrimary: email.IsPrimary(),
Identity: FromIdentityModel(email.Identity),
}
}