usersservice

package
v4.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 2, 2017 License: MIT Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Profile

type Profile interface {
	// GetName returns the profile's name
	GetName() string

	// GetRiches returns the profile's riches
	GetRiches() float32

	// GetStocks returns the profile's stocks
	GetStocks() []Stock
}

Profile represents the information about a user that the application stores.

type Stock

type Stock interface {
	// GetQuantity returns the quantity of the stock
	GetQuantity() int

	// GetTicker returns the ticker of the stock
	GetTicker() string
}

Stock represents the quantity of stock owned by ticker

type User

type User interface {
	// GetAccessToken returns the user's access token
	GetAccessToken() string

	// GetIDToken returns the user's ID token
	GetIDToken() string

	// GetProfile returns the user profile
	GetProfile() Profile

	// JSON serializes the user record
	JSON() ([]byte, error)
}

User represents a user of the system. Owner of purchase orders and sell orders. Only the profile portion of a user is ever stored server side

type UsersService

type UsersService interface {
	// UpdateForSellOrderByUserID adds to the user's riches. Will
	// return an error if the user cannot be found
	UpdateForSellOrderByUserID(userID, ticker string, quantity int, amount float32) error

	// GetProfile retrieves a profile for a userID
	GetProfile(userID string) (Profile, error)

	// Login exchanges the code for a user profile
	// and then upserts the user profile into persistent
	// storage
	Login(code string) (User, int, error)

	// UpdateForBuyOrderByUserID removes riches from the user and adds
	// to the stock quantity for the given ticker. Will
	// return an error if the user cannot be found
	UpdateForBuyOrderByUserID(userID, ticker string, quantity int, price float32) error

	// UserIDForAccessToken verifies the RS256 signature
	// of a JWT access token
	UserIDForAccessToken(accessToken string) (string, error)
}

UsersService manages CRUD for buy & sell users

func New

func New(auth0Creds auth0creds.Auth0Creds, mongoDB *mgo.Session) UsersService

New constructs a new UsersService that will persist data using the provided mongo session

Jump to

Keyboard shortcuts

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