csapi

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: MIT Imports: 5 Imported by: 0

README

csapi-go

PkgGoDev Codacy Badge codecov test

Go client package for the CSApi (API for certified-senders.org)

Usage

Import the lib as usual

import "go.bnck.me/csapi"

Then create a new client. The login will be handled automatically. You will get a authenticated client.

api, err := csapi.NewWithOptions(csapi.WithCredentials("abc12", "abc-123"))
if err != nil {
    return err
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIEndpoint

type APIEndpoint string

APIEndpoint represents a api endpoint

const (
	// APIEndpointProduction Production API endpoint
	APIEndpointProduction APIEndpoint = "https://monitor.certified-senders.org/api/v1"
	// APIEndpointBeta Beta API endpoint
	APIEndpointBeta APIEndpoint = "https://monitor-beta.certified-senders.org/api/v1"
)

type Client

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

Client represents the main client

func New

func New(apiName, apiKey string) (*Client, error)

New creates a new Client with APIUrl and APIKey

func NewWithClient

func NewWithClient(httpClient *http.Client, apiName, apiKey string) (*Client, error)

NewWithClient creates a new Client with a given http.Client

func NewWithOptions

func NewWithOptions(options ...ClientOption) (*Client, error)

NewWithOptions creates a new Client with given options

func (*Client) Stat

func (c *Client) Stat() stat.Client

Stat returns a client related to stats

type ClientOption

type ClientOption func(*Client)

ClientOption options for creating the client

func WithAPIEndpoint

func WithAPIEndpoint(api APIEndpoint) ClientOption

WithAPIEndpoint supplies a API Endpoint to be used

func WithCredentials

func WithCredentials(apiName, apiKey string) ClientOption

WithCredentials supplies the api credentials

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ClientOption

WithHTTPClient supplies a already created http.Client

func WithLogger

func WithLogger(logger *zerolog.Logger) ClientOption

WithLogger supplies a logger for the transport client

Directories

Path Synopsis
apis
internal

Jump to

Keyboard shortcuts

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