112 lines
3.0 KiB
Go
112 lines
3.0 KiB
Go
package response
|
|
|
|
import (
|
|
"enaklo-pos-be/internal/entity"
|
|
"time"
|
|
)
|
|
|
|
type MemberRegistrationResponse struct {
|
|
Token string `json:"token"`
|
|
Status string `json:"status"`
|
|
ExpiresAt time.Time `json:"expires_at"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
type MemberVerificationResponse struct {
|
|
CustomerID int64 `json:"customer_id"`
|
|
Name string `json:"name"`
|
|
Email string `json:"email"`
|
|
Phone string `json:"phone"`
|
|
Points int `json:"points"`
|
|
Status string `json:"status"`
|
|
}
|
|
|
|
type MemberRegistrationStatus struct {
|
|
Token string `json:"token"`
|
|
Status string `json:"status"`
|
|
ExpiresAt time.Time `json:"expires_at"`
|
|
IsExpired bool `json:"is_expired"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type ResendOTPResponse struct {
|
|
Token string `json:"token"`
|
|
ExpiresAt time.Time `json:"expires_at"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
type CustomerCheckResponse struct {
|
|
Exists bool `json:"exists"`
|
|
Customer *CustomerResponse `json:"customer,omitempty"`
|
|
Message string `json:"message,omitempty"`
|
|
}
|
|
|
|
type CustomerResponse struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Email string `json:"email"`
|
|
Phone string `json:"phone"`
|
|
BirthDate string `json:"birth_date,omitempty"`
|
|
Points int `json:"points"`
|
|
CreatedAt string `json:"created_at"`
|
|
CustomerID string `json:"customer_id"`
|
|
}
|
|
|
|
func MapToMemberRegistrationResponse(entity *entity.MemberRegistrationResponse) MemberRegistrationResponse {
|
|
return MemberRegistrationResponse{
|
|
Token: entity.Token,
|
|
Status: entity.Status,
|
|
ExpiresAt: entity.ExpiresAt,
|
|
Message: entity.Message,
|
|
}
|
|
}
|
|
|
|
func MapToMemberVerificationResponse(entity *entity.MemberVerificationResponse) MemberVerificationResponse {
|
|
return MemberVerificationResponse{
|
|
CustomerID: entity.CustomerID,
|
|
Name: entity.Name,
|
|
Email: entity.Email,
|
|
Phone: entity.Phone,
|
|
Points: entity.Points,
|
|
Status: entity.Status,
|
|
}
|
|
}
|
|
|
|
func MapToMemberRegistrationStatus(entity *entity.MemberRegistrationStatus) MemberRegistrationStatus {
|
|
return MemberRegistrationStatus{
|
|
Token: entity.Token,
|
|
Status: entity.Status,
|
|
ExpiresAt: entity.ExpiresAt,
|
|
IsExpired: entity.IsExpired,
|
|
CreatedAt: entity.CreatedAt,
|
|
}
|
|
}
|
|
|
|
func MapToResendOTPResponse(entity *entity.ResendOTPResponse) ResendOTPResponse {
|
|
return ResendOTPResponse{
|
|
Token: entity.Token,
|
|
ExpiresAt: entity.ExpiresAt,
|
|
Message: entity.Message,
|
|
}
|
|
}
|
|
|
|
func MapToCustomerCheckResponse(entity *entity.CustomerCheckResponse) CustomerCheckResponse {
|
|
response := CustomerCheckResponse{
|
|
Exists: entity.Exists,
|
|
Message: entity.Message,
|
|
}
|
|
|
|
if entity.Customer != nil {
|
|
customer := &CustomerResponse{
|
|
ID: entity.Customer.ID,
|
|
Name: entity.Customer.Name,
|
|
Email: entity.Customer.Email,
|
|
Phone: entity.Customer.Phone,
|
|
CreatedAt: entity.Customer.CreatedAt.Format("2006-01-02"),
|
|
}
|
|
response.Customer = customer
|
|
}
|
|
|
|
return response
|
|
}
|