TrueWallet

package module
v0.0.0-...-5e4054a Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2019 License: MIT Imports: 16 Imported by: 6

README

TrueWalletAPI


Installation

go get github.com/ATTHDEV/TrueWallet/


Example01

package main

import (
	"fmt"

	TrueWallet "github.com/ATTHDEV/TrueWallet-API"
)

func main() {

	mobileTracking, _ := TrueWallet.GenerateRandomString(40)
	wallet, err := TrueWallet.New("xxxxxxxxxx", "xxxx", "email", mobileTracking) //put you email and password
	if err != nil {
		panic(err)
	}
	ref, err := wallet.GetOtp()
	if err != nil {
		panic(err)
	}
	wallet.ConfirmOtp("You mobile number", "You OTP", ref)

	// if you confirm otp , you will have reference token
	fmt.Println(wallet.ReferenceToken)

	// now you can fetch data from you wallet..

	fmt.Println("this is last 100 transaction for today")
	fmt.Println(wallet.GetTransaction(100))
}


Example02

package main

import (
	"fmt"

	TrueWallet "github.com/ATTHDEV/TrueWallet-API"
)

func main() {

	// in example1 you have mobileTracking and ReferencToken
	// you will use it aways
	mobileTracking := "xxxxx" // frome example01
	refToken := "xxxxx"       // frome example01 , after confirm OTP

	wallet, err := TrueWallet.New("xxxxxxxxxx", "xxxx", "email", mobileTracking) //put you email and password
	wallet.SetReferenceToken(refToken)
	if err != nil {
		panic(err)
	}

	fmt.Println("this is activities for 0812345678 from 2018-12-01 to 2018-12-02")
	fmt.Println(wallet.GetActivities("0812345678", "2018-12-01", "2018-12-02"))
}


License

MIT license.


Documentation

Overview

author ATTH

Index

Constants

View Source
const (
	RequestError = 1
	LoginError   = 2
	TokenError   = 3
	UnknownError = 4
	OtpError     = 5
)
View Source
const (
	StatusSuccess = 1
	StatusFail    = 0
)

Variables

This section is empty.

Functions

func CreateSignature

func CreateSignature(msg string) string

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

func GenerateRandomString

func GenerateRandomString(s int) (string, error)

func New

func New(id, password, loginType string, options ...interface{}) (*Wallet, *Error)

func TimestampString

func TimestampString() string

Types

type Activity

type Activity struct {
	ReportID string `json:"report_id"`
	Date     string `json:"date_time"`
	Money    string `json:"amount"`
	Phone    string `json:"sub_title"`
	Action   string `json:"original_action"`
}

type Data

type Data struct {
	Data string `json:"data"`
}

type Error

type Error struct {
	Code    int
	Message string
}

func NewError

func NewError(code int, message string) *Error

type Profile

type Profile struct {
	Code string `json:"code"`
	Data struct {
		Occupation         string `json:"occupation"`
		Birthdate          string `json:"birthdate"`
		TmnID              string `json:"tmnId"`
		MobileNumber       string `json:"mobileNumber"`
		CurrentBalance     string `json:"currentBalance"`
		ProfileImageStatus string `json:"profileImageStatus"`
		LastnameEn         string `json:"lastnameEn"`
		HasPassword        bool   `json:"hasPassword"`
		Title              string `json:"title"`
		ThaiID             string `json:"thaiId"`
		ProfileType        string `json:"profileType"`
		FirstnameEn        string `json:"firstnameEn"`
		AddressList        []struct {
			AddressID  int    `json:"addressID"`
			Address    string `json:"address"`
			Province   string `json:"province"`
			PostalCode string `json:"postalCode"`
		} `json:"addressList"`
		ImageURL string `json:"imageURL"`
		Fullname string `json:"fullname"`
		Email    string `json:"email"`
	} `json:"data"`
}

type Report

type Report struct {
	Code string `json:"code"`
	Data struct {
		ServiceType string  `json:"service_type"`
		Amount      float64 `json:"amount"`
		Section2    struct {
			Column1 struct {
				Cell1 struct {
					Title string `json:"title"`
					Value string `json:"value"`
				} `json:"cell1"`
				Cell2 struct {
					Title string `json:"title"`
					Value string `json:"value"`
				} `json:"cell2"`
			} `json:"column1"`
		} `json:"section2"`
		Section4 struct {
			Column1 struct {
				Cell1 struct {
					Title string `json:"title"`
					Value string `json:"value"`
				} `json:"cell1"`
			} `json:"column1"`
			Column2 struct {
				Cell1 struct {
					Title string `json:"title"`
					Value string `json:"value"`
				} `json:"cell1"`
			} `json:"column2"`
		} `json:"section4"`
	} `json:"data"`
}

type Transaction

type Transaction struct {
	Code string `json:"code"`
	Data struct {
		Total      int        `json:"total"`
		TotalPage  int        `json:"total_page"`
		Activities []Activity `json:"activities"`
	} `json:"data"`
}

type Wallet

type Wallet struct {
	MobileTracking string
	DeviceID       string
	AccessToken    string
	ReferenceToken string
	Headers        map[string]string
	// contains filtered or unexported fields
}

func (*Wallet) ClearToken

func (w *Wallet) ClearToken()

func (*Wallet) ConfirmOtp

func (w *Wallet) ConfirmOtp(phone, otp, ref string) *Error

func (*Wallet) GetActivities

func (w *Wallet) GetActivities(options ...interface{}) ([]Activity, *Error)

func (*Wallet) GetBalance

func (w *Wallet) GetBalance() (string, *Error)

func (*Wallet) GetLastTransfer

func (w *Wallet) GetLastTransfer(phone string, money float32, options ...interface{}) (*Activity, *Error)

func (*Wallet) GetOtp

func (w *Wallet) GetOtp() (string, *Error)

func (*Wallet) GetProfile

func (w *Wallet) GetProfile() (*Profile, *Error)

func (*Wallet) GetRawTransaction

func (w *Wallet) GetRawTransaction(options ...interface{}) []byte

func (*Wallet) GetReport

func (w *Wallet) GetReport(id string) (*Report, *Error)

func (*Wallet) GetTransaction

func (w *Wallet) GetTransaction(options ...interface{}) (*Transaction, *Error)

func (*Wallet) Login

func (w *Wallet) Login() *Error

func (*Wallet) SetReferenceToken

func (w *Wallet) SetReferenceToken(token string)

func (*Wallet) TopupMoney

func (w *Wallet) TopupMoney(cashcard string) ([]byte, *Error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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