flip

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 License: MIT Imports: 18 Imported by: 0

README

sangu-flip

Flip (flip.id) implementation with GO

Documentation

Index

Constants

View Source
const (
	BankListURL             = "/general/banks"
	BankAccountInquiryURL   = "/disbursement/bank-account-inquiry"
	CurrentBalanceURL       = "/general/balance"
	CheckIsOperationalURL   = "/general/operational"
	CheckIsMaintenanceURL   = "/general/maintenance"
	GetAllDisbursementURL   = "/disbursement"
	GetDisbursementQueueURL = "/disbursement/[trxId]/queue"
	DisburseURL             = "/disbursement"
)
View Source
const (
	APPLICATION_NAME = "sangu-flip"
	LOG_KEY_REQ_ID   = "req_id"
	LOG_KEY_METHOD   = "method"
	LOG_KEY_CALLER   = "caller"
	LOG_LEVEL_TRACE  = "trace"
	LOG_LEVEL_DEBUG  = "debug"
	LOG_LEVEL_INFO   = "info"
	LOG_LEVEL_WARN   = "warn"
	LOG_LEVEL_ERROR  = "error"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Balance added in v0.1.5

type Balance struct {
	Balance int64 `json:"balance"`
}

type Bank added in v0.1.5

type Bank struct {
	BankCode string `json:"bank_code"`
	Name     string `json:"name"`
	Fee      uint32 `json:"fee"`
	Queue    int    `json:"queue"`
	Status   string `json:"status"` // OPERATIONAL, DISTURBED, HEAVILY_DISTURBED
}

type BankAccountInquiry added in v0.1.2

type BankAccountInquiry struct {
	BankCode      string `json:"bank_code"`
	AccountNumber string `json:"account_number"`
	AccountHolder string `json:"account_holder"`
	Status        string `json:"status"`
}

type CheckIsMaintenance added in v0.1.5

type CheckIsMaintenance struct {
	Maintenance bool `json:"maintenance"`
}

type CheckIsOperational added in v0.1.5

type CheckIsOperational struct {
	Operational bool `json:"operational"`
}

type Client

type Client struct {
	BaseURL    string
	UserKey    string
	LogLevel   int
	Logger     Logger
	HTTPOption HTTPOption
}

Client - Bigflip Client data UserKey is base64 BasicAuth

func NewClient

func NewClient() Client

func (*Client) Call

func (c *Client) Call(method, path string, header map[string]string, body io.Reader, v interface{}) (err error, respErr ErrorResponse)

Call the BigFlip API at specific `path` using the specified HTTP `method`. The result will be given to `v` if there is no error. If any error occurred and Bigflip send error response, the result will be error code, error message and data, otherwise only error code and error message

func (*Client) ExecuteRequest

func (c *Client) ExecuteRequest(req *http.Request, v interface{}) (err error, respErr ErrorResponse)

ExecuteRequest : execute request

func (*Client) NewRequest

func (c *Client) NewRequest(method string, fullPath string, headers map[string]string, body io.Reader) (*http.Request, error)

NewRequest : send new request

type CoreGateway

type CoreGateway struct {
	Client Client
}

func (*CoreGateway) Call

func (gateway *CoreGateway) Call(method, path string, header map[string]string, body io.Reader, v interface{}) (err error, respErr ErrorResponse)

func (*CoreGateway) CheckIsMaintenance added in v0.1.5

func (gateway *CoreGateway) CheckIsMaintenance() (resp CheckIsMaintenance, respError ErrorResponse, err error)

func (*CoreGateway) CheckIsOperational added in v0.1.5

func (gateway *CoreGateway) CheckIsOperational() (resp CheckIsOperational, respError ErrorResponse, err error)

func (*CoreGateway) Disburse added in v0.1.5

func (gateway *CoreGateway) Disburse(idempotencyKey string, payload DisbursementRequest) (resp Disbursement, respError ErrorResponse, err error)

func (*CoreGateway) GetAllDisbursement added in v0.1.5

func (gateway *CoreGateway) GetAllDisbursement(perPage int, page int) (resp GetAllDisbursement, respError ErrorResponse, err error)

func (*CoreGateway) GetBankAccountInquiry added in v0.1.3

func (gateway *CoreGateway) GetBankAccountInquiry(bankCode string, accountNumber string) (resp BankAccountInquiry, respError ErrorResponse, err error)

func (*CoreGateway) GetBanks

func (gateway *CoreGateway) GetBanks(bankCode string) (resp []Bank, respError ErrorResponse, err error)

func (*CoreGateway) GetCurrentBalance added in v0.1.5

func (gateway *CoreGateway) GetCurrentBalance() (resp Balance, respError ErrorResponse, err error)

func (*CoreGateway) GetDisbursementInfo added in v0.1.5

func (gateway *CoreGateway) GetDisbursementInfo(trxId int) (resp Disbursement, respError ErrorResponse, err error)

func (*CoreGateway) GetDisbursementQueue added in v0.1.5

func (gateway *CoreGateway) GetDisbursementQueue(trxId int) (resp DisbursementQueue, respError ErrorResponse, err error)

type Disbursement added in v0.1.5

type Disbursement struct {
	ID            uint32  `json:"id"`
	UserID        uint32  `json:"user_id"`
	Amount        uint32  `json:"amount"`
	Status        string  `json:"status"`    // PENDING, CANCELLED, DONE
	Timestamp     string  `json:"timestamp"` // (Format: YYYY-MM-DD H:i:s)
	BankCode      string  `json:"bank_code"`
	AccountNumber string  `json:"account_number"`
	RecipientName string  `json:"recipient_name"`
	SenderBank    string  `json:"sender_bank"`
	Remark        string  `json:"remark"`
	Receipt       string  `json:"receipt"`
	TimeServed    string  `json:"time_served"` // Will only show valid value when the status is DONE (Format: YYYY-MM-DD H:i:s)
	BundleID      uint32  `json:"bundle_id"`
	CompanyID     uint32  `json:"company_id"`
	RecipientCity uint32  `json:"recipient_city"`
	CreatedFrom   string  `json:"created_from"`
	Direction     string  `json:"direction"`
	Sender        *Sender `json:"sender"`
	Fee           uint32  `json:"fee"`
}

type DisbursementError added in v0.1.5

type DisbursementError struct {
	Code   string            `json:"code"`
	Errors []ValidationError `json:"errors"`
}

type DisbursementQueue added in v0.1.5

type DisbursementQueue struct {
	Queue uint32 `json:"queue"`
}

type DisbursementRequest added in v0.1.5

type DisbursementRequest struct {
	AccountNumber string `json:"account_number" url:"account_number" valid:"required"`
	BankCode      string `json:"bank_code" url:"bank_code" valid:"required"`
	Amount        uint32 `json:"amount" url:"amount" valid:"required"`
	Remark        string `json:"remark" url:"remark"`
	RecipientCity uint32 `json:"recipient_city" url:"recipient_city"`
}

type ErrorResponse added in v0.1.5

type ErrorResponse struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Error   interface{} `json:"error,omitempty"`
}

type GeneralErrorResponse added in v0.1.7

type GeneralErrorResponse struct {
	Name    string `json:"name"`
	Message string `json:"message"`
	Code    int    `json:"code"`
	Status  int    `json:"status"`
	Type    string `json:"type"`
}

type GetAllDisbursement added in v0.1.5

type GetAllDisbursement struct {
	TotalData   uint32         `json:"total_data"`
	DataPerPage uint32         `json:"data_per_page"`
	TotalPage   uint32         `json:"total_page"`
	Page        uint32         `json:"page"`
	Data        []Disbursement `json:"data"`
}

type HTTPOption added in v0.1.5

type HTTPOption struct {
	Timeout           time.Duration
	BackoffInterval   time.Duration
	MaxJitterInterval time.Duration
	RetryCount        int
}

HTTPOption for heimdall properties

type LogOption added in v0.2.0

type LogOption struct {
	Format          string
	Level           string
	TimestampFormat string
	CallerToggle    bool
	Pretty          bool
}

type Logger added in v0.2.0

type Logger struct {
	// contains filtered or unexported fields
}

func NewLogger added in v0.2.0

func NewLogger(option LogOption) *Logger

func (*Logger) Ctx added in v0.2.0

func (l *Logger) Ctx(ctx context.Context) *Logger

func (*Logger) Debug added in v0.2.0

func (l *Logger) Debug(format string, v ...interface{})

func (*Logger) Error added in v0.2.0

func (l *Logger) Error(format string, v ...interface{})

func (*Logger) Info added in v0.2.0

func (l *Logger) Info(format string, v ...interface{})

func (*Logger) Method added in v0.2.0

func (l *Logger) Method(name string) *Logger

func (*Logger) Str added in v0.2.0

func (l *Logger) Str(key string, val string) *Logger

func (*Logger) Trace added in v0.2.0

func (l *Logger) Trace(format string, v ...interface{})

func (*Logger) Warn added in v0.2.0

func (l *Logger) Warn(format string, v ...interface{})

type Sender added in v0.1.5

type Sender struct {
	SenderName           string `json:"sender_name"`
	PlaceOfBirth         uint32 `json:"place_of_birth"`
	DateOfBirth          string `json:"date_of_birth"` // (Format: YYYY-MM-DD)
	Address              string `json:"address"`
	SenderIdentityType   string `json:"sender_identity_type"`
	SenderIdentityNumber string `json:"sender_identity_number"`
	SenderCountry        int16  `json:"sender_country"`
	Job                  string `json:"babu"`
}

type ValidationError added in v0.1.5

type ValidationError struct {
	Attribute string `json:"attribute"`
	Code      uint16 `json:"code"`
	Message   string `json:"message"`
}

Jump to

Keyboard shortcuts

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