bills

package
v0.0.0-...-c130b31 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2018 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

** Copyright [2013-2017] [Megam Systems] ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License.

** Copyright [2013-2017] [Megam Systems] ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License.

** Copyright [2013-2017] [Megam Systems] ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License.

** Copyright [2013-2017] [Megam Systems] ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License.

Index

Constants

View Source
const (
	ORGANIZATIONGET = "/organizations"
	ACCOUNTS_GET    = "/accounts/"
)
View Source
const (
	UPDATE           = "/update"
	BALANCE          = "/balances/"
	EVENTBALANCEJSON = "Megam::Balances"
)
View Source
const (
	SCYLLADB = "scylladb"
	WHMCS    = "whmcs"
)
View Source
const (
	EVENTSKEWS          = "/eventsskews"
	EVENTSKEWS_NEW      = "/eventsskews/content"
	EVENTSKEWS_UPDATE   = "/eventsskews/update"
	EVENTEVENTSKEWSJSON = "Megam::Skews"
	HARDSKEWS           = "terminate"
	SOFTSKEWS           = "suspend"
	WARNING             = "warning"
	ACTIVE              = "active"
	RESUME              = "start"
)
View Source
const (
	NEWBILLEDHISTORY = "/billedhistories/content"
	BILLJSONCLAZ     = "Megam::Billedhistories"
)

Variables

View Source
var BillProviders map[string]BillProvider

Functions

func GetBase64

func GetBase64(dummymap map[string]string) string

func GetMD5Hash

func GetMD5Hash(text string) string

func Register

func Register(name string, provider BillProvider)

Register registers a new billing provider, that can be later configured and used.

func SetField

func SetField(obj interface{}, name string, value string) error

Types

type Accounts

type Accounts struct {
	Id           string   `json:"id" cql:"id"`
	Name         Name     `json:"name" cql:"name"`
	Phone        Phone    `json:"phone" cql:"phone"`
	Email        string   `json:"email" cql:"email"`
	Dates        Dates    `json:"dates" cql:"dates"`
	ApiKey       string   `json:"api_key" cql:"api_key"`
	Password     Password `json:"password" cql:"password"`
	Approval     Approval `json:"approval" cql:"approval"`
	Suspend      Suspend  `json:"suspend" cql:"suspend"`
	RegIpAddress string   `json:"registration_ip_address" cql:"registration_ip_address"`
	States       States   `json:"states" cql:"states"`
}

func NewAccounts

func NewAccounts(m map[string]string) (*Accounts, error)

type ApiAccounts

type ApiAccounts struct {
	JsonClaz string   `json:"json_claz" cql:"json_claz"`
	Results  Accounts `json:"results" cql:"results"`
}

type ApiBalances

type ApiBalances struct {
	JsonClaz string     `json:"json_claz" cql:"json_claz"`
	Results  []Balances `json:"results" json:"results"`
}

type ApiOrganizations

type ApiOrganizations struct {
	JsonClaz string       `json:"json_claz" cql:"json_claz"`
	Results  Organization `json:"results" cql:"results"`
}

type ApiSkewsEvents

type ApiSkewsEvents struct {
	JsonClaz string         `json:"json_claz"`
	Results  []*EventsSkews `json:"results"`
}

type Approval

type Approval struct {
	Approved     string `json:"approved" cql:"approved"`
	ApprovedById string `json:"approved_by_id" cql:"approved_by_id"`
	ApprovedAt   string `json:"approved_at" cql:"approved_at"`
}

type BalanceOpts

type BalanceOpts struct {
	Id       string
	Consumed string
}

type Balances

type Balances struct {
	Id        string `json:"id" cql:"id"`
	AccountId string `json:"account_id" cql:"account_id"`
	Credit    string `json:"credit" cql:"credit"`
	JsonClaz  string `json:"json_claz" cql:"json_claz"`
}

func NewBalances

func NewBalances(email string, m map[string]string) (*Balances, error)

Temporary hack to create an assembly from its id. This is used by SetStatus. We need add a Notifier interface duck typed by Box and Carton ?

func (*Balances) Deduct

func (b *Balances) Deduct(bopts *BalanceOpts, m map[string]string) error

func (*Balances) String

func (b *Balances) String() string

type BillOpts

type BillOpts struct {
	AccountId       string
	AssemblyId      string
	AssembliesId    string
	AssemblyName    string
	Consumed        string
	StartTime       string
	EndTime         string
	QuotaId         string
	SkewsType       string
	SoftGracePeriod string
	SoftLimit       string
	HardGracePeriod string
	HardLimit       string
	Resources       string
	Timestamp       string
	M               map[string]string
}

BillOpts represents a billtransaction managed by the provider

func (*BillOpts) FillStruct

func (s *BillOpts) FillStruct(m map[string]string) error

type BillProvider

type BillProvider interface {
	IsEnabled() bool                                    //is this billing provider enabled.
	Onboard(o *BillOpts, m map[string]string) error     //onboard an user in the billing system
	Nuke(o *BillOpts) error                             //delete an user from the billing system
	Suspend(o *BillOpts) error                          //suspend an user from the billing system
	Deduct(o *BillOpts, m map[string]string) error      //deduct the balance credit
	Transaction(o *BillOpts, m map[string]string) error //deduct the bill transaction
	Invoice(o *BillOpts) error                          //invoice for a  range.
	Notify(o *BillOpts) error                           //notify an user
	AuditUnpaid(o *BillOpts, m map[string]string) error
}

func Provider

func Provider(providerName string) BillProvider

Provider returns the current configured manager, as defined in the configuration file.

type BilledHistories

type BilledHistories struct {
	AccountId     string `json:"-" cql:"account_id"`
	AssemblyId    string `json:"assembly_id" cql:"assembly_id"`
	BillType      string `json:"bill_type" cql:"bill_type"`
	BillingAmount string `json:"billing_amount" cql:"billing_amount"`
	StateDate     string `json:"start_date" cql:"start_date"`
	EndDate       string `json:"end_date" cql:"end_date"`
	CurrencyType  string `json:"currency_type" cql:"currency_type"`
}

func NewBilledHistories

func NewBilledHistories(topts *BillOpts) (*BilledHistories, error)

func (*BilledHistories) BilledHistories

func (bt *BilledHistories) BilledHistories(m map[string]string) error

type BilledHistoriesOpts

type BilledHistoriesOpts struct {
	AccountId    string
	AssemblyId   string
	AssemblyName string
	Consumed     string
}

func (*BilledHistoriesOpts) String

func (bt *BilledHistoriesOpts) String() string

type Dates

type Dates struct {
	CreatedAt       string `json:"created_at" cql:"created_at"`
	LastPostedAt    string `json:"last_posted_at" cql:"last_posted_at"`
	LastEmailedAt   string `json:"last_emailed_at" cql:"last_emailed_at"`
	PreviousVisitAt string `json:"previous_visit_at" cql:"previous_visit_at"`
	FirstSeenAt     string `json:"first_seen_at" cql:"first_seen_at"`
}

type EventsSkews

type EventsSkews struct {
	Id        string          `json:"id"`
	AccountId string          `json:"account_id"`
	CatId     string          `json:"cat_id"`
	Inputs    pairs.JsonPairs `json:"inputs"`
	Outputs   pairs.JsonPairs `json:"outputs"`
	Actions   pairs.JsonPairs `json:"actions"`
	JsonClaz  string          `json:"json_claz"`
	Status    string          `json:"status"`
	EventType string          `json:"event_type"`
}

func NewEventsSkews

func NewEventsSkews(email, cat_id string, mi map[string]string) ([]*EventsSkews, error)

func (*EventsSkews) ActionEvents

func (s *EventsSkews) ActionEvents(o *BillOpts, currentBal string, mi map[string]string) error

func (*EventsSkews) Create

func (s *EventsSkews) Create(mi map[string]string, o *BillOpts) error

func (*EventsSkews) CreateEvent

func (s *EventsSkews) CreateEvent(o *BillOpts, ACTION string, mi map[string]string) error

func (*EventsSkews) DeactiveEvents

func (s *EventsSkews) DeactiveEvents(o *BillOpts, mi map[string]string) error

func (*EventsSkews) PushSkews

func (s *EventsSkews) PushSkews(mi map[string]string, skew_action string) error

func (*EventsSkews) SkewsQuotaUnpaid

func (s *EventsSkews) SkewsQuotaUnpaid(o *BillOpts, mi map[string]string) error

type Name

type Name struct {
	FirstName string `json:"first_name" cql:"first_name"`
	LastName  string `json:"last_name" cql:"last_name"`
}

type Organization

type Organization struct {
	Id         string `json:"id" cql:"id"`
	AccountsId string `json:"accounts_id" cql:"accounts_id"`
	CreatedAt  string `json:"created_at" cql:"created_at"`
	JsonClaz   string `json:"json_claz" cql:"json_claz"`
	Name       string `json:"name" cql:"name"`
}

func AccountsOrg

func AccountsOrg(email string, m map[string]string) (*Organization, error)

type Password

type Password struct {
	Password            string `json:"password" cql:"password"`
	PasswordResetKey    string `json:"password_reset_key" cql:"password_reset_key"`
	PasswordResetSentAt string `json:"password_reset_sent_at" cql:"password_reset_sent_at"`
}

type Phone

type Phone struct {
	Phone         string `json:"phone" cql:"phone"`
	PhoneVerified string `json:"phone_verified" cql:"phone_verified"`
}

type States

type States struct {
	Authority string `json:"authority" cql:"authority"`
	Active    string `json:"active" cql:"active"`
	Blocked   string `json:"blocked" cql:"blocked"`
	Staged    string `json:"staged" cql:"staged"`
}

type Suspend

type Suspend struct {
	Suspended     string `json:"suspended" cql:"suspended"`
	SuspendedAt   string `json:"suspended_at" cql:"suspended_at"`
	SuspendedTill string `json:"suspended_till" cql:"suspended_till"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL