localbitcoins

package
v0.0.0-...-5aedeac Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2016 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool is a helper function that allocates a new bool value to store v and returns a pointer to it.

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.

func Float

func Float(v float64) *float64

Float is a helper function that allocates a new float64 value to store v and returns a pointer to it.

func Int

func Int(v int) *int

Int is a helper function that allocates a new int32 value to store v and returns a pointer to it, but unlike Int32 its argument value is an int.

func String

func String(v string) *string

String is a helper function that allocates a new string value to store v and returns a pointer to it.

func Stringify

func Stringify(message interface{}) string

Stringify attempts to create a reasonable string representation of types in the GitHub library. It does things like resolve pointers to their values and omits struct fields with nil values.

Types

type Account

type Account struct {
	Username                  *string `json:"username,omitempty"`
	TradingPartnersCount      *int    `json:"trading_partners_count,omitempty"`
	FeedbacksUnconfirmedCount *int    `json:"feedbacks_unconfirmed_count,omitempty"`
	TradeVolumeText           *string `json:"trade_volume_text,omitempty"`
	HasCommonTrades           *bool   `json:"has_common_trades,omitempty"`
	ConfirmedTradeCountText   *string `json:"confirmed_trade_count_text,omitempty"`
	BlockedCount              *int    `json:"blocked_count,omitempty"`
	FeedbackCount             *int    `json:"feedback_count,omitempty"`
	Url                       *string `json:"url,omitempty"`
	TrustedCount              *int    `json:"trusted_count,omitempty"`
}

Account represents a LocalBitcoins account.

func (Account) String

func (a Account) String() string

type AccountsService

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

AccountsService provides access to all account related functions in the LocalBitcoins API.

func (*AccountsService) Get

func (s *AccountsService) Get(account string) (*Account, *Response, error)

Get fetches an account. Passing an empty string will fetch the authenticated account.

type Client

type Client struct {

	// Base URL used for API requests. Must end with a trailing slash.
	BaseURL *url.URL

	// User agent sent when communicating with the LocalBitcoins API.
	UserAgent string

	// Services for talking to different parts of the LocalBitcoins API.
	Accounts *AccountsService
	Escrows  *EscrowsService
	// contains filtered or unexported fields
}

A Client manages communication with the LocalBitcoins API.

func NewClient

func NewClient(httpClient *http.Client) *Client

Returns a new LocalBitcoins API client. If a nil httpClient is provided, http.DefaultClient will be used. To use API methods that require authentication (most, if not all, do), provide an http.Client that will perform the authentication for you (such as that provided by the goauth2 library).

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)

Sends an API request and returns the API response. The API response is decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string,
	body interface{}) (*http.Request, error)

Creates an API request. A relative URl can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type Error

type Error struct {
	Message string `json:"message"`
	Code    int    `json:"error_code"`
}

func (*Error) Error

func (e *Error) Error() string

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response
	Err      Error `json:"error"`
}

An ErrorResponse reports an error caused by an API request.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type Escrow

type Escrow struct {
	CreatedAt             *time.Time `json:"created_at,omitempty"`
	BuyerUsername         *string    `json:"buyer_username,omitempty"`
	ReferenceCode         *string    `json:"reference_code,omitempty"`
	Currency              *string    `json:"currency,omitempty"`
	Amount                *float64   `json:"amount,string,omitempty"`
	AmountBTC             *float64   `json:"amount_btc,string,omitempty"`
	ExchangeRateUpdatedAt *time.Time `json:"exchange_rate_updated_at,omitempty"`
	// contains filtered or unexported fields
}

Escrow represents an escrow as returned by the LocalBitcoins API.

func (Escrow) String

func (e Escrow) String() string

type EscrowsService

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

EscrowsService handles all escrow-related communications with the LocalBitcoins API.

func (*EscrowsService) List

func (s *EscrowsService) List() ([]*Escrow, *Response, error)

type Response

type Response struct {
	*http.Response
}

Response is a LocalBitcoins API response. This wraps the standard http.Response returned from LocalBitcoins and provides convenient access to things like pagination links.

type ResponseData

type ResponseData struct {
	Data    interface{} `json:"data"`
	Actions interface{} `json:"actions"`
}

Represents data as returned by the LocalBitcoins API. Wraps the data and actions objects.

Jump to

Keyboard shortcuts

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