diff --git a/app/company-helpers.go b/app/company-helpers.go index bb5c21b..f32ed17 100644 --- a/app/company-helpers.go +++ b/app/company-helpers.go @@ -2,12 +2,25 @@ package app import ( "database/sql" + "reflect" "time" "code.tnxs.net/taxnexus/lib/api/crm/crm_models" "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 func UnMarshalCompany(s *crm_models.Company) *Company { if s.ID == "" { diff --git a/app/contact-helpers.go b/app/contact-helpers.go index afa42f2..bc62772 100644 --- a/app/contact-helpers.go +++ b/app/contact-helpers.go @@ -9,6 +9,18 @@ import ( "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 func UnMarshalContact(s *crm_models.Contact) *Contact { 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 func (obj *Contact) MarshalToSwagger() *crm_models.Contact { return &crm_models.Contact{ diff --git a/app/lead-helpers.go b/app/lead-helpers.go index 8ac9831..dbed061 100644 --- a/app/lead-helpers.go +++ b/app/lead-helpers.go @@ -2,12 +2,25 @@ package app import ( "database/sql" + "reflect" "time" "code.tnxs.net/taxnexus/lib/api/crm/crm_models" "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 func UnMarshalLead(s *crm_models.Lead) *Lead { if s.ID == "" {