diff --git a/tpes/tpe_attributes.go b/tpes/tpe_attributes.go index a6e5d6b59..aab46e4cb 100644 --- a/tpes/tpe_attributes.go +++ b/tpes/tpe_attributes.go @@ -19,6 +19,8 @@ along with this program. If not, see package tpes import ( + "bytes" + "encoding/csv" "fmt" "github.com/cgrates/birpc/context" @@ -50,8 +52,8 @@ func (tpAttr TPAttributes) exportItems(ctx *context.Context, tnt string, itmIDs } return nil, err } - var attrMdl []interface{} - attrMdl = engine.APItoModelTPAttribute(engine.AttributeProfileToAPI(attrPrf)) + + attrMdl := engine.APItoModelTPAttribute(engine.AttributeProfileToAPI(attrPrf)) if err := writeOut(utils.AttributesCsv, attrMdl); err != nil { return nil, err } @@ -59,3 +61,20 @@ func (tpAttr TPAttributes) exportItems(ctx *context.Context, tnt string, itmIDs } return } + +func writeOut(fileName string, tpData engine.AttributeMdls) error { + buff := new(bytes.Buffer) + + csvWriter := csv.NewWriter(buff) + for _, tpItem := range tpData { + record, err := engine.CsvDump(tpItem) + if err != nil { + return err + } + if err := csvWriter.Write(record); err != nil { + return err + } + } + + return nil +} diff --git a/tpes/tpexporter.go b/tpes/tpexporter.go index 72b695a1e..9c34770a4 100644 --- a/tpes/tpexporter.go +++ b/tpes/tpexporter.go @@ -19,9 +19,6 @@ along with this program. If not, see package tpes import ( - "bytes" - "encoding/csv" - "github.com/cgrates/birpc/context" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" @@ -55,21 +52,3 @@ func newTPExporter(expType string, dm *engine.DataManager) (tpE tpExporter, err return nil, utils.ErrPrefix(utils.ErrUnsupportedTPExporterType, expType) } } - -func writeOut(fileName string, tpData []interface{}) error { - buff := new(bytes.Buffer) - - csvWriter := csv.NewWriter(buff) - for _, tpItem := range tpData { - record, err := engine.CsvDump(tpItem) - if err != nil { - return err - } - if err := csvWriter.Write(record); err != nil { - return err - } - } - - utils.Logger.Debug(buff.String()) - return nil -}