api

package module
Version: v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2021 License: BSD-3-Clause Imports: 11 Imported by: 2

README

go-brooklynintegers-api

Go package for the Brooklyn Integers API.

Install

You will need to have both Go and the make programs installed on your computer. Assuming you do just type:

make tools

All of this package's dependencies are bundled with the code in the vendor directory.

Usage

Simple

package main

import (
	"fmt"
	"github.com/aaronland/go-brooklynintegers-api"
)

func main() {

	client := api.NewAPIClient()
	i, _ := client.CreateInteger()

	fmt.Println(i)
}

Less simple

import (
       "fmt"
       "github.com/aaronland/go-brooklynintegers-api"
)

func main() {

	client := api.NewAPIClient()

	params := url.Values{}
	method := "brooklyn.integers.create"

	rsp, _ := client.ExecuteMethod(method, &params)
	i, _ := rsp.Int()

	fmt.Println(i)
}

Tools

int

Mint one or more Brooklyn Integers.

$> ./bin/int -h
Usage of ./bin/int:
  -count int
    	The number of Brooklyn Integers to mint (default 1)
proxy-server

This tool has been moved to the go-brooklynintegers-proxy package.

See also

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAPIClient

func NewAPIClient() artisanalinteger.Client

Types

type APIClient

type APIClient struct {
	artisanalinteger.Client
	BrooklynIntegersClient // see above

	Scheme   string
	Host     string
	Endpoint string
	// contains filtered or unexported fields
}

func (*APIClient) CreateInteger

func (client *APIClient) CreateInteger() (int64, error)

func (*APIClient) ExecuteMethod

func (client *APIClient) ExecuteMethod(method string, params *url.Values) (*APIResponse, error)

func (*APIClient) NextInt

func (client *APIClient) NextInt() (int64, error)

type APIError

type APIError struct {
	Code    int64
	Message string
}

func (*APIError) Error

func (e *APIError) Error() string

type APIResponse

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

func (*APIResponse) Error

func (rsp *APIResponse) Error() error

func (*APIResponse) Int

func (rsp *APIResponse) Int() (int64, error)

func (*APIResponse) Ok

func (rsp *APIResponse) Ok() (bool, error)

func (*APIResponse) Stat

func (rsp *APIResponse) Stat() string

type BrooklynIntegersClient

type BrooklynIntegersClient interface {
	CreateInteger() (int64, error)
	ExecuteMethod(string, *url.Values) (*APIResponse, error)
}

Source Files

Directories

Path Synopsis
cmd
int

Jump to

Keyboard shortcuts

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