all CRM remarshal

v0.1.12 v0.1.12
Vernon Keenan 2021-01-18 11:31:41 -08:00
parent bc3e3a61e5
commit cda4c20de9
3 changed files with 38 additions and 12 deletions

View File

@ -2,12 +2,25 @@ package app
import ( import (
"database/sql" "database/sql"
"reflect"
"time" "time"
"code.tnxs.net/taxnexus/lib/api/crm/crm_models" "code.tnxs.net/taxnexus/lib/api/crm/crm_models"
"github.com/google/uuid" "github.com/google/uuid"
) )
// ReMarshalCompany converts microservice Models object to swagger
func ReMarshalCompany(p interface{}) crm_models.Company {
// reflect input and set to crm_models type
t := reflect.ValueOf(&p).Elem()
s := crm_models.Company{}
r := reflect.ValueOf(&s).Elem()
for i := 0; i < t.NumField(); i++ {
r.Field(i).Set(t.Field(i))
}
return s
}
// UnMarshalCompany decodes swagger to first class object // UnMarshalCompany decodes swagger to first class object
func UnMarshalCompany(s *crm_models.Company) *Company { func UnMarshalCompany(s *crm_models.Company) *Company {
if s.ID == "" { if s.ID == "" {

View File

@ -9,6 +9,18 @@ import (
"github.com/google/uuid" "github.com/google/uuid"
) )
// ReMarshalContact converts microservice Models object to swagger
func ReMarshalContact(p interface{}) crm_models.Contact {
// reflect input and set to crm_models type
t := reflect.ValueOf(&p).Elem()
s := crm_models.Contact{}
r := reflect.ValueOf(&s).Elem()
for i := 0; i < t.NumField(); i++ {
r.Field(i).Set(t.Field(i))
}
return s
}
// UnMarshalContact decodes swagger to first class object // UnMarshalContact decodes swagger to first class object
func UnMarshalContact(s *crm_models.Contact) *Contact { func UnMarshalContact(s *crm_models.Contact) *Contact {
if s.ID == "" { if s.ID == "" {
@ -78,18 +90,6 @@ func UnMarshalContact(s *crm_models.Contact) *Contact {
} }
} }
// ReMarshalContact converts microservice Models object to swagger
func ReMarshalContact(p interface{}) crm_models.Contact {
// reflect input and set to crm_models type
t := reflect.ValueOf(&p).Elem()
s := crm_models.Contact{}
r := reflect.ValueOf(&s).Elem()
for i := 0; i < t.NumField(); i++ {
r.Field(i).Set(t.Field(i))
}
return s
}
// MarshalToSwagger encodes first class object // MarshalToSwagger encodes first class object
func (obj *Contact) MarshalToSwagger() *crm_models.Contact { func (obj *Contact) MarshalToSwagger() *crm_models.Contact {
return &crm_models.Contact{ return &crm_models.Contact{

View File

@ -2,12 +2,25 @@ package app
import ( import (
"database/sql" "database/sql"
"reflect"
"time" "time"
"code.tnxs.net/taxnexus/lib/api/crm/crm_models" "code.tnxs.net/taxnexus/lib/api/crm/crm_models"
"github.com/google/uuid" "github.com/google/uuid"
) )
// ReMarshalLead converts microservice Models object to swagger
func ReMarshalLead(p interface{}) crm_models.Lead {
// reflect input and set to crm_models type
t := reflect.ValueOf(&p).Elem()
s := crm_models.Lead{}
r := reflect.ValueOf(&s).Elem()
for i := 0; i < t.NumField(); i++ {
r.Field(i).Set(t.Field(i))
}
return s
}
// UnMarshalLead decodes swagger to first class object // UnMarshalLead decodes swagger to first class object
func UnMarshalLead(s *crm_models.Lead) *Lead { func UnMarshalLead(s *crm_models.Lead) *Lead {
if s.ID == "" { if s.ID == "" {