lib/app/address.go

99 lines
2.1 KiB
Go
Raw Normal View History

2021-01-10 23:44:39 +00:00
package app
2021-01-14 06:36:35 +00:00
import (
2021-01-27 23:11:19 +00:00
"encoding/json"
2021-01-14 06:36:35 +00:00
"code.tnxs.net/taxnexus/lib/api/crm/crm_models"
"code.tnxs.net/taxnexus/lib/api/ops/ops_models"
)
2021-01-10 23:44:39 +00:00
// Address address struct
type Address struct {
City string
Country string
CountryCode string
PostalCode string
State string
StateCode string
Street string
}
2021-01-14 06:36:35 +00:00
2021-01-27 23:11:19 +00:00
// ToString returns the full address in a string
func (obj *Address) ToString() string {
return obj.Street + " " +
obj.City + " " +
obj.State + " " +
obj.PostalCode
}
// MarshalToJSON returns a JSON string representation of the address
func (obj *Address) MarshalToJSON() *string {
bytes, _ := json.Marshal(obj)
str := string(bytes)
return &str
}
2021-01-14 06:36:35 +00:00
// MarshalToCrm converts a first class object to swagger
func (obj *Address) MarshalToCrm() *crm_models.Address {
if obj == nil {
return nil
}
return &crm_models.Address{
City: obj.City,
Country: obj.Country,
CountryCode: obj.CountryCode,
PostalCode: obj.PostalCode,
State: obj.State,
StateCode: obj.StateCode,
Street: obj.Street,
}
}
// MarshalToOps converts a first class object to swagger
func (obj *Address) MarshalToOps() *ops_models.Address {
if obj == nil {
return nil
}
return &ops_models.Address{
City: obj.City,
Country: obj.Country,
CountryCode: obj.CountryCode,
PostalCode: obj.PostalCode,
State: obj.State,
StateCode: obj.StateCode,
Street: obj.Street,
}
}
// UnMarshalCrmAddress converts a first class object to swagger
func UnMarshalCrmAddress(s *crm_models.Address) *Address {
if s == nil {
return nil
}
return &Address{
City: s.City,
Country: s.Country,
CountryCode: s.CountryCode,
PostalCode: s.PostalCode,
State: s.State,
StateCode: s.StateCode,
Street: s.Street,
}
}
// UnMarshalOpsAddress converts a first class object to swagger
func UnMarshalOpsAddress(s *ops_models.Address) *Address {
if s == nil {
return nil
}
return &Address{
City: s.City,
Country: s.Country,
CountryCode: s.CountryCode,
PostalCode: s.PostalCode,
State: s.State,
StateCode: s.StateCode,
Street: s.Street,
}
}