nfon

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 11 Imported by: 0

README

go-nfon

A go libary for the NFON-API

Installation

go get github.com/Lukas-Nielsen/go-nfon

Usage

import
import "github.com/Lukas-Nielsen/go-nfon"
perform request
// new client
client := nfon.NewClient(<api key>, <api secret>, <api url>, <debug>)

// new request
req := client.NewRequest()

// add options to request
req.AddLink(<href>, <rel>)
req.AddData(<name>, <value>)

// send request
req.Send(<GET|POST|DELETE|PUT>, <api path>, <pointer to result or nil>)

API Reference

NFON

Authors

License

MIT

Documentation

Index

Constants

View Source
const (
	POST   method = "POST"
	PUT    method = "PUT"
	DELETE method = "DELETE"
	GET    method = "GET"

	POST_SUCCESS   int = 201
	PUT_SUCCESS    int = 204
	DELETE_SUCCESS int = 204
	GET_SUCCESS    int = 200
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v0.2.0

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

func NewClient added in v0.2.0

func NewClient(key string, secret string, uri string, debug bool) *Client

param api key, api secret, api uri, debug the requests

func (*Client) GetRequestCount added in v0.3.0

func (c *Client) GetRequestCount() uint

func (*Client) NewRequest added in v0.2.0

func (c *Client) NewRequest() *Request

type Error added in v0.2.0

type Error struct {
	Detail      string   `json:"detail"`
	Title       string   `json:"title"`
	DescribedBy string   `json:"described_by"`
	Errors      []Errors `json:"errors"`
}

func (Error) Log added in v0.2.0

func (e Error) Log()

type Errors added in v0.2.0

type Errors struct {
	Message string `json:"message"`
	Path    string `json:"path"`
	Value   string `json:"value"`
}

type Items added in v0.2.0

type Items struct {
	Href  string
	Links map[string]string
	Data  map[string]any
}

type Request added in v0.2.0

type Request struct {
	Links []links `json:"links,omitempty"`
	Data  []data  `json:"data,omitempty"`
	// contains filtered or unexported fields
}

func (*Request) AddData added in v0.2.0

func (r *Request) AddData(name string, value any) *Request
func (r *Request) AddLink(rel string, href string) *Request

func (*Request) Send added in v0.2.0

func (r *Request) Send(method method, path string, result *Response) (int, Error)

type Response added in v0.2.0

type Response struct {
	Href   string
	Offset int
	Total  int
	Size   int
	Links  map[string]string
	Data   map[string]any
	Items  []Items
}

Jump to

Keyboard shortcuts

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