core

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authenticate

func Authenticate(email, password string) (string, error)

Authenticate is used for obtaining a JWT token. JWT is required only for payout request API call

func HTTPSend

func HTTPSend(p *SendParams) error

HTTPSend sends to endpoint with an optional request body and get the HTTP response result in into

func Status

func Status() (string, error)

Status returns current state of the API. "OK" is returned if everything is fine, otherwise an error message is returned.

func UseBaseURL

func UseBaseURL(b BaseURL)

UseBaseURL sets the base URL to use to connect to NOWPayment's API

func UseClient

func UseClient(s HTTPClient)

UseClient specifies which API server to use.

func WithDebug

func WithDebug(d bool)

WithDebug prints out debugging info about HTTP traffic

Types

type BaseURL

type BaseURL string

BaseURL is the URL to NOWPayment's service

const (
	ProductionBaseURL BaseURL = "https://api.nowpayments.io/v1"
	SandBoxBaseURL            = "https://api-sandbox.nowpayments.io/v1"
)

type HTTPClient

type HTTPClient interface {
	// Do executes the HTTP request to the API server.
	Do(*http.Request) (*http.Response, error)
}

HTTPClient defines methods of an HTTP client.

func NewHTTPClient

func NewHTTPClient() HTTPClient

NewHTTPClient uses the default http.Client.

type SendParams

type SendParams struct {
	Body      io.Reader
	Into      interface{}
	Path      string
	RouteName string
	Values    url.Values
	JWTToken  string
}

SendParams are parameters needed to build and send an HTTP request to the service

type V2ResponseFormat added in v1.0.1

type V2ResponseFormat[T interface{}] struct {
	Result T `json:"result"`
}

V2ResponseFormat handle some inconsistency on their side some response are at root level, sometimes in data (list only) and sometimes under result key because of many result format, we use generics to instantiate the struct with the correct response format

Jump to

Keyboard shortcuts

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