models

package
v0.0.0-...-f154cc1 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2017 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusPending = "PENDING"
	StatusFailed  = "FAILED"
	StatusSuccess = "SUCCESS"
	Credit        = "credit"
	Debit         = "debit"
)

Variables

View Source
var ErrInvalidTransactionType error = errors.New("Invalid transaction type")

Functions

func DoesUserExist

func DoesUserExist(query map[string]interface{}) (bool, error)

func Setup

func Setup() error

Types

type Transaction

type Transaction struct {
	Id           int       `json:"id"`
	CreatedAt    time.Time `json:"createdAt"`
	UpdatedAt    time.Time `json:"updatedAt"`
	CompletedAt  time.Time `json:"completedAt"`
	Amount       float64   `json:"amount"`
	Type         string    `json:"type"`
	MNO          string    `json:"mno"`
	Reference    string    `json:"reference"`
	Message      string    `json:"message"`
	MobileNumber string    `json:"mobileNumber"`
	ReceiveToken string    `json:"receiveToken"`
	NetworkID    string    `json:"networkID"`
	Status       string    `json:"status"`
	ReferenceID  string    `json:"referenceID"`
	UserID       int       `json:"userID"`
}

func CreateTransaction

func CreateTransaction(paymentRequest payments.MPaymentRequest, typeOfTrx string, user *User) (*Transaction, error)

func GetUserTransactions

func GetUserTransactions(userID int) ([]Transaction, error)

func (*Transaction) GetTransaction

func (trx *Transaction) GetTransaction(queryParam map[string]interface{}) error

func (*Transaction) Update

func (trx *Transaction) Update() error

func (*Transaction) Validate

func (trx *Transaction) Validate() error

type User

type User struct {
	ID              int
	EmailAddress    string
	Password        string
	PasswordHash    string
	Token           string
	CallbackURL     string
	CurrentBalance  float64
	MobileNumber    string
	NetworkOperator string
	CreatedAt       time.Time
	UpdatedAt       time.Time
	Transactions    []Transaction `gorm:"ForeignKey:UserID"`
}

func CreateUser

func CreateUser(user *payloads.User) (*User, error)

func (*User) GetUser

func (u *User) GetUser(query map[string]interface{}) error

func (*User) Update

func (u *User) Update() error

Jump to

Keyboard shortcuts

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