luno

package module
v0.0.0-...-b2ec78d Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

README

luno-go

Unofficial Go library for luno.io

The API is not yet stable, as I have not yet tried to build an app with it yet. But the core operations seem to work correctly.

Status

GoDoc Build Status Coverage Status Go Report Card

License

Apache 2.0

Documentation

Index

Constants

View Source
const (
	ErrCodeIncorrectPassword = "incorrect_password"
	ErrCodeUserClosed        = "user_closed"
	ErrCodeSessionNotFound   = "session_not_found"
)

Error Codes used by Luno - https://luno.io/docs/errors

Variables

View Source
var ErrNotImplemented = fmt.Errorf("not implemented")

ErrNotImplemented is returned for any API method not yet implemented

Log allows an application to provie a custom logger for logging care must be taken, as logs may contain sensitive information

View Source
var LogRequestBody = false

LogRequestBody allows you to log the body of every HTTP request

View Source
var LogRequestURL = false

LogRequestURL allows you to log the URL of every HTTP request

View Source
var LogResponseBody = false

LogResponseBody allows you to log every HTTP response body

View Source
var LogResponseCode = false

LogResponseCode allows you to log every HTTP response code

Functions

func IsErrorCode

func IsErrorCode(err error, code string) bool

IsErrorCode checks is an error was a luno error with the matching code

func ParseError

func ParseError(resp *http.Response) error

ParseError parses a Luno error from an HTTP response

func ParseLogin

func ParseLogin(resp *http.Response) (*User, *Session, error)

ParseLogin parses a login response (User and Session) from an HTTP response

Types

type APIAuth

type APIAuth struct {
	Entity
	UserID  string      `json:"user_id,omitempty"`
	Key     string      `json:"key,omitempty"`
	Secret  string      `json:"secret,omitempty"`
	Created string      `json:"created,omitempty"`
	Details interface{} `json:"details,omitempty"`
	User    *User       `json:"user,omitempty"`
}

APIAuth represents the Luno API Authetication - https://luno.io/docs#api_authentication

func ParseAPIAuth

func ParseAPIAuth(resp *http.Response) (*APIAuth, error)

ParseAPIAuth parses an APIAuth out of an HTTP response

func (*APIAuth) MarshalForUpdate

func (a *APIAuth) MarshalForUpdate() ([]byte, error)

MarshalForUpdate exports only the fields suitable for update

type APIAuthFilter

type APIAuthFilter struct {
	UserID string `json:"user_id"`
}

APIAuthFilter allows you tou filter ApiAuth objects

type APIAuths

type APIAuths struct {
	Entity
	List []*APIAuth `json:"list"`
	Page Page       `json:"page"`
}

APIAuths represents a list of ApiAuth objects

func ParseAPIAuths

func ParseAPIAuths(resp *http.Response) (*APIAuths, error)

ParseAPIAuths extracts APIAuths from an HTTP response

type Account

type Account struct {
	Entity
	Email     string `json:"email"`
	Name      string `json:"name"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	UserName  string `json:"username"`
	Created   string `json:"created"`
	Closed    string `json:"closed"`
}

Account represents the Luno Account - https://luno.io/docs#account

func ParseAccount

func ParseAccount(resp *http.Response) (*Account, error)

ParseAccount parses an Account out of an HTTP response

func (*Account) MarshalForUpdate

func (a *Account) MarshalForUpdate() ([]byte, error)

MarshalForUpdate exports only those fields suitable for an update operation

type Client

type Client struct {
	Users     *usersClient
	Events    *eventsClient
	Sessions  *sessionsClient
	APIAuth   *apiAuthClient
	Analytics *analyticsClient
	Account   *accountClient
	// contains filtered or unexported fields
}

Client is a Luno Client - https://luno.io/docs/libraries

func NewClient

func NewClient(apiKey, secretKey string) *Client

NewClient builds a new client with the provided API key and secret key

type Entity

type Entity struct {
	Type string `json:"type,omitempty"`
	ID   string `json:"id,omitempty"`
	URL  string `json:"url,omitempty"`
}

Entity contains fields common to many Luno entities

type EntityAggregate

type EntityAggregate map[string]int

EntityAggregate represents a response containing aggregte information about an entitites, Users, Sessions, Events

func ParseEntityAggregate

func ParseEntityAggregate(resp *http.Response) (EntityAggregate, error)

ParseEntityAggregate parses an EntityAggregate out of an HTTP response

type Error

type Error struct {
	Code        string      `json:"code"`
	Message     string      `json:"message"`
	Description string      `json:"description"`
	Status      int         `json:"status"`
	Extra       interface{} `json:"extra"`
}

Error represents all the information in a Luno Error

func (*Error) Error

func (l *Error) Error() string

type Event

type Event struct {
	Entity
	UserID    string      `json:"user_id,omitempty"`
	Timestamp string      `json:"timestamp,omitempty"`
	Name      string      `json:"name,omitempty"`
	Details   interface{} `json:"details,omitempty"`
	User      *User       `json:"user,omitempty"`
}

Event represents a Luno Event - https://luno.io/docs#events

func ParseEvent

func ParseEvent(resp *http.Response) (*Event, error)

ParseEvent parses an Event out of an HTTP response

func (*Event) MarshalForUpdate

func (e *Event) MarshalForUpdate() ([]byte, error)

MarshalForUpdate exports the event fields suitable for an update operation

type EventAggregate

type EventAggregate struct {
	Entity
	Name  string `json:"name"`
	Count int    `json:"count"`
	Last  string `json:"last"`
}

EventAggregate represents aggregate information about an Event

type EventAggregates

type EventAggregates struct {
	List []*EventAggregate `json:"list"`
}

EventAggregates contains a list of EventAggregate

func ParseEventAggregates

func ParseEventAggregates(resp *http.Response) (*EventAggregates, error)

ParseEventAggregates parses EventAggregates out of an HTTP response

type EventFilter

type EventFilter struct {
	Name   string `json:"name"`
	UserID string `json:"user_id"`
}

EventFilter lets you filter events

type Events

type Events struct {
	Entity
	List []*Event `json:"list"`
	Page Page     `json:"page"`
}

Events represents a list of Event objects

func ParseEvents

func ParseEvents(resp *http.Response) (*Events, error)

ParseEvents parses Events out of an HTTP response

type EventsTimeline

type EventsTimeline struct {
	Timeline []*TimelineEntry `json:"timeline"`
	Total    int              `json:"total"`
}

EventsTimeline represents a list of TimelineEntry objects

func ParseEventsTimeline

func ParseEventsTimeline(resp *http.Response) (*EventsTimeline, error)

ParseEventsTimeline parses an EventsTimeline out of an HTTP response

type Login

type Login struct {
	ID       string   `json:"id,omitempty"`
	Email    string   `json:"email,omitempty"`
	Username string   `json:"username,omitempty"`
	Login    string   `json:"username,omitempty"`
	Password string   `json:"password,omitempty"`
	Session  *Session `json:"session,omitempty"`
}

Login represents information used to log in to the system

func (*Login) MarshalJSON

func (l *Login) MarshalJSON() ([]byte, error)

MarshalJSON converts a Login to JSON

type Page

type Page struct {
	Next Entity `json:"next"`
	Prev Entity `json:"prev"`
}

Page contains fields in results related to paging

type Paging

type Paging struct {
	From  string `json:"from"`
	To    string `json:"to"`
	Limit int    `json:"limit"`
}

Paging contains request options related to paging

func (*Paging) Params

func (p *Paging) Params() url.Values

Params converts Paging struct into HTTP request params

type Range

type Range struct {
	From string `json:"from"`
	To   string `json:"to"`
}

Range represents a date range

type Session

type Session struct {
	Entity
	UserID      string      `json:"user_id,omitempty"`
	Key         string      `json:"key,omitempty"`
	Created     string      `json:"created,omitempty"`
	Expires     string      `json:"expires,omitempty"`
	LastAccess  string      `json:"last_access,omitempty"`
	AccessCount int         `json:"access_count,omitempty"`
	IP          string      `json:"ip,omitempty"`
	UserAgent   string      `json:"user_agent,omitempty"`
	Details     interface{} `json:"details,omitempty"`
	User        *User       `json:"user,omitempty"`
}

Session represents a Luno session - https://luno.io/docs#sessions

func ParseSession

func ParseSession(resp *http.Response) (*Session, error)

ParseSession parses a Session out of an HTTP response

func (*Session) MarshalForUpdate

func (s *Session) MarshalForUpdate(includeKey bool) ([]byte, error)

MarshalForUpdate exports only the Session fields suitable for an update operation

type SessionFilter

type SessionFilter struct {
	UserID string `json:"user_id"`
}

SessionFilter lets you filter session

type Sessions

type Sessions struct {
	Entity
	List []*Session `json:"list"`
	Page Page       `json:"page"`
}

Sessions represents a list of Session objects

func ParseSessions

func ParseSessions(resp *http.Response) (*Sessions, error)

ParseSessions parses Sessions out of an HTTP response

type TimelineEntry

type TimelineEntry struct {
	Timestamp string `json:"timestamp"`
	Range     *Range `json:"range"`
	Count     int
}

TimelineEntry represents an point on a Timeline

type TimelineFilter

type TimelineFilter struct {
	Distinct   bool   `json:"distinct"`
	From       string `json:"from"`
	To         string `json:"to"`
	Group      string `json:"group"`
	Name       string `json:"name"`
	RoundRange bool   `json:"round_range"`
	UserID     string `json:"user_id"`
}

TimelineFilter allows you to filter items returned from an Event Timeline

func (*TimelineFilter) Params

func (t *TimelineFilter) Params() url.Values

Params converts a TimelineFilter into HTTP URL parameters

type User

type User struct {
	Entity
	Email     string      `json:"email,omitempty"`
	UserName  string      `json:"username,omitempty"`
	Name      string      `json:"name,omitempty"`
	FirstName string      `json:"first_name,omitempty"`
	LastName  string      `json:"last_name,omitempty"`
	Created   string      `json:"created,omitempty"`
	Closed    string      `json:"closed,omitempty"`
	Password  string      `json:"password,omitempty"`
	Profile   interface{} `json:"profile,omitempty"`
}

User represents a Luno User - https://luno.io/docs#users

func ParseUser

func ParseUser(resp *http.Response) (*User, error)

ParseUser parses a User out of an HTTP response

func (*User) MarshalForUpdate

func (u *User) MarshalForUpdate() ([]byte, error)

MarshalForUpdate exports only the User fields suitable for an update operation

type Users

type Users struct {
	Entity
	List []*User `json:"list"`
	Page Page    `json:"page"`
}

Users represents a list of User objects

func ParseUsers

func ParseUsers(resp *http.Response) (*Users, error)

ParseUsers parses Users out of an HTTP response

Jump to

Keyboard shortcuts

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