coingate

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: MIT Imports: 8 Imported by: 1

README

Golang client for CoinGate exchange rate API

Go Reference Test codecov

Golang client for the CoinGate Exchange Rate API.

Example

First, ensure the library is installed and up to date by running

go get -u github.com/ivanglie/go-coingate-client

This is a very simple app that just displays US Dollar to Chinese Yuan Renminbi conversion.

package main

import (
	"fmt"
	"time"

	coingate "github.com/ivanglie/go-coingate-client"
)

func main() {
	client := coingate.NewClient()
	rate, err := client.GetRate("USD", "CNY")
	if err != nil {
		panic(err)
	}
	fmt.Println(rate)
}

See main.go.

References

For more information check out the following links:

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debug = false

Debug mode If this variable is set to true, debug mode activated for the package

Functions

func SetLogger

func SetLogger(logger Logger) error

SetLogger specifies the logger that the package should use.

Types

type Client

type Client interface {
	GetRate(from, to string) (float64, error)
	SetFetchFunction(FetchFunction)
}

Client is the interface for the rates service.

func NewClient

func NewClient() Client

NewClient creates a new rates service instance.

type Error

type Error struct {
	Message string `json:"message"`
	Reason  string `json:"reason"`
}

CoinGate API error responses Response example:

{
  "message": "Not found App by Access-Key",
  "reason": "BadCredentials"
}

See https://developer.coingate.com/docs/common-errors

type FetchFunction

type FetchFunction func(url string) (resp *http.Response, err error)

FetchFunction is a function that mimics http.Get() method.

type Logger

type Logger interface {
	Println(v ...interface{})
	Printf(format string, v ...interface{})
}

Logger is an interface that represents the required methods to log data.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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