Skip to content

Commit 0647c6e

Browse files
committed
add customer type
1 parent c5d8907 commit 0647c6e

1 file changed

Lines changed: 38 additions & 21 deletions

File tree

dto.go

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -383,27 +383,44 @@ type History struct {
383383
}
384384

385385
type Customer struct {
386-
ID string `json:"id,omitempty"` // Unique customer identifier
387-
Title string `json:"title,omitempty"` // Something like Ms or Mrs
388-
FirstName string `json:"firstName,omitempty"` // The first name of the customer.
389-
LastName string `json:"lastName,omitempty"` // The last name of the customer.
390-
Street string `json:"street,omitempty"` // The street of the customer.
391-
Street2 string `json:"street2,omitempty"` // Additional street information. For example: '3rd floor'
392-
City string `json:"city,omitempty"` // The city of the customer.
393-
Country string `json:"country,omitempty"` // 2 letter ISO 3166-1 alpha-2 country code
394-
ZipCode string `json:"zipCode,omitempty"` // Zip code of the customer.
395-
Phone string `json:"phone,omitempty"` // Phone number of the customer.
396-
CellPhone string `json:"cellPhone,omitempty"` // Cell Phone number of the customer.
397-
Email string `json:"email,omitempty"` // The email address of the customer.
398-
Gender string `json:"gender,omitempty"` // Gender of the customer. female or male.
399-
BirthDate string `json:"birthDate,omitempty"` // The birth date of the customer. Must be in ISO-8601 format (YYYY-MM-DD).
400-
Language string `json:"language,omitempty"` // The language of the customer.
401-
Type string `json:"type,omitempty"` // P or C depending on whether the customer is private or a company. If C, the fields name and companyRegisterNumber are required
402-
Name string `json:"name,omitempty"` // The name of the company. Only applicable if type=C
403-
CompanyLegalForm string `json:"companyLegalForm,omitempty"` // The legal form of the company (AG, GmbH, ...)
404-
CompanyRegisterNumber string `json:"companyRegisterNumber,omitempty"` // The register number of the company. Only applicable if type=C
405-
IpAddress string `json:"ipAddress,omitempty"` // The ip address of the customer.
406-
}
386+
ID string `json:"id,omitempty"` // Unique customer identifier
387+
Title string `json:"title,omitempty"` // Something like Ms or Mrs
388+
FirstName string `json:"firstName,omitempty"` // The first name of the customer.
389+
LastName string `json:"lastName,omitempty"` // The last name of the customer.
390+
Street string `json:"street,omitempty"` // The street of the customer.
391+
Street2 string `json:"street2,omitempty"` // Additional street information. For example: '3rd floor'
392+
City string `json:"city,omitempty"` // The city of the customer.
393+
Country string `json:"country,omitempty"` // 2 letter ISO 3166-1 alpha-2 country code
394+
ZipCode string `json:"zipCode,omitempty"` // Zip code of the customer.
395+
Phone string `json:"phone,omitempty"` // Phone number of the customer.
396+
CellPhone string `json:"cellPhone,omitempty"` // Cell Phone number of the customer.
397+
Email string `json:"email,omitempty"` // The email address of the customer.
398+
Gender string `json:"gender,omitempty"` // Gender of the customer. female or male.
399+
BirthDate string `json:"birthDate,omitempty"` // The birth date of the customer. Must be in ISO-8601 format (YYYY-MM-DD).
400+
Language string `json:"language,omitempty"` // The language of the customer.
401+
Type CustomerType `json:"type,omitempty"` // P or C depending on whether the customer is private or a company. If C, the fields name and companyRegisterNumber are required
402+
Name string `json:"name,omitempty"` // The name of the company. Only applicable if type=C
403+
CompanyLegalForm string `json:"companyLegalForm,omitempty"` // The legal form of the company (AG, GmbH, ...)
404+
CompanyRegisterNumber string `json:"companyRegisterNumber,omitempty"` // The register number of the company. Only applicable if type=C
405+
IpAddress string `json:"ipAddress,omitempty"` // The ip address of the customer.
406+
}
407+
408+
func (c *Customer) SetType() {
409+
if c == nil {
410+
return
411+
}
412+
c.Type = CustomerTypePrivate
413+
if c.Name != "" || c.CompanyRegisterNumber != "" || c.CompanyLegalForm != "" {
414+
c.Type = CustomerTypeCompany
415+
}
416+
}
417+
418+
type CustomerType string
419+
420+
const (
421+
CustomerTypePrivate CustomerType = "P"
422+
CustomerTypeCompany CustomerType = "C"
423+
)
407424

408425
type Theme struct {
409426
// Theme configuration options when using the default DT2015 theme

0 commit comments

Comments
 (0)