db

package
v0.0.0-...-965783e Latest Latest
Warning

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

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

Documentation

Overview

Package db interfaces to the local database (user data).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LocalDB

type LocalDB interface {
	// NewSession generates a new session.
	NewSession() (Session, error)

	// FindSession attempts to retrieve an existing session from the database;
	// if it was not found, a new session will be returned.
	FindSession(cookie string) (Session, error)

	// AuthenticateSession associates a session with an EVE character authenticated
	// by OAuth2.
	AuthenticateSession(cookie string, token *oauth2.Token, charInfo *evesso.CharacterInfo) error

	// APIKeys returns the user's API keys that have been registered in this application.
	APIKeys(userID int) ([]XMLAPIKey, error)

	// LogoutSession deletes all of a user's sessions.
	LogoutSession(cookie string) error

	// DeleteAPIKey deletes the specified API key.
	DeleteAPIKey(userID, keyID int) error

	// AddAPIKey adds the specified API key.
	AddAPIKey(key XMLAPIKey) error

	// GetAPICharacters adds the characters on an API key to the database.
	GetAPICharacters(userid int, key XMLAPIKey) ([]evego.Character, error)

	// GetAPISkills adds the skills on a character to the database.
	GetAPISkills(key XMLAPIKey, charID int) error

	// CharacterSkill returns the specified skill's level, or 0 if it has not
	// been injected.
	CharacterSkill(userID, charID, skillID int) (int, error)

	// CharacterSkill returns the levels of all injected skills in the specified
	// group.
	CharacterSkillGroup(userID, charID, skillGroupID int) ([]evego.Skill, error)

	// GetAPIStandings adds a character's standings with NPC entities to the database.
	GetAPIStandings(key XMLAPIKey, charID int) error

	// CharacterStandings queries a character's standings (corporation and faction)
	// with an NPC corporation.
	CharacterStandings(userID, charID, corpID int) (corpStanding, factionStanding sql.NullFloat64, err error)

	// RepopulateOutposts updates outpost information in the local database.
	RepopulateOutposts() error

	// SearchStations searches outpost and station names for the provided term,
	// adding %s on either side.
	SearchStations(search string) ([]evego.Station, error)

	// StationForID gets the station or outpost corresponding to the passed
	// ID.
	StationForID(stationID int) (*evego.Station, error)

	// GetAssetsBlueprints retrieves a character's assets and blueprints, and
	// adds them to the database.
	GetAssetsBlueprints(key XMLAPIKey, charID int) error

	// CharacterBlueprints returns a character's blueprints from the local
	// database.
	CharacterBlueprints(userID, charID int) ([]evego.BlueprintItem, error)

	// UnusedSalvage returns a character's salvage inventory that is not used
	// by any blueprint he owns.
	UnusedSalvage(userid, characterID int) ([]evego.InventoryItem, error)
}

LocalDB is an interface to this application's local data.

func Interface

func Interface(driver, resource string, xmlAPI evego.XMLAPI) (LocalDB, error)

Interface returns an interface to the local data store. Currently, it assumes that the schema our tables and functions are in can be found in the search path, so you'll need to ensure that it's set in the provided resource.

Example resource: "user=enoch dbname=evetool search_path=eveindy"

type Session

type Session struct {
	// User is the application user's ID. (This is a local identifier and is not
	// related to the authenticating account or character.)
	User int `db:"userid"`

	// State is a random value that will be passed to CCP's servers when making
	// an OAuth request.
	State string `db:"state"`

	// Cookie is a random value that is stored on the client's system (as a cookie)
	// to identify the client across requests.
	Cookie string `db:"cookie"`

	// Token is the OAuth token returned from CCP's servers and can be used to
	// access the CREST API.
	Token *oauth2.Token `db:"-"`

	// LastSeen is the time at which the session owner used this website.
	LastSeen time.Time `db:"lastseen"`
}

Session is a user's session (logged in or otherwise).

type XMLAPIKey

type XMLAPIKey struct {
	// User is the application user's ID. (This is a local identifier and is not
	// related to the authenticating account or character.)
	User int `db:"userid" json:"userid"`

	// ID is the key's ID assigned by CCP.
	ID int `db:"id" json:"id"`

	// VerificationCode is the key's verification code assigned by CCP.
	VerificationCode string `db:"vcode" json:"vcode"`

	// Description is a user-entered label for the key; it is not the one that
	// the user entered in EVE's API managment interface.
	Description string `db:"label" json:"label"`

	// Characters is a list of characters that are accessible using this API key.
	Characters []evego.Character `json:"characters"`
}

XMLAPIKey is a user-provided key for the EVE XML API.

Jump to

Keyboard shortcuts

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