mirror of
https://github.com/teamhanko/hanko.git
synced 2025-10-27 06:06:54 +08:00
34 lines
786 B
Go
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),
|
|
}
|
|
}
|