utils

package module
v0.0.0-...-822d38c Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2020 License: MIT Imports: 3 Imported by: 6

README

Welcome to OKCommon

The purpose of OKCommon is to provide a place to factor out certain OKEx related bits o' goodness, such as error messages, that are of interest to more than one other project.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExpectedResponseHeaders = map[string]string{
	"Cache-Control":                "",
	"Content-Length":               "",
	"Content-Type":                 "",
	"Date":                         "",
	"Expires":                      "",
	"Set-Cookie":                   "",
	"Pragma":                       "",
	"Via":                          "",
	"X-Brokerid":                   "",
	"X-Content-Type-Options":       "",
	"X-Frame-Options":              "",
	"X-Kong-Proxy-Latency":         "",
	"X-Kong-Upstream-Latency":      "",
	"X-Ratelimit-Limit-Second":     "",
	"X-Ratelimit-Remaining-Second": "",
	"X-Xss-Protection":             "",
}

Each response should have these headers.

View Source
var ExpectedResponseHeadersB = map[string]string{
	"Cache-Control":           "",
	"Content-Length":          "",
	"Content-Type":            "",
	"Date":                    "",
	"Expires":                 "",
	"Set-Cookie":              "",
	"Pragma":                  "",
	"Via":                     "",
	"X-Brokerid":              "",
	"X-Content-Type-Options":  "",
	"X-Frame-Options":         "",
	"X-Kong-Proxy-Latency":    "",
	"X-Kong-Upstream-Latency": "",
	"X-Xss-Protection":        "",
}

Some responses return all of the above but omit X-Ratelimit*

Functions

func HmacSha256Base64Signer

func HmacSha256Base64Signer(message string, secretKey string) (string, error)

signing a message using: hmac sha256 + base64

eg:
  message = Pre_hash function comment
  secretKey = E65791902180E9EF4510DB6A77F6EBAE
return signed string = TO6uwdqz+31SIPkd4I+9NiZGmVH74dXi+Fd5X0EzzSQ=

Types

type AccountsEntry

type AccountsEntry struct {
	AccountID  string `json:"id"`
	Available  string `json:"available"`
	Balance    string `json:"balance"`
	CurrencyID string `json:"currency"`
	Frozen     string `json:"frozen"`
	Hold       string `json:"hold"`
	Holds      string `json:"holds"`
}

type Credentials

type Credentials struct {
	Key        string `json:"api_key"`
	SecretKey  string `json:"api_secret_key"`
	Passphrase string
	Type       string // read, read-trade, read-withdraw
	UserID     string `json:"user_id"`
}

type CurrenciesEntry

type CurrenciesEntry struct {
	CanDeposit    string `json:"can_deposit"`
	CanWithdraw   string `json:"can_withdraw"`
	CurrencyID    string `json:"currency"`
	Name          string `json:"name"`
	MinWithdrawal string `json:"min_withdrawal"`
}

type DepositAddress

type DepositAddress struct {
	Address    string `json:"address"`
	Tag        string `json:"tag"`
	PaymentID  string `json:"payment_id"`
	Memo       string `json:"memo"`
	CurrencyID string `json:"currency"`
	To         int    `json:"to"`
}

type DepositHistory

type DepositHistory struct {
	Amount     string `json:"amount"`
	TXID       string `json:"txid"`
	CurrencyID string `json:"currency"`
	From       string `json:"from"`
	To         string `json:"to"`
	DepositID  uint32 `json:"deposit_id"`
	Timestamp  string `json:"timestamp"`
	Status     string `json:"status"`
}

type LedgerEntry

type LedgerEntry struct {
	Amount    string
	Balance   string
	Currency  string
	Fee       string
	LedgerID  string `json:"ledger_id"`
	Typename  string
	Timestamp string `json:"timestamp"`
}

type OK500Error

type OK500Error struct {
	ErrorMessage string `json:"error_message"`
	Message      string `json:"message"`
}

5xx error messages

func Err500

func Err500() OK500Error

type OKError

type OKError struct {
	ErrorMessage string `json:"error_message"`
	Code         int    `json:"code"`
	ErrorCode    string `json:"error_code"`
	Message      string `json:"message"`
}

Ordinary 4xx error messages.

func Err30001

func Err30001() OKError

func Err30002

func Err30002() OKError

func Err30003

func Err30003() OKError

func Err30004

func Err30004() OKError

func Err30005

func Err30005() OKError

func Err30006

func Err30006() OKError

func Err30007

func Err30007() OKError

func Err30008

func Err30008() OKError

func Err30012

func Err30012() OKError

func Err30013

func Err30013() OKError

func Err30015

func Err30015() OKError

func Err30023

func Err30023(t string) OKError

func Err30024

func Err30024(t string) OKError

func Err30025

func Err30025(t string) OKError

func Err30031

func Err30031(t string) OKError

func Err30032

func Err30032() OKError

func Err33007

func Err33007() OKError

func Err34002

func Err34002() OKError

func Err34008

func Err34008() OKError

type WalletEntry

type WalletEntry struct {
	Available  string `json:"available"`
	Balance    string `json:"balance"`
	CurrencyID string `json:"currency"`
	Hold       string `json:"hold"`
}

type WithdrawalFee

type WithdrawalFee struct {
	CurrencyID string `json:"currency"`
	MinFee     string `json:"min_fee"`
	MaxFee     string `json:"max_fee"`
}

Jump to

Keyboard shortcuts

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