diff --git a/config/fctemplate.go b/config/fctemplate.go
new file mode 100755
index 000000000..8418d6e82
--- /dev/null
+++ b/config/fctemplate.go
@@ -0,0 +1,62 @@
+/*
+Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
+Copyright (C) ITsysCOM GmbH
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see
+*/
+
+package config
+
+import (
+ "github.com/cgrates/cgrates/utils"
+)
+
+func NewFCTemplateFromFCTemplateJsonCfg(jsnCfg *FcTemplateJsonCfg) *FCTemplate {
+ fcTmp := new(FCTemplate)
+ if jsnCfg.Id != nil {
+ fcTmp.ID = *jsnCfg.Id
+ }
+ if jsnCfg.Type != nil {
+ fcTmp.Type = *jsnCfg.Type
+ }
+ if jsnCfg.Field_id != nil {
+ fcTmp.FieldId = *jsnCfg.Field_id
+ }
+ if jsnCfg.Filters != nil {
+ fcTmp.Filters = make([]string, len(*jsnCfg.Filters))
+ for i, fltr := range *jsnCfg.Filters {
+ fcTmp.Filters[i] = fltr
+ }
+ }
+ if jsnCfg.Value != nil {
+ fcTmp.Value = utils.NewRSRParsersMustCompile(*jsnCfg.Value, true)
+ }
+ return fcTmp
+}
+
+type FCTemplate struct {
+ ID string
+ Type string // Type of field
+ FieldId string // Field identifier
+ Filters []string // list of filter profiles
+ Value utils.RSRParsers
+}
+
+func FCTemplatesFromFCTemapltesJsonCfg(jsnCfgFlds []*FcTemplateJsonCfg) []*FCTemplate {
+ retFields := make([]*FCTemplate, len(jsnCfgFlds))
+ for i, jsnFld := range jsnCfgFlds {
+ retFields[i] = NewFCTemplateFromFCTemplateJsonCfg(jsnFld)
+ }
+ return retFields
+}
diff --git a/config/fctemplate_test.go b/config/fctemplate_test.go
new file mode 100755
index 000000000..6255a72bc
--- /dev/null
+++ b/config/fctemplate_test.go
@@ -0,0 +1,85 @@
+/*
+Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
+Copyright (C) ITsysCOM GmbH
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see
+*/
+package config
+
+import (
+ "reflect"
+ "testing"
+
+ "github.com/cgrates/cgrates/utils"
+)
+
+func TestNewFCTemplateFromFCTemplateJsonCfg(t *testing.T) {
+ jsonCfg := &FcTemplateJsonCfg{
+ Id: utils.StringPointer("Tenant"),
+ Type: utils.StringPointer("*composed"),
+ Field_id: utils.StringPointer("Tenant"),
+ Filters: &[]string{"Filter1", "Filter2"},
+ Value: utils.StringPointer("cgrates.org"),
+ }
+ expected := &FCTemplate{
+ ID: "Tenant",
+ Type: "*composed",
+ FieldId: "Tenant",
+ Filters: []string{"Filter1", "Filter2"},
+ Value: utils.NewRSRParsersMustCompile("cgrates.org", true),
+ }
+ rcv := NewFCTemplateFromFCTemplateJsonCfg(jsonCfg)
+ if !reflect.DeepEqual(expected, rcv) {
+ t.Errorf("expected: %s ,received: %s", utils.ToJSON(expected), utils.ToJSON(rcv))
+ }
+}
+
+func TestFCTemplatesFromFCTemapltesJsonCfg(t *testing.T) {
+ jsnCfgs := []*FcTemplateJsonCfg{
+ &FcTemplateJsonCfg{
+ Id: utils.StringPointer("Tenant"),
+ Type: utils.StringPointer("*composed"),
+ Field_id: utils.StringPointer("Tenant"),
+ Filters: &[]string{"Filter1", "Filter2"},
+ Value: utils.StringPointer("cgrates.org"),
+ },
+ &FcTemplateJsonCfg{
+ Id: utils.StringPointer("RunID"),
+ Type: utils.StringPointer("*composed"),
+ Field_id: utils.StringPointer("RunID"),
+ Filters: &[]string{"Filter1_1", "Filter2_2"},
+ Value: utils.StringPointer("SampleValue"),
+ },
+ }
+ expected := []*FCTemplate{
+ &FCTemplate{
+ ID: "Tenant",
+ Type: "*composed",
+ FieldId: "Tenant",
+ Filters: []string{"Filter1", "Filter2"},
+ Value: utils.NewRSRParsersMustCompile("cgrates.org", true),
+ },
+ &FCTemplate{
+ ID: "RunID",
+ Type: "*composed",
+ FieldId: "RunID",
+ Filters: []string{"Filter1_1", "Filter2_2"},
+ Value: utils.NewRSRParsersMustCompile("SampleValue", true),
+ },
+ }
+ rcv := FCTemplatesFromFCTemapltesJsonCfg(jsnCfgs)
+ if !reflect.DeepEqual(expected, rcv) {
+ t.Errorf("expected: %s ,received: %s", utils.ToJSON(expected), utils.ToJSON(rcv))
+ }
+}
diff --git a/config/libconfig_json.go b/config/libconfig_json.go
index dbce7de1b..bab1ddf8c 100755
--- a/config/libconfig_json.go
+++ b/config/libconfig_json.go
@@ -572,3 +572,11 @@ type MigratorCfgJson struct {
Out_storDB_user *string
Out_storDB_password *string
}
+
+type FcTemplateJsonCfg struct {
+ Id *string
+ Type *string
+ Field_id *string
+ Filters *[]string
+ Value *string
+}