api

package
v0.0.0-...-e8f4e09 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2016 License: MIT Imports: 19 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadRequest = errors.New("The remote service responded but appear to think the request is malformatted")

ErrBadRequest happens when the remote service thinks the request is malformatted

View Source
var ErrFormatting = errors.New("Request was malformatted and could not be performed")

ErrFormatting happens when the something in the request body was not right

View Source
var ErrInvalidAuthToken = errors.New("The auth token used is not vailid")

ErrInvalidAuthToken happens when the currently used auth token is not vailid

View Source
var ErrInvalidPlatformRequest = errors.New("A platform specific request is invalid")

ErrInvalidPlatformRequest happens when a platform specific request like the request signature being incorrect

View Source
var ErrInvalidRequest = errors.New("The remote service responded but appear to think the request is invalid")

ErrInvalidRequest happens when the request is invalid

View Source
var ErrNewRPCURL = errors.New("There is a new RPC url in the response, please use the new URL for future requests")

ErrNewRPCURL happens when there is a new RPC url available in the response body

View Source
var ErrNoURL = errors.New("The remote service did not respond with a remote URL when expected")

ErrNoURL happens when the remote service is expected to respond with a remote URL but doesn't

View Source
var ErrRedirect = errors.New("The request was redirected")

ErrRedirect happens when an invalid session endpoint has been used

View Source
var ErrRequest = errors.New("The remote service responded but the request could not be completed for unknown reasons")

ErrRequest happens when there is an unknown issue with the request

View Source
var ErrSessionInvalidated = errors.New("The session has been invalidated")

ErrSessionInvalidated happens when the session has been invalidated by the remote service

Functions

func GetErrorFromStatus

func GetErrorFromStatus(status protos.ResponseEnvelope_StatusCode) error

GetErrorFromStatus will, depending on the status code, give you an error or nil if there is no error

Types

type CellIDs

type CellIDs []uint64

CellIDs is a slice of uint64s

func (CellIDs) Len

func (a CellIDs) Len() int

func (CellIDs) Less

func (a CellIDs) Less(i, j int) bool

func (CellIDs) Swap

func (a CellIDs) Swap(i, j int)

type ErrResponse

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

ErrResponse happens when there's something wrong with the response object

func (*ErrResponse) Error

func (e *ErrResponse) Error() string

type Feed

type Feed interface {
	// Push is used to put response messages on to the feed
	Push(entry interface{})
}

Feed is a common interface to act on encountered

type Location

type Location struct {
	Lon      float64
	Lat      float64
	Alt      float64
	Accuracy float64
}

Location consists of coordinates in longitude, latitude and altitude

func (*Location) DistanceToFort

func (l *Location) DistanceToFort(fort *protos.FortData) float64

DistanceToFort returns distance between the location and a fort using the Haversine formula Reference: https://gist.github.com/cdipaolo/d3f8db3848278b49db68

func (*Location) GetBytes

func (l *Location) GetBytes() []byte

GetBytes returns a byte slice of the location coordinates

func (*Location) GetCellIDs

func (l *Location) GetCellIDs() CellIDs

GetCellIDs will return a slice of the closed neighbourhood cell ids for the current coordinates

type RPC

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

RPC is used to communicate with the Pokémon Go API

func NewRPC

func NewRPC() *RPC

NewRPC constructs a Pokémon Go RPC API client

func (*RPC) Request

func (c *RPC) Request(ctx context.Context, endpoint string, requestEnvelope *protos.RequestEnvelope) (responseEnvelope *protos.ResponseEnvelope, err error)

Request queries the Pokémon Go API will all pending requests

type Session

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

Session is used to communicate with the Pokémon Go API

func NewSession

func NewSession(provider auth.Provider, location *Location, feed Feed, deviceInfo *protos.Signature_DeviceInfo, debug bool) *Session

NewSession constructs a Pokémon Go RPC API client

func (*Session) Announce

func (s *Session) Announce(ctx context.Context) (mapObjects *protos.GetMapObjectsResponse, err error)

Announce publishes the player's presence and returns the map environment

func (*Session) Call

func (s *Session) Call(ctx context.Context, requests []*protos.Request) (*protos.ResponseEnvelope, error)

Call queries the Pokémon Go API through RPC protobuf

func (*Session) GetInventory

func (s *Session) GetInventory(ctx context.Context) (*protos.GetInventoryResponse, error)

GetInventory returns the player items

func (*Session) GetPlayer

func (s *Session) GetPlayer(ctx context.Context) (*protos.GetPlayerResponse, error)

GetPlayer returns the current player profile

func (*Session) GetPlayerMap

func (s *Session) GetPlayerMap(ctx context.Context) (*protos.GetMapObjectsResponse, error)

GetPlayerMap returns the surrounding map cells

func (*Session) Init

func (s *Session) Init(ctx context.Context) error

Init initializes the client by performing full authentication

func (*Session) MoveTo

func (s *Session) MoveTo(location *Location)

MoveTo sets your current location

func (*Session) SetTimeout

func (s *Session) SetTimeout(d time.Duration)

SetTimeout sets the client timeout for the RPC API

type VoidFeed

type VoidFeed struct {
}

VoidFeed is a feed that does nothing with the data

func (*VoidFeed) Push

func (f *VoidFeed) Push(entry interface{})

Push pushes the entry in to nothing

Jump to

Keyboard shortcuts

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