Some checks failed
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
ci/woodpecker/push/bump_version Pipeline failed
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package model
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/tech/sendico/pkg/merrors"
|
|
)
|
|
|
|
// CallRequest represents a request to schedule a call from the marketing site.
|
|
type CallRequest struct {
|
|
Name string `json:"name"`
|
|
Phone string `json:"phone"`
|
|
Email string `json:"email"`
|
|
Company string `json:"company"`
|
|
PreferredTime string `json:"preferredTime"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
// Normalize trims whitespace from all string fields.
|
|
func (cr *CallRequest) Normalize() {
|
|
if cr == nil {
|
|
return
|
|
}
|
|
cr.Name = strings.TrimSpace(cr.Name)
|
|
cr.Phone = strings.TrimSpace(cr.Phone)
|
|
cr.Email = strings.TrimSpace(cr.Email)
|
|
cr.Company = strings.TrimSpace(cr.Company)
|
|
cr.PreferredTime = strings.TrimSpace(cr.PreferredTime)
|
|
cr.Message = strings.TrimSpace(cr.Message)
|
|
}
|
|
|
|
// Validate ensures required call request fields are present.
|
|
func (cr *CallRequest) Validate() error {
|
|
if cr == nil {
|
|
return merrors.InvalidArgument("request payload is empty", "request")
|
|
}
|
|
if cr.Phone == "" && cr.Email == "" {
|
|
return merrors.InvalidArgument("phone or email must not be empty", "request.phone", "request.email")
|
|
}
|
|
return nil
|
|
}
|