client

package
v0.0.0-...-ea6506d Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// HTTP is the underlying HTTP client used send requests.
	HTTP *http.Client
	// BaseURL is the HTTP endpoint for the REST API. Can be overridden for tests.
	// It defaults to https://backend.findrandomevents.com
	BaseURL string
	// JWT is the user credential used to authenticate with eventdb.
	//
	// We're using Firebase auth, so this must be retrieved from the Firebase API.
	JWT string

	Users  *UsersClient
	Events *EventsClient
	Dests  *DestsClient
}

Client provides a client to eventdb's REST API.

Don't construct a Client directly. Use New() instead.

func New

func New(jwt string) *Client

New constructs a new Client

type DestsClient

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

DestsClient provides access to the eventdb /dests endpoint

func (*DestsClient) Generate

Generate finds a new random event near the user's location and returns a DestGenerateReply that includes the new event and whether or not the search was successful.

func (*DestsClient) Get

Get retrieves a Dest from the database.

func (*DestsClient) List

func (c *DestsClient) List(ctx context.Context, id eventdb.DestID, update eventdb.DestUpdate) ([]eventdb.Dest, error)

List lists a user's Dests by creation date.

func (*DestsClient) Update

func (c *DestsClient) Update(ctx context.Context, id eventdb.DestID, update eventdb.DestUpdate) (eventdb.Dest, error)

Update updates a Dest with the user's feedback

type EventsClient

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

EventsClient provides access to the eventdb /events endpoint

func (*EventsClient) Search

Search queries the database for events matching the EventSearchRequest and returns Event objects for the matching results.

func (*EventsClient) Submit

Submit downloads the events using the Facebook API and saves them to the EventStore. It uses a random user's Facebook API token to fetch the event so some users must be logged in with Facebook for this method to work.

type UsersClient

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

UsersClient provides access to the eventdb /users endpoint

func (*UsersClient) Get

func (c *UsersClient) Get(ctx context.Context, id string) (eventdb.User, error)

Get retrieves User records.

func (*UsersClient) Update

func (c *UsersClient) Update(ctx context.Context, id string, update eventdb.UserUpdate) (eventdb.User, error)

Update lets users update their profile data.

Jump to

Keyboard shortcuts

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