857e911d40
- Introduced a new inquiry management feature, including CRUD operations for inquiries in both admin and public API endpoints. - Implemented inquiry entity, service, repository, and handler layers following the clean architecture principles. - Added new API routes for searching, retrieving, updating, and deleting inquiries, enhancing the overall functionality of the system. - Updated Swagger documentation to include detailed descriptions and examples for the new inquiry endpoints, ensuring clarity for API consumers. - Enhanced error handling for duplicate inquiries and validation, improving the robustness of the inquiry management process. - Updated existing routes to integrate inquiry handling, ensuring a seamless user experience across the application.
44 lines
1.6 KiB
Go
44 lines
1.6 KiB
Go
package inquiry
|
|
|
|
import "errors"
|
|
|
|
// Inquiry-specific errors
|
|
var (
|
|
ErrDuplicateInquiryByEmail = errors.New("duplicate inquiry by email")
|
|
ErrDuplicateInquiryByPhone = errors.New("duplicate inquiry by phone")
|
|
ErrInquiryNotFound = errors.New("inquiry not found")
|
|
ErrInvalidStatusTransition = errors.New("invalid status transition")
|
|
ErrInquiryAlreadyProcessed = errors.New("inquiry already processed")
|
|
)
|
|
|
|
// DuplicateInquiryError represents a duplicate inquiry error with details
|
|
type DuplicateInquiryError struct {
|
|
Type string `json:"type"` // "email" or "phone"
|
|
ExistingID string `json:"existing_id"` // ID of existing inquiry
|
|
Status string `json:"status"` // Status of existing inquiry
|
|
CreatedAt int64 `json:"created_at"` // When existing inquiry was created
|
|
Message string `json:"message"` // User-friendly message
|
|
}
|
|
|
|
func (e *DuplicateInquiryError) Error() string {
|
|
return e.Message
|
|
}
|
|
|
|
// NewDuplicateInquiryError creates a new duplicate inquiry error
|
|
func NewDuplicateInquiryError(inquiryType, existingID, status string, createdAt int64) *DuplicateInquiryError {
|
|
var message string
|
|
if inquiryType == "email" {
|
|
message = "You already have a pending inquiry with this email address. Please wait for it to be processed before submitting a new one."
|
|
} else {
|
|
message = "A pending inquiry already exists with this phone number. Please wait for it to be processed before submitting a new one."
|
|
}
|
|
|
|
return &DuplicateInquiryError{
|
|
Type: inquiryType,
|
|
ExistingID: existingID,
|
|
Status: status,
|
|
CreatedAt: createdAt,
|
|
Message: message,
|
|
}
|
|
}
|