core

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 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. Such a token is required for some API calls like payment status or create payment.

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 is the URL to the production service.
	ProductionBaseURL BaseURL = "https://api.nowpayments.io/v1"
	// SandBoxBaseURL is the URL to the sandbox service.
	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
	// JWT token obtained after authentication.
	Token string
}

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

Jump to

Keyboard shortcuts

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