From aa1c2021d3d88036b98e606ce3ac12c20fb45c54 Mon Sep 17 00:00:00 2001 From: DanB Date: Thu, 11 Jul 2013 14:44:54 +0200 Subject: [PATCH] Adding TPDestRateTiming APIs and attached documentation --- apier/tpdestinationrates.go | 3 +- apier/tpdestratetimings.go | 83 +++++++ .../mysql/create_tariffplan_tables.sql | 9 +- docs/api_tpdestratetimings.rst | 205 ++++++++++++++++++ docs/api_tprates.rst | 10 +- docs/apicalls.rst | 47 +--- rater/storage_interface.go | 4 + rater/storage_map.go | 17 ++ rater/storage_mongo.go | 16 ++ rater/storage_redis.go | 16 ++ rater/storage_sql.go | 80 ++++++- utils/consts.go | 46 ++-- utils/tpdata.go | 19 +- 13 files changed, 471 insertions(+), 84 deletions(-) create mode 100644 apier/tpdestratetimings.go create mode 100644 docs/api_tpdestratetimings.rst diff --git a/apier/tpdestinationrates.go b/apier/tpdestinationrates.go index 9d96eedcf..2878b2d66 100644 --- a/apier/tpdestinationrates.go +++ b/apier/tpdestinationrates.go @@ -26,7 +26,6 @@ import ( "github.com/cgrates/cgrates/utils" ) - // Creates a new DestinationRate profile within a tariff plan func (self *Apier) SetTPDestinationRate(attrs utils.TPDestinationRate, reply *string) error { if missing := utils.MissingStructFields(&attrs, []string{"TPid", "DestinationRateId", "DestinationRates"}); len(missing) != 0 { @@ -45,7 +44,7 @@ func (self *Apier) SetTPDestinationRate(attrs utils.TPDestinationRate, reply *st } type AttrGetTPDestinationRate struct { - TPid string // Tariff plan id + TPid string // Tariff plan id DestinationRateId string // Rate id } diff --git a/apier/tpdestratetimings.go b/apier/tpdestratetimings.go new file mode 100644 index 000000000..6d387754a --- /dev/null +++ b/apier/tpdestratetimings.go @@ -0,0 +1,83 @@ +/* +Rating system designed to be used in VoIP Carriers World +Copyright (C) 2013 ITsysCOM + +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 apier + +// This file deals with tp_destrates_timing management over APIs + +import ( + "errors" + "fmt" + "github.com/cgrates/cgrates/utils" +) + +// Creates a new DestinationRateTiming profile within a tariff plan +func (self *Apier) SetTPDestRateTiming(attrs utils.TPDestRateTiming, reply *string) error { + if missing := utils.MissingStructFields(&attrs, []string{"TPid", "DestRateTimingId", "DestRateTimings"}); len(missing) != 0 { + return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing) + } + if exists, err := self.StorDb.ExistsTPDestRateTiming(attrs.TPid, attrs.DestRateTimingId); err != nil { + return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error()) + } else if exists { + return errors.New(utils.ERR_DUPLICATE) + } + if err := self.StorDb.SetTPDestRateTiming(&attrs); err != nil { + return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error()) + } + *reply = "OK" + return nil +} + +type AttrGetTPDestRateTiming struct { + TPid string // Tariff plan id + DestRateTimingId string // Rate id +} + +// Queries specific DestRateTiming profile on tariff plan +func (self *Apier) GetTPDestRateTiming(attrs AttrGetTPDestRateTiming, reply *utils.TPDestRateTiming) error { + if missing := utils.MissingStructFields(&attrs, []string{"TPid", "DestRateTimingId"}); len(missing) != 0 { //Params missing + return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing) + } + if dr, err := self.StorDb.GetTPDestRateTiming(attrs.TPid, attrs.DestRateTimingId); err != nil { + return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error()) + } else if dr == nil { + return errors.New(utils.ERR_NOT_FOUND) + } else { + *reply = *dr + } + return nil +} + +type AttrTPDestRateTimingIds struct { + TPid string // Tariff plan id +} + +// Queries DestRateTiming identities on specific tariff plan. +func (self *Apier) GetTPDestRateTimingIds(attrs AttrGetTPRateIds, reply *[]string) error { + if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing + return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing) + } + if ids, err := self.StorDb.GetTPDestRateTimingIds(attrs.TPid); err != nil { + return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error()) + } else if ids == nil { + return errors.New(utils.ERR_NOT_FOUND) + } else { + *reply = ids + } + return nil +} diff --git a/data/storage/mysql/create_tariffplan_tables.sql b/data/storage/mysql/create_tariffplan_tables.sql index b9762a776..b070a1cf9 100644 --- a/data/storage/mysql/create_tariffplan_tables.sql +++ b/data/storage/mysql/create_tariffplan_tables.sql @@ -66,15 +66,16 @@ CREATE TABLE `tp_destination_rates` ( -- Table structure for table `tp_rate_timings` -- -CREATE TABLE `tp_destination_rate_timings` ( +CREATE TABLE `tp_destrate_timings` ( `id` int(11) NOT NULL AUTO_INCREMENT, `tpid` char(40) NOT NULL, `tag` varchar(24) NOT NULL, - `destination_rates_tag` varchar(24) NOT NULL, - `timings_tag` varchar(24) NOT NULL, + `destrates_tag` varchar(24) NOT NULL, + `timing_tag` varchar(24) NOT NULL, `weight` DECIMAL(5,2) NOT NULL, PRIMARY KEY (`id`), - KEY `tpid` (`tpid`) + KEY `tpid` (`tpid`), + UNIQUE KEY `tpid_tag_destrates_timings_weight` (`tpid`,`tag`,`destrates_tag`,`timing_tag`,`weight`) ); -- diff --git a/docs/api_tpdestratetimings.rst b/docs/api_tpdestratetimings.rst new file mode 100644 index 000000000..d96c54b18 --- /dev/null +++ b/docs/api_tpdestratetimings.rst @@ -0,0 +1,205 @@ +Apier.SetTPDestRateTiming ++++++++++++++++++++++++++ + +Creates a new DestinationRateTiming profile within a tariff plan. + +**Request**: + + Data: + :: + + type TPDestRateTiming struct { + TPid string // Tariff plan id + DestRateTimingId string // DestinationRate profile id + DestRateTimings []DestRateTiming // Set of destinationid-rateid bindings + } + + type DestRateTiming struct { + DestRatesId string // The DestinationRate identity + TimingId string // The timing identity + Weight float64 // Binding priority taken into consideration when more DestinationRates are active on a time slot + } + + Mandatory parameters: ``[]string{"TPid", "DestRateTimingId", "DestRateTimings"}`` + + *JSON sample*: + :: + + { + "id": 0, + "method": "Apier.SetTPDestRateTiming", + "params": [ + { + "DestRateTimingId": "SAMPLE_DRTIMING_1", + "DestRateTimings": [ + { + "DestRatesId": "SAMPLE_DR_1", + "TimingId": "SAMPLE_TIMING_1", + "Weight": 10 + } + ], + "TPid": "SAMPLE_TP" + } + ] + } + +**Reply**: + + Data: + :: + + string + + Possible answers: + ``OK`` - Success. + + *JSON sample*: + :: + + { + "error": null, + "id": 0, + "result": "OK" + } + +**Errors**: + + ``MANDATORY_IE_MISSING`` - Mandatory parameter missing from request. + + ``SERVER_ERROR`` - Server error occurred. + + ``DUPLICATE`` - The specified combination of TPid/DestRateTimingId already exists in StorDb. + + +Apier.GetTPDestRateTiming ++++++++++++++++++++++++++ + +Queries specific DestRateTiming profile on tariff plan. + +**Request**: + + Data: + :: + + type AttrGetTPDestRateTiming struct { + TPid string // Tariff plan id + DestRateTimingId string // Rate id + } + + Mandatory parameters: ``[]string{"TPid", "DestRateTimingId"}`` + + *JSON sample*: + :: + + { + "id": 4, + "method": "Apier.GetTPDestRateTiming", + "params": [ + { + "DestRateTimingId": "SAMPLE_DRTIMING_1", + "TPid": "SAMPLE_TP" + } + ] + } + +**Reply**: + + Data: + :: + + type TPDestRateTiming struct { + TPid string // Tariff plan id + DestRateTimingId string // DestinationRate profile id + DestRateTimings []DestRateTiming // Set of destinationid-rateid bindings + } + + type DestRateTiming struct { + DestRatesId string // The DestinationRate identity + TimingId string // The timing identity + Weight float64 // Binding priority taken into consideration when more DestinationRates are active on a time slot + } + + *JSON sample*: + :: + + { + "error": null, + "id": 4, + "result": { + "DestRateTimingId": "SAMPLE_DRTIMING_1", + "DestRateTimings": [ + { + "DestRatesId": "SAMPLE_DR_1", + "TimingId": "SAMPLE_TIMING_1", + "Weight": 10 + } + ], + "TPid": "SAMPLE_TP" + } + } + +**Errors**: + + ``MANDATORY_IE_MISSING`` - Mandatory parameter missing from request. + + ``SERVER_ERROR`` - Server error occurred. + + ``NOT_FOUND`` - Requested DestRateTiming profile not found. + + +Apier.GetTPDestRateTimingIds +++++++++++++++++++++++++++++ + +Queries DestRateTiming identities on specific tariff plan. + +**Request**: + + Data: + :: + + type AttrTPDestRateTimingIds struct { + TPid string // Tariff plan id + } + + Mandatory parameters: ``[]string{"TPid"}`` + + *JSON sample*: + :: + + { + "id": 5, + "method": "Apier.GetTPDestRateTimingIds", + "params": [ + { + "TPid": "SAMPLE_TP" + } + ] + } + +**Reply**: + + Data: + :: + + []string + + *JSON sample*: + :: + + { + "error": null, + "id": 5, + "result": [ + "SAMPLE_DRTIMING_1", + "SAMPLE_DRTIMING_2", + "SAMPLE_DRTIMING_3" + ] + } + +**Errors**: + + ``MANDATORY_IE_MISSING`` - Mandatory parameter missing from request. + + ``SERVER_ERROR`` - Server error occurred. + + ``NOT_FOUND`` - Requested tariff plan not found. diff --git a/docs/api_tprates.rst b/docs/api_tprates.rst index a2ddd6779..51046bb00 100644 --- a/docs/api_tprates.rst +++ b/docs/api_tprates.rst @@ -1,5 +1,5 @@ Apier.SetTPRate -+++++++++++++++++ ++++++++++++++++ Creates a new rate within a tariff plan. @@ -52,7 +52,7 @@ Creates a new rate within a tariff plan. "TPid": "SAMPLE_TP" } ] - } + } **Reply**: @@ -159,6 +159,7 @@ Queries specific rate on tariff plan. "TPid": "SAMPLE_TP" } } + **Errors**: ``MANDATORY_IE_MISSING`` - Mandatory parameter missing from request. @@ -169,7 +170,7 @@ Queries specific rate on tariff plan. Apier.GetTPRateIds -+++++++++++++++++++++++++ +++++++++++++++++++ Queries rate identities on tariff plan. @@ -216,7 +217,7 @@ Queries rate identities on tariff plan. "SAMPLE_RATE_3", "SAMPLE_RATE_4" ] - } + } **Errors**: @@ -227,4 +228,3 @@ Queries rate identities on tariff plan. ``NOT_FOUND`` - Requested tariff plan not found. - diff --git a/docs/apicalls.rst b/docs/apicalls.rst index df3dbb3d8..a238a721e 100644 --- a/docs/apicalls.rst +++ b/docs/apicalls.rst @@ -166,13 +166,13 @@ DestinationRates api_tpdestinationrates -GetTPRateTiming +DestinationRateTiming +~~~~~~~~~~~~~~~~~~~~~ -SetTPRateTiming +.. toctree:: + :maxdepth: 2 -DeleteTPRateTiming - -GetAllTPRateTinings + api_tpdestratetimings GetTPRatingProfile @@ -184,47 +184,10 @@ DeleteTPProfile GetAllTPRatingProfiles -GetTPAction - -SetTPAction - -DeleteTPAction - -GetAllTPActions - - -GetTPActionTiming - -SetTPActionTiming - -DeleteTPActionTiming - -GetAllTPActionTimings - - -GetTPActionTrigger - -SetTPActionTrigger - -DeleteTPActionTrigger - -GetAllTPActionTriggers - - -GetTPAccountAction - -SetTPAccountAction - -DeleteTPAccountAction - -GetAllTPAccountActions - - ImportWithOverride ImportWithFlush -GetAllTPTariffPlanIds 6.1.5. Management API --------------------- diff --git a/rater/storage_interface.go b/rater/storage_interface.go index 14e18a344..7a4e325e1 100644 --- a/rater/storage_interface.go +++ b/rater/storage_interface.go @@ -75,6 +75,10 @@ type DataStorage interface { SetTPDestinationRate(*utils.TPDestinationRate) error GetTPDestinationRate(string, string) (*utils.TPDestinationRate, error) GetTPDestinationRateIds(string) ([]string, error) + ExistsTPDestRateTiming(string, string) (bool, error) + SetTPDestRateTiming(*utils.TPDestRateTiming) error + GetTPDestRateTiming(string, string) (*utils.TPDestRateTiming, error) + GetTPDestRateTimingIds(string) ([]string, error) // End Apier functions GetActions(string) (Actions, error) SetActions(string, Actions) error diff --git a/rater/storage_map.go b/rater/storage_map.go index 039d2dc4f..ae1b77ad1 100644 --- a/rater/storage_map.go +++ b/rater/storage_map.go @@ -141,6 +141,23 @@ func (ms *MapStorage) GetTPDestinationRateIds(tpid string) ([]string, error) { return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) } +func (ms *MapStorage) ExistsTPDestRateTiming(tpid, drtId string) (bool, error) { + return false, errors.New(utils.ERR_NOT_IMPLEMENTED) +} + +func (ms *MapStorage) SetTPDestRateTiming(drt *utils.TPDestRateTiming) error { + return errors.New(utils.ERR_NOT_IMPLEMENTED) +} + +func (ms *MapStorage) GetTPDestRateTiming(tpid, drtId string) (*utils.TPDestRateTiming, error) { + return nil, nil +} + +func (ms *MapStorage) GetTPDestRateTimingIds(tpid string) ([]string, error) { + return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) +} + + func (ms *MapStorage) GetActions(key string) (as Actions, err error) { if values, ok := ms.dict[ACTION_PREFIX+key]; ok { diff --git a/rater/storage_mongo.go b/rater/storage_mongo.go index 73bf564b9..499ecd21d 100644 --- a/rater/storage_mongo.go +++ b/rater/storage_mongo.go @@ -216,6 +216,22 @@ func (ms *MongoStorage) GetTPDestinationRateIds(tpid string) ([]string, error) { return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) } +func (ms *MongoStorage) ExistsTPDestRateTiming(tpid, drtId string) (bool, error) { + return false, errors.New(utils.ERR_NOT_IMPLEMENTED) +} + +func (ms *MongoStorage) SetTPDestRateTiming(drt *utils.TPDestRateTiming) error { + return errors.New(utils.ERR_NOT_IMPLEMENTED) +} + +func (ms *MongoStorage) GetTPDestRateTiming(tpid, drtId string) (*utils.TPDestRateTiming, error) { + return nil, nil +} + +func (ms *MongoStorage) GetTPDestRateTimingIds(tpid string) ([]string, error) { + return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) +} + func (ms *MongoStorage) GetActions(key string) (as Actions, err error) { result := AcKeyValue{} err = ms.db.C("actions").Find(bson.M{"key": key}).One(&result) diff --git a/rater/storage_redis.go b/rater/storage_redis.go index 1ba05466d..46260bdc7 100644 --- a/rater/storage_redis.go +++ b/rater/storage_redis.go @@ -171,6 +171,22 @@ func (rs *RedisStorage) GetTPDestinationRateIds(tpid string) ([]string, error) { return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) } +func (rs *RedisStorage) ExistsTPDestRateTiming(tpid, drtId string) (bool, error) { + return false, errors.New(utils.ERR_NOT_IMPLEMENTED) +} + +func (rs *RedisStorage) SetTPDestRateTiming(drt *utils.TPDestRateTiming) error { + return errors.New(utils.ERR_NOT_IMPLEMENTED) +} + +func (rs *RedisStorage) GetTPDestRateTiming(tpid, drtId string) (*utils.TPDestRateTiming, error) { + return nil, nil +} + +func (rs *RedisStorage) GetTPDestRateTimingIds(tpid string) ([]string, error) { + return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) +} + func (rs *RedisStorage) GetActions(key string) (as Actions, err error) { var values string if values, err = rs.db.Get(ACTION_PREFIX + key); err == nil { diff --git a/rater/storage_sql.go b/rater/storage_sql.go index a7871ab75..b03bee698 100644 --- a/rater/storage_sql.go +++ b/rater/storage_sql.go @@ -57,7 +57,7 @@ func (self *SQLStorage) SetDestination(d *Destination) (err error) { // Return a list with all TPids defined in the system, even if incomplete, isolated in some table. func (self *SQLStorage) GetTPIds() ([]string, error) { rows, err := self.Db.Query( - fmt.Sprintf("(SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s)", utils.TBL_TP_TIMINGS, utils.TBL_TP_DESTINATIONS, utils.TBL_TP_RATES, utils.TBL_TP_DESTINATION_RATES, utils.TBL_TP_DESTINATION_RATE_TIMINGS, utils.TBL_TP_RATE_PROFILES)) + fmt.Sprintf("(SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s)", utils.TBL_TP_TIMINGS, utils.TBL_TP_DESTINATIONS, utils.TBL_TP_RATES, utils.TBL_TP_DESTINATION_RATES, utils.TBL_TP_DESTRATE_TIMINGS, utils.TBL_TP_RATE_PROFILES)) if err != nil { return nil, err } @@ -280,7 +280,7 @@ func (self *SQLStorage) SetTPDestinationRate(dr *utils.TPDestinationRate) error return nil //Nothing to set } // Using multiple values in query to spare some network processing time - qry := fmt.Sprintf("INSERT INTO %s (tpid, tag, destinations_tag, rates_tag) VALUES", utils.TBL_TP_DESTINATION_RATES) + qry := fmt.Sprintf("INSERT INTO %s (tpid, tag, destinations_tag, rates_tag) VALUES ", utils.TBL_TP_DESTINATION_RATES) for idx, drPair := range dr.DestinationRates { if idx!=0 { //Consecutive values after the first will be prefixed with "," as separator qry += "," @@ -339,6 +339,80 @@ func (self *SQLStorage) GetTPDestinationRateIds(tpid string) ([]string, error) { return ids, nil } +func (self *SQLStorage) ExistsTPDestRateTiming(tpid, drtId string) (bool, error) { + var exists bool + err := self.Db.QueryRow(fmt.Sprintf("SELECT EXISTS (SELECT 1 FROM %s WHERE tpid='%s' AND tag='%s')", utils.TBL_TP_DESTRATE_TIMINGS, tpid, drtId)).Scan(&exists) + if err != nil { + return false, err + } + return exists, nil +} + +func (self *SQLStorage) SetTPDestRateTiming(drt *utils.TPDestRateTiming) error { + if len(drt.DestRateTimings) == 0 { + return nil //Nothing to set + } + // Using multiple values in query to spare some network processing time + qry := fmt.Sprintf("INSERT INTO %s (tpid, tag, destrates_tag, timing_tag, weight) VALUES ", utils.TBL_TP_DESTRATE_TIMINGS) + for idx, drtPair := range drt.DestRateTimings { + if idx!=0 { //Consecutive values after the first will be prefixed with "," as separator + qry += "," + } + qry += fmt.Sprintf("('%s','%s','%s','%s',%f)", drt.TPid, drt.DestRateTimingId, drtPair.DestRatesId, drtPair.TimingId, drtPair.Weight) + } + if _, err := self.Db.Exec(qry); err != nil { + return err + } + return nil +} + +func (self *SQLStorage) GetTPDestRateTiming(tpid, drtId string) (*utils.TPDestRateTiming, error) { + rows, err := self.Db.Query(fmt.Sprintf("SELECT destrates_tag, timing_tag, weight from %s where tpid='%s' and tag='%s'", utils.TBL_TP_DESTRATE_TIMINGS, tpid, drtId)) + if err != nil { + return nil, err + } + defer rows.Close() + drt := &utils.TPDestRateTiming{TPid: tpid, DestRateTimingId: drtId} + i := 0 + for rows.Next() { + i++ //Keep here a reference so we know we got at least one result + var drTag, timingTag string + var weight float64 + err = rows.Scan(&drTag, &timingTag, &weight) + if err != nil { + return nil, err + } + drt.DestRateTimings = append(drt.DestRateTimings, utils.DestRateTiming{drTag, timingTag,weight}) + } + if i == 0 { + return nil, nil + } + return drt, nil +} + +func (self *SQLStorage) GetTPDestRateTimingIds(tpid string) ([]string, error) { + rows, err := self.Db.Query(fmt.Sprintf("SELECT DISTINCT tag FROM %s where tpid='%s'", utils.TBL_TP_DESTRATE_TIMINGS, tpid)) + if err != nil { + return nil, err + } + defer rows.Close() + ids := []string{} + i := 0 + for rows.Next() { + i++ //Keep here a reference so we know we got at least one + var id string + err = rows.Scan(&id) + if err != nil { + return nil, err + } + ids = append(ids, id) + } + if i == 0 { + return nil, nil + } + return ids, nil +} + func (self *SQLStorage) GetActions(string) (as Actions, err error) { return } @@ -570,7 +644,7 @@ func (self *SQLStorage) GetTpTimings(tpid, tag string) (map[string]*Timing, erro func (self *SQLStorage) GetTpDestinationRateTimings(tpid, tag string) ([]*DestinationRateTiming, error) { var rts []*DestinationRateTiming - q := fmt.Sprintf("SELECT * FROM %s WHERE tpid=%s", utils.TBL_TP_DESTINATION_RATE_TIMINGS, tpid) + q := fmt.Sprintf("SELECT * FROM %s WHERE tpid=%s", utils.TBL_TP_DESTRATE_TIMINGS, tpid) if tag != "" { q += "AND tag=" + tag } diff --git a/utils/consts.go b/utils/consts.go index 1e6bacbd4..91aed2df5 100644 --- a/utils/consts.go +++ b/utils/consts.go @@ -1,27 +1,27 @@ package utils const ( - LOCALHOST = "127.0.0.1" - FSCDR_FILE_CSV = "freeswitch_file_csv" - FSCDR_HTTP_JSON = "freeswitch_http_json" - NOT_IMPLEMENTED = "not implemented" - PREPAID = "prepaid" - POSTPAID = "postpaid" - PSEUDOPREPAID = "pseudoprepaid" - RATED = "rated" - ERR_NOT_IMPLEMENTED = "NOT_IMPLEMENTED" - ERR_SERVER_ERROR = "SERVER_ERROR" - ERR_NOT_FOUND = "NOT_FOUND" - ERR_MANDATORY_IE_MISSING = "MANDATORY_IE_MISSING" - ERR_DUPLICATE = "DUPLICATE" - TBL_TP_TIMINGS = "tp_timings" - TBL_TP_DESTINATIONS = "tp_destinations" - TBL_TP_RATES = "tp_rates" - TBL_TP_DESTINATION_RATES = "tp_destination_rates" - TBL_TP_DESTINATION_RATE_TIMINGS = "tp_destination_rate_timings" - TBL_TP_RATE_PROFILES = "tp_rate_profiles" - TBL_TP_ACTIONS = "tp_actions" - TBL_TP_ACTION_TIMINGS = "tp_action_timings" - TBL_TP_ACTION_TRIGGERS = "tp_action_triggers" - TBL_TP_ACCOUNT_ACTIONS = "tp_account_actions" + LOCALHOST = "127.0.0.1" + FSCDR_FILE_CSV = "freeswitch_file_csv" + FSCDR_HTTP_JSON = "freeswitch_http_json" + NOT_IMPLEMENTED = "not implemented" + PREPAID = "prepaid" + POSTPAID = "postpaid" + PSEUDOPREPAID = "pseudoprepaid" + RATED = "rated" + ERR_NOT_IMPLEMENTED = "NOT_IMPLEMENTED" + ERR_SERVER_ERROR = "SERVER_ERROR" + ERR_NOT_FOUND = "NOT_FOUND" + ERR_MANDATORY_IE_MISSING = "MANDATORY_IE_MISSING" + ERR_DUPLICATE = "DUPLICATE" + TBL_TP_TIMINGS = "tp_timings" + TBL_TP_DESTINATIONS = "tp_destinations" + TBL_TP_RATES = "tp_rates" + TBL_TP_DESTINATION_RATES = "tp_destination_rates" + TBL_TP_DESTRATE_TIMINGS = "tp_destrate_timings" + TBL_TP_RATE_PROFILES = "tp_rate_profiles" + TBL_TP_ACTIONS = "tp_actions" + TBL_TP_ACTION_TIMINGS = "tp_action_timings" + TBL_TP_ACTION_TRIGGERS = "tp_action_triggers" + TBL_TP_ACCOUNT_ACTIONS = "tp_account_actions" ) diff --git a/utils/tpdata.go b/utils/tpdata.go index 784956d63..dc6048d66 100644 --- a/utils/tpdata.go +++ b/utils/tpdata.go @@ -34,16 +34,25 @@ type RateSlot struct { Weight float64 // Rate's priority when dealing with grouped rates } - type TPDestinationRate struct { - TPid string // Tariff plan id - DestinationRateId string // DestinationRate profile id - DestinationRates []DestinationRate // Set of destinationid-rateid bindings + TPid string // Tariff plan id + DestinationRateId string // DestinationRate profile id + DestinationRates []DestinationRate // Set of destinationid-rateid bindings } type DestinationRate struct { DestinationId string // The destination identity - RateId string // The rate identity + RateId string // The rate identity } +type TPDestRateTiming struct { + TPid string // Tariff plan id + DestRateTimingId string // DestinationRate profile id + DestRateTimings []DestRateTiming // Set of destinationid-rateid bindings +} +type DestRateTiming struct { + DestRatesId string // The DestinationRate identity + TimingId string // The timing identity + Weight float64 // Binding priority taken into consideration when more DestinationRates are active on a time slot +}