Some checks failed
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline is pending
ci/woodpecker/push/ledger Pipeline is pending
ci/woodpecker/push/nats Pipeline is pending
ci/woodpecker/push/notification Pipeline is pending
ci/woodpecker/push/payments_orchestrator Pipeline is pending
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/frontend Pipeline failed
ci/woodpecker/push/fx_ingestor Pipeline failed
ci/woodpecker/push/bump_version unknown status
42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package model
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/tech/sendico/pkg/merrors"
|
|
)
|
|
|
|
// DemoRequest represents a request submitted from the marketing site to request a demo.
|
|
type DemoRequest struct {
|
|
Name string `json:"name"`
|
|
OrganizationName string `json:"organizationName"`
|
|
Phone string `json:"phone"`
|
|
WorkEmail string `json:"workEmail"`
|
|
PayoutVolume string `json:"payoutVolume"`
|
|
Comment string `json:"comment,omitempty"`
|
|
}
|
|
|
|
// Normalize trims whitespace from all string fields.
|
|
func (dr *DemoRequest) Normalize() {
|
|
if dr == nil {
|
|
return
|
|
}
|
|
dr.Name = strings.TrimSpace(dr.Name)
|
|
dr.OrganizationName = strings.TrimSpace(dr.OrganizationName)
|
|
dr.Phone = strings.TrimSpace(dr.Phone)
|
|
dr.WorkEmail = strings.TrimSpace(dr.WorkEmail)
|
|
dr.PayoutVolume = strings.TrimSpace(dr.PayoutVolume)
|
|
dr.Comment = strings.TrimSpace(dr.Comment)
|
|
}
|
|
|
|
// Validate ensures that all required fields are present.
|
|
func (dr *DemoRequest) Validate() error {
|
|
if dr == nil {
|
|
return merrors.InvalidArgument("request payload is empty", "request")
|
|
}
|
|
if (dr.WorkEmail == "") && (dr.Phone == "") {
|
|
return merrors.InvalidArgument("work email or phone must not be empty", "request.workEmail", "request.phone")
|
|
}
|
|
return nil
|
|
}
|