+notification from site +version bump fix
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/fx_oracle Pipeline was successful
ci/woodpecker/push/bump_version Pipeline failed
ci/woodpecker/push/frontend 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
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/fx_oracle Pipeline was successful
ci/woodpecker/push/bump_version Pipeline failed
ci/woodpecker/push/frontend 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
This commit is contained in:
53
api/pkg/model/demorequest.go
Normal file
53
api/pkg/model/demorequest.go
Normal file
@@ -0,0 +1,53 @@
|
||||
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")
|
||||
}
|
||||
if dr.Name == "" {
|
||||
return merrors.InvalidArgument("name must not be empty")
|
||||
}
|
||||
if dr.OrganizationName == "" {
|
||||
return merrors.InvalidArgument("organization name must not be empty")
|
||||
}
|
||||
if dr.Phone == "" {
|
||||
return merrors.InvalidArgument("phone must not be empty")
|
||||
}
|
||||
if dr.WorkEmail == "" {
|
||||
return merrors.InvalidArgument("work email must not be empty")
|
||||
}
|
||||
if dr.PayoutVolume == "" {
|
||||
return merrors.InvalidArgument("payout volume must not be empty")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
31
api/pkg/model/demorequest_test.go
Normal file
31
api/pkg/model/demorequest_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package model
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestDemoRequestNormalizeAndValidate(t *testing.T) {
|
||||
req := &DemoRequest{
|
||||
Name: " Alice ",
|
||||
OrganizationName: " Sendico ",
|
||||
Phone: " +1 234 ",
|
||||
WorkEmail: " demo@sendico.io ",
|
||||
PayoutVolume: " 100k ",
|
||||
Comment: " Excited ",
|
||||
}
|
||||
|
||||
req.Normalize()
|
||||
if err := req.Validate(); err != nil {
|
||||
t.Fatalf("expected request to be valid, got error: %v", err)
|
||||
}
|
||||
|
||||
if req.Name != "Alice" || req.OrganizationName != "Sendico" || req.Phone != "+1 234" || req.WorkEmail != "demo@sendico.io" || req.PayoutVolume != "100k" || req.Comment != "Excited" {
|
||||
t.Fatalf("normalize failed: %+v", req)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDemoRequestValidateMissing(t *testing.T) {
|
||||
req := &DemoRequest{}
|
||||
req.Normalize()
|
||||
if err := req.Validate(); err == nil {
|
||||
t.Fatalf("expected validation error for empty request")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user