34064e8b36
- Changed the query parameter name from `search` to `q` in both SearchCustomersForm and ListUsersForm for consistency across API endpoints. - This update enhances clarity in the API's query structure, aligning with common practices for search parameters.
81 lines
3.5 KiB
Go
81 lines
3.5 KiB
Go
package customer
|
|
|
|
import "tm/pkg/response"
|
|
|
|
// CreateCustomerForm represents the form for creating a new customer
|
|
type CreateCustomerForm struct {
|
|
FullName *string `json:"full_name,omitempty" valid:"optional,length(2|100)" example:"User"`
|
|
Type string `json:"type" valid:"required,in(individual|company|government)" example:"individual"`
|
|
CompanyIDs []string `json:"company_ids,omitempty" valid:"optional"`
|
|
Username string `json:"username" valid:"required,alphanum,length(3|30)" example:"user"`
|
|
Email string `json:"email" valid:"required,email" example:"user@opplens.com"`
|
|
Password string `json:"password" valid:"required,length(8|128)" example:"User!1234"`
|
|
Phone *string `json:"phone,omitempty" valid:"optional,length(10|20)" example:"+1234567890"`
|
|
}
|
|
|
|
// UpdateCustomerForm represents the form for updating a customer
|
|
type UpdateCustomerForm struct {
|
|
FullName *string `json:"full_name,omitempty" valid:"optional,length(2|100)" example:"User"`
|
|
Type string `json:"type" valid:"required,in(individual|company|government)" example:"individual"`
|
|
CompanyIDs []string `json:"company_ids,omitempty" valid:"optional"`
|
|
Username string `json:"username" valid:"required,alphanum,length(3|30)" example:"user"`
|
|
Email string `json:"email" valid:"required,email" example:"user@opplens.com"`
|
|
Password string `json:"password" valid:"required,length(8|128)" example:"User!1234"`
|
|
Phone *string `json:"phone,omitempty" valid:"optional,length(10|20)" example:"+1234567890"`
|
|
}
|
|
|
|
// CustomerStatusForm represents the form for suspending a customer
|
|
type UpdateStatusForm struct {
|
|
Status string `json:"status" valid:"required,in(active|inactive|suspended)" example:"active"`
|
|
Reason string `json:"reason" valid:"required,length(10|500)" example:"Customer is active"`
|
|
}
|
|
|
|
// ListCustomersForm represents the form for listing customers with filters
|
|
type SearchCustomersForm struct {
|
|
Search *string `query:"q" valid:"optional"`
|
|
Type *string `query:"type" valid:"optional,in(individual|company|government)"`
|
|
Status *string `query:"status" valid:"optional,in(active|inactive|suspended)"`
|
|
CompanyID *string `query:"company_id" valid:"optional"`
|
|
}
|
|
|
|
// CustomerListResponse represents the response for listing customers
|
|
type CustomerListResponse struct {
|
|
Customers []*CustomerResponse `json:"customers"`
|
|
Meta *response.Meta `json:"meta"`
|
|
}
|
|
|
|
type LoginForm struct {
|
|
Username string `json:"username" valid:"required" example:"app"`
|
|
Password string `json:"password" valid:"required" example:"App!1234"`
|
|
}
|
|
|
|
type RefreshTokenForm struct {
|
|
RefreshToken string `json:"refresh_token" valid:"required"`
|
|
}
|
|
|
|
type ChangePasswordForm struct {
|
|
OldPassword string `json:"old_password" valid:"required"`
|
|
NewPassword string `json:"new_password" valid:"required,length(8|128)"`
|
|
}
|
|
|
|
type UpdateProfileForm struct {
|
|
FullName *string `json:"full_name,omitempty" valid:"optional,length(2|100)"`
|
|
Username *string `json:"username,omitempty" valid:"optional,alphanum,length(3|30)"`
|
|
Phone *string `json:"phone,omitempty" valid:"optional,length(10|20)"`
|
|
}
|
|
|
|
type AuthResponse struct {
|
|
Customer *CustomerResponse `json:"customer"`
|
|
AccessToken string `json:"access_token"`
|
|
RefreshToken string `json:"refresh_token"`
|
|
ExpiresAt int64 `json:"expires_at"`
|
|
}
|
|
|
|
type AssignCompaniesForm struct {
|
|
CompanyIDs []string `json:"company_ids" valid:"required"`
|
|
}
|
|
|
|
type RemoveCompaniesForm struct {
|
|
CompanyIDs []string `json:"company_ids" valid:"required"`
|
|
}
|