Documentation ¶
Overview ¶
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 <http://www.gnu.org/licenses/>
Index ¶
- Constants
- func ConvertMapValStrIf(inMap map[string]string) map[string]interface{}
- func FSCgrId(uuid string) string
- func FirstNonEmpty(vals ...string) string
- func GenUUID() string
- func IsSliceMember(ss []string, s string) bool
- func MapKeys(m map[string]string) []string
- func MirrorMap(mapIn map[string]string) (map[string]string, error)
- func MissingMapKeys(inMap map[string]string, requiredKeys []string) []string
- func MissingStructFields(s interface{}, mandatories []string) []string
- func NewTPid() string
- func NonemptyStructFields(s interface{}) map[string]interface{}
- func ParseDate(date string) (expDate time.Time, err error)
- func Round(x float64, prec int, method string) float64
- func RoundToMinute(seconds float64) float64
- func SliceMemberHasPrefix(ss []string, prfx string) bool
- func StrucToMap(s interface{}) map[string]interface{}
- func UpdateStructWithStrMap(s interface{}, m map[string]string) []string
- type Action
- type ApiActionTiming
- type ApiActionTrigger
- type ApiTPAccountActions
- type ApiTPActionTimings
- type ApiTPActionTriggers
- type AttrTPRatingProfileIds
- type CDR
- type DestRateTiming
- type DestinationRate
- type GenericCdr
- func (gcdr GenericCdr) GetAccId() string
- func (gcdr GenericCdr) GetAccount() string
- func (gcdr GenericCdr) GetAnswerTime() (time.Time, error)
- func (gcdr GenericCdr) GetCdrHost() string
- func (gcdr GenericCdr) GetCgrId() string
- func (gcdr GenericCdr) GetDestination() string
- func (gcdr GenericCdr) GetDirection() string
- func (gcdr GenericCdr) GetDuration() int64
- func (gcdr GenericCdr) GetExtraFields() map[string]string
- func (gcdr GenericCdr) GetFallbackSubj() string
- func (gcdr GenericCdr) GetOrigId() string
- func (gcdr GenericCdr) GetReqType() string
- func (gcdr GenericCdr) GetSubject() string
- func (gcdr GenericCdr) GetTOR() string
- func (gcdr GenericCdr) GetTenant() string
- type LoggerInterface
- type RateSlot
- type RatingActivation
- type StdLogger
- func (sl *StdLogger) Alert(m string) (err error)
- func (sl *StdLogger) Close() (err error)
- func (sl *StdLogger) Crit(m string) (err error)
- func (sl *StdLogger) Debug(m string) (err error)
- func (sl *StdLogger) Emerg(m string) (err error)
- func (sl *StdLogger) Err(m string) (err error)
- func (sl *StdLogger) Info(m string) (err error)
- func (sl *StdLogger) Notice(m string) (err error)
- func (sl *StdLogger) Warning(m string) (err error)
- type TPActionTimingsRow
- type TPActions
- type TPDestRateTiming
- type TPDestinationRate
- type TPRate
- type TPRatingProfile
Constants ¶
const ( VERSION = "0.9.1rc3" POSTGRES = "postgres" MYSQL = "mysql" MONGO = "mongo" REDIS = "redis" 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_rating_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" TBL_COST_DETAILS = "cost_details" TBL_RATED_CDRS = "rated_cdrs" TIMINGS_CSV = "Timings.csv" DESTINATIONS_CSV = "Destinations.csv" RATES_CSV = "Rates.csv" DESTINATION_RATES_CSV = "DestinationRates.csv" DESTRATE_TIMINGS_CSV = "DestinationRateTimings.csv" RATE_PROFILES_CSV = "RatingProfiles.csv" ACTIONS_CSV = "Actions.csv" ACTION_TIMINGS_CSV = "ActionTimings.csv" ACTION_TRIGGERS_CSV = "ActionTriggers.csv" ACCOUNT_ACTIONS_CSV = "AccountActions.csv" TIMINGS_NRCOLS = 6 DESTINATIONS_NRCOLS = 2 RATES_NRCOLS = 9 DESTINATION_RATES_NRCOLS = 3 DESTRATE_TIMINGS_NRCOLS = 4 RATE_PROFILES_NRCOLS = 7 ACTIONS_NRCOLS = 11 ACTION_TIMINGS_NRCOLS = 4 ACTION_TRIGGERS_NRCOLS = 8 ACCOUNT_ACTIONS_NRCOLS = 5 ROUNDING_UP = "*up" ROUNDING_MIDDLE = "*middle" ROUNDING_DOWN = "*down" COMMENT_CHAR = '#' )
Variables ¶
This section is empty.
Functions ¶
func ConvertMapValStrIf ¶
Converts map[string]string into map[string]interface{}
func FirstNonEmpty ¶
Returns first non empty string out of vals. Useful to extract defaults
func MissingMapKeys ¶
Returns mising keys in a map
func MissingStructFields ¶
Detects missing field values based on mandatory field names, s should be a pointer to a struct
func NonemptyStructFields ¶
func NonemptyStructFields(s interface{}) map[string]interface{}
Detects nonempty struct fields, s should be a pointer to a struct Useful to not overwrite db fields with non defined params in api
func Round ¶
Round return rounded version of x with prec precision.
Special cases are:
Round(±0) = ±0 Round(±Inf) = ±Inf Round(NaN) = NaN
func RoundToMinute ¶
func SliceMemberHasPrefix ¶
Iterates over slice members and returns true of one starts with prefix
func UpdateStructWithStrMap ¶
Update struct with map fields, returns not matching map keys, s is a struct to be updated
Types ¶
type Action ¶
type Action struct { Identifier string // Identifier mapped in the code BalanceType string // Type of balance the action will operate on Direction string // Balance direction Units float64 // Number of units to add/deduct ExpiryTime string // Time when the units will expire DestinationId string // Destination profile id RateType string // Type of rate <*absolute|*percent> Rate float64 // Price value MinutesWeight float64 // Minutes weight Weight float64 // Action's weight }
type ApiActionTiming ¶
type ApiActionTrigger ¶
type ApiActionTrigger struct { BalanceType string // Type of balance this trigger monitors Direction string // Traffic direction ThresholdType string // This threshold type ThresholdValue float64 // Threshold DestinationId string // Id of the destination profile ActionsId string // Actions which will execute on threshold reached Weight float64 // weight }
type ApiTPAccountActions ¶
type ApiTPAccountActions struct { TPid string // Tariff plan id AccountActionsId string // AccountActions id Tenant string // Tenant's Id Account string // Account name Direction string // Traffic direction ActionTimingsId string // Id of ActionTimings profile to use ActionTriggersId string // Id of ActionTriggers profile to use }
type ApiTPActionTimings ¶
type ApiTPActionTimings struct { TPid string // Tariff plan id ActionTimingsId string // ActionTimings id ActionTimings []ApiActionTiming // Set of ActionTiming bindings this profile will group }
type ApiTPActionTriggers ¶
type ApiTPActionTriggers struct { TPid string // Tariff plan id ActionTriggersId string // Profile id ActionTriggers []ApiActionTrigger // Set of triggers grouped in this profile }
type AttrTPRatingProfileIds ¶
type CDR ¶
type CDR interface { GetCgrId() string GetAccId() string GetCdrHost() string GetDirection() string GetOrigId() string GetSubject() string GetAccount() string GetDestination() string GetTOR() string GetTenant() string GetReqType() string GetAnswerTime() (time.Time, error) GetDuration() int64 GetFallbackSubj() string GetExtraFields() map[string]string //Stores extra CDR Fields }
type DestRateTiming ¶
type DestinationRate ¶
type GenericCdr ¶
func (GenericCdr) GetAccId ¶
func (gcdr GenericCdr) GetAccId() string
func (GenericCdr) GetAccount ¶
func (gcdr GenericCdr) GetAccount() string
func (GenericCdr) GetAnswerTime ¶
func (gcdr GenericCdr) GetAnswerTime() (time.Time, error)
func (GenericCdr) GetCdrHost ¶
func (gcdr GenericCdr) GetCdrHost() string
func (GenericCdr) GetCgrId ¶
func (gcdr GenericCdr) GetCgrId() string
func (GenericCdr) GetDestination ¶
func (gcdr GenericCdr) GetDestination() string
func (GenericCdr) GetDirection ¶
func (gcdr GenericCdr) GetDirection() string
func (GenericCdr) GetDuration ¶
func (gcdr GenericCdr) GetDuration() int64
func (GenericCdr) GetExtraFields ¶
func (gcdr GenericCdr) GetExtraFields() map[string]string
func (GenericCdr) GetFallbackSubj ¶
func (gcdr GenericCdr) GetFallbackSubj() string
func (GenericCdr) GetOrigId ¶
func (gcdr GenericCdr) GetOrigId() string
func (GenericCdr) GetReqType ¶
func (gcdr GenericCdr) GetReqType() string
func (GenericCdr) GetSubject ¶
func (gcdr GenericCdr) GetSubject() string
func (GenericCdr) GetTOR ¶
func (gcdr GenericCdr) GetTOR() string
func (GenericCdr) GetTenant ¶
func (gcdr GenericCdr) GetTenant() string
type LoggerInterface ¶
type RateSlot ¶
type RateSlot struct { ConnectFee float64 // ConnectFee applied once the call is answered Rate float64 // Rate applied RatedUnits string // Number of billing units this rate applies to RateIncrements string // This rate will apply in increments of duration GroupIntervalStart string // Group position RoundingMethod string // Use this method to round the cost RoundingDecimals int // Round the cost number of decimals Weight float64 // Rate's priority when dealing with grouped rates }
type RatingActivation ¶
type TPActionTimingsRow ¶
type TPActionTimingsRow struct { ActionsId string // Actions id TimingId string // Timing profile id Weight float64 // Binding's weight }
Represents a single row in .csv or storDb, id will be used as key in the map holding all rows
type TPDestRateTiming ¶
type TPDestRateTiming struct { TPid string // Tariff plan id DestRateTimingId string // DestinationRate profile id DestRateTimings []DestRateTiming // Set of destinationid-rateid bindings }
type TPDestinationRate ¶
type TPDestinationRate struct { TPid string // Tariff plan id DestinationRateId string // DestinationRate profile id DestinationRates []DestinationRate // Set of destinationid-rateid bindings }
type TPRatingProfile ¶
type TPRatingProfile struct { TPid string // Tariff plan id RatingProfileId string // RatingProfile id Tenant string // Tenant's Id TOR string // TypeOfRecord Direction string // Traffic direction, OUT is the only one supported for now Subject string // Rating subject, usually the same as account RatesFallbackSubject string // Fallback on this subject if rates not found for destination RatingActivations []RatingActivation // Activate rate profiles at specific time }