client

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(endpoint, apiKey string) (_ api.Service, err error)

New creates a new API v1 client that implements the Service interface.

Types

type APIv1

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

APIv1 implements the Service interface

func (*APIv1) DeleteShortURL

func (c *APIv1) DeleteShortURL(ctx context.Context, id string) (err error)

func (*APIv1) Do

func (s *APIv1) Do(req *http.Request, data interface{}, checkStatus bool) (rep *http.Response, err error)

Do executes an http request against the server, performs error checking, and deserializes the response data into the specified struct.

func (*APIv1) NewRequest

func (s *APIv1) NewRequest(ctx context.Context, method, path string, data interface{}, params *url.Values) (req *http.Request, err error)

func (*APIv1) ShortURLInfo

func (c *APIv1) ShortURLInfo(ctx context.Context, id string) (out *api.ShortURL, err error)

func (*APIv1) ShortURLList added in v1.1.0

func (c *APIv1) ShortURLList(ctx context.Context, page *api.PageQuery) (out *api.ShortURLList, err error)

func (*APIv1) ShortenURL

func (c *APIv1) ShortenURL(ctx context.Context, in *api.LongURL) (out *api.ShortURL, err error)

func (*APIv1) Status

func (c *APIv1) Status(ctx context.Context) (out *api.StatusReply, err error)

func (*APIv1) Updates added in v1.1.0

func (c *APIv1) Updates(ctx context.Context, id string) (_ <-chan *api.Click, err error)

TODO: figure out how to gracefully close the connection!

type StatusError

type StatusError struct {
	StatusCode int
	Reply      api.Reply
}

StatusError decodes an error response from the Service

func (*StatusError) Error

func (e *StatusError) Error() string

Jump to

Keyboard shortcuts

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