client

package
v0.0.0-...-c83d288 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package client provides an interface for interacting with a remote MOTKI installation.

The client package currently contains only a GRPC client implementation, but the Client interface or a specialized client (such as the ProductClient or InventoryClient) should be used in code that consumes this package.

Usage

When used with a remote MOTKI application server, this package can operate without any additional services installed on the local machine. By default, this client will connect to the public MOTKI server at motki.org:18443.

The APIs defined in this package are intended to be the outward-facing interface for a MOTKI installation.

Running the Server

See https://github.com/motki/motki-server for information on running your own MOTKI application server.

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrBadCredentials = errors.New("username or password is incorrect")
View Source
var ErrNotAuthenticated = errors.New("not authenticated")

Functions

This section is empty.

Types

type AssetClient

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

AssetClient handles asset related functionality.

func (*AssetClient) GetCorpBlueprints

func (c *AssetClient) GetCorpBlueprints() ([]*model.Blueprint, error)

GetCorpBlueprints returns the current session's corporation's blueprints.

This method requires that the user's corporation has opted-in to data collection.

type CharacterClient

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

CharacterClient retrieves character, corporation, and alliance information.

func (*CharacterClient) CharacterForRole

func (c *CharacterClient) CharacterForRole(role model.Role) (*model.Character, error)

CharacterForRole returns the current session's associated character for the given role.

func (*CharacterClient) GetAlliance

func (c *CharacterClient) GetAlliance(allianceID int) (*model.Alliance, error)

GetAlliance returns a populated Alliance for the given alliance ID.

func (*CharacterClient) GetCharacter

func (c *CharacterClient) GetCharacter(charID int) (*model.Character, error)

GetCharacter returns a populated Character for the given character ID.

func (*CharacterClient) GetCorporation

func (c *CharacterClient) GetCorporation(corpID int) (*model.Corporation, error)

GetCorporation returns a populated Corporation for the given corporation ID.

type Client

type Client interface {
	// Authenticate attempts to authenticate the client session with the server.
	Authenticate(username, password string) error
	// Authenticated returns true if the current session is authenticated.
	Authenticated() bool

	// CharacterForRole returns the current session's associated character for the given role.
	CharacterForRole(model.Role) (*model.Character, error)
	// GetCharacter returns a populated Character for the given character ID.
	GetCharacter(charID int) (*model.Character, error)
	// GetCorporation returns a populated Corporation for the given corporation ID.
	GetCorporation(corpID int) (*model.Corporation, error)
	// GetAlliance returns a populated Alliance for the given alliance ID.
	GetAlliance(allianceID int) (*model.Alliance, error)

	// GetRace returns information about the given race ID.
	GetRace(raceID int) (*evedb.Race, error)
	// GetRaces returns information about all races in the EVE universe.
	GetRaces() ([]*evedb.Race, error)
	// GetBloodline returns information about the given bloodline ID.
	GetBloodline(bloodlineID int) (*evedb.Bloodline, error)
	// GetAncestry returns information about the given ancestry ID.
	GetAncestry(ancestryID int) (*evedb.Ancestry, error)

	// GetRegion returns information about the given region ID.
	GetRegion(regionID int) (*evedb.Region, error)
	// GetRegions returns a slice containing information about all regions in the EVE universe.
	GetRegions() ([]*evedb.Region, error)
	// GetConstellation returns information about the given constellation ID.
	GetConstellation(constellationID int) (*evedb.Constellation, error)
	// GetSystem returns information about the given system ID.
	GetSystem(systemID int) (*evedb.System, error)

	// GetItemType returns information about the given type ID.
	GetItemType(typeID int) (*evedb.ItemType, error)
	// GetItemTypeDetail returns detailed information about the given type ID.
	GetItemTypeDetail(typeID int) (*evedb.ItemTypeDetail, error)

	// QueryItemTypes searches for matching item types given a search query and optional category IDs.
	QueryItemTypes(query string, catIDs ...int) ([]*evedb.ItemType, error)
	// QueryItemTypeDetails searches for matching item types, returning detail type information for each match.
	QueryItemTypeDetails(query string, catIDs ...int) ([]*evedb.ItemTypeDetail, error)
	// GetMaterialSheet returns manufacturing information about the given type ID.
	GetMaterialSheet(typeID int) (*evedb.MaterialSheet, error)

	// GetInventory returns all inventory items for the current session's corporation.
	GetInventory() ([]*model.InventoryItem, error)
	// NewInventoryItem creates a new inventory item for the given type ID and location ID.
	// If an inventory item already exists for the given type and location ID, it will be returned.
	NewInventoryItem(typeID, locationID int) (*model.InventoryItem, error)
	// SaveInventoryItem attempts to save the given inventory item to the backend database.
	SaveInventoryItem(*model.InventoryItem) error

	// GetMarketPrice returns the current market price for the given type ID.
	GetMarketPrice(typeID int) (*model.MarketPrice, error)
	// GetMarketPrices returns a slice of market prices for each of the given type IDs.
	GetMarketPrices(typeID int, typeIDs ...int) ([]*model.MarketPrice, error)

	// GetCorpBlueprints returns the current session's corporation's blueprints.
	GetCorpBlueprints() ([]*model.Blueprint, error)

	// NewProduct creates a new Production Chain for the given type ID.
	// If a production chain already exists for the given type ID, it will be returned.
	NewProduct(typeID int) (*model.Product, error)
	// GetProduct attempts to load an existing production chain using its unique product ID.
	GetProduct(productID int) (*model.Product, error)
	// SaveProduct attempts to save the given production chain to the backend database.
	SaveProduct(product *model.Product) error
	// GetProducts gets all production chains for the current session's corporation.
	GetProducts() ([]*model.Product, error)
	// UpdateProductPrices updates all items in a production chain with the latest market sell price.
	UpdateProductPrices(*model.Product) (*model.Product, error)

	// GetStructure gets basic information about the given structure.
	GetStructure(structureID int) (*model.Structure, error)
	// GetCorpStructures gets detailed information about corporation structures.
	GetCorpStructures() ([]*model.CorporationStructure, error)

	// GetLocation returns information about the denormalized locationID.
	GetLocation(locationID int) (*model.Location, error)
	// QueryLocation return locations that match the input query.
	QueryLocations(query string) ([]*model.Location, error)
}

A Client provides a remote interface to the MOTKI model package.

A Client is the full interface. See the feature-specific client implementations for details on specific functionality.

func New

func New(conf proto.Config, logger log.Logger) (Client, error)

New creates a new Client using the given model configuration.

Example

ExampleNew shows how one might use the client package directly.

package main

import (
	"fmt"

	"github.com/motki/core/log"
	"github.com/motki/core/proto"
	"github.com/motki/core/proto/client"
)

func main() {
	// This configuration connects to the public application server at motki.org.
	c := proto.Config{
		Kind:       proto.BackendRemoteGRPC,
		RemoteGRPC: proto.RemoteConfig{ServerAddr: "motki.org:18443"},
	}
	// Gotta have a logger.
	l := log.New(log.Config{Level: "warn"})

	// Create the client or panic.
	cl, err := client.New(c, l)
	if err != nil {
		panic(err)
	}

	// This method call will always fail when ran under the godoc sandbox without network access.
	it, err := cl.GetItemType(2281)
	if err != nil {
		panic(err)
	}

	fmt.Println(it.Name)

}
Output:

Adaptive Invulnerability Field II

type EVEUniverseClient

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

EVEUniverseClient provides information about the EVE universe.

func (*EVEUniverseClient) GetAncestry

func (c *EVEUniverseClient) GetAncestry(ancestryID int) (*evedb.Ancestry, error)

GetAncestry returns information about the given ancestry ID.

func (*EVEUniverseClient) GetBloodline

func (c *EVEUniverseClient) GetBloodline(bloodlineID int) (*evedb.Bloodline, error)

GetBloodline returns information about the given bloodline ID.

func (*EVEUniverseClient) GetConstellation

func (c *EVEUniverseClient) GetConstellation(constellationID int) (*evedb.Constellation, error)

GetConstellation returns information about the given constellation ID.

func (*EVEUniverseClient) GetRace

func (c *EVEUniverseClient) GetRace(raceID int) (*evedb.Race, error)

GetRace returns information about the given race ID.

func (*EVEUniverseClient) GetRaces

func (c *EVEUniverseClient) GetRaces() ([]*evedb.Race, error)

GetRaces returns information about all races in the EVE universe.

func (*EVEUniverseClient) GetRegion

func (c *EVEUniverseClient) GetRegion(regionID int) (*evedb.Region, error)

GetRegion returns information about the given region ID.

func (*EVEUniverseClient) GetRegions

func (c *EVEUniverseClient) GetRegions() ([]*evedb.Region, error)

GetRegions returns a slice containing information about all regions in the EVE universe.

func (*EVEUniverseClient) GetSystem

func (c *EVEUniverseClient) GetSystem(systemID int) (*evedb.System, error)

GetSystem returns information about the given system ID.

type GRPCClient

GRPCClient is the defacto implementation of the Client interface.

type InventoryClient

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

InventoryClient is the interface for corporation inventory management.

Functionality provided by this client requires that the user's corporation is registered and opted-in to data collection.

func (*InventoryClient) GetInventory

func (c *InventoryClient) GetInventory() ([]*model.InventoryItem, error)

GetInventory returns all inventory items for the current session's corporation.

This method requires that the user's corporation has opted-in to data collection.

func (*InventoryClient) NewInventoryItem

func (c *InventoryClient) NewInventoryItem(typeID, locationID int) (*model.InventoryItem, error)

NewInventoryItem creates a new inventory item for the given type ID and location ID.

If an inventory item already exists for the given type and location ID, it will be returned.

This method requires that the user's corporation has opted-in to data collection.

func (*InventoryClient) SaveInventoryItem

func (c *InventoryClient) SaveInventoryItem(item *model.InventoryItem) error

SaveInventoryItem attempts to save the given inventory item to the backend database.

This method requires that the user's corporation has opted-in to data collection.

type ItemTypeClient

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

ItemTypeClient retrieves type information for items in the EVE universe.

func (*ItemTypeClient) GetItemType

func (c *ItemTypeClient) GetItemType(typeID int) (*evedb.ItemType, error)

GetItemType returns information about the given type ID.

func (*ItemTypeClient) GetItemTypeDetail

func (c *ItemTypeClient) GetItemTypeDetail(typeID int) (*evedb.ItemTypeDetail, error)

GetItemTypeDetail returns detailed information about the given type ID.

func (*ItemTypeClient) GetMaterialSheet

func (c *ItemTypeClient) GetMaterialSheet(typeID int) (*evedb.MaterialSheet, error)

GetMaterialSheet returns manufacturing information about the given type ID.

func (*ItemTypeClient) QueryItemTypeDetails

func (c *ItemTypeClient) QueryItemTypeDetails(query string, catIDs ...int) ([]*evedb.ItemTypeDetail, error)

QueryItemTypeDetails searches for matching item types, returning detail type information for each match.

func (*ItemTypeClient) QueryItemTypes

func (c *ItemTypeClient) QueryItemTypes(query string, catIDs ...int) ([]*evedb.ItemType, error)

QueryItemTypes searches for matching item types given a search query and optional category IDs.

type LocationClient

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

LocationClient provides location information using denormalized location IDs.

func (*LocationClient) GetLocation

func (c *LocationClient) GetLocation(locationID int) (*model.Location, error)

GetLocation returns the given Location using the denormalized location ID.

If the user's corporation has opted-in, asset and structure information is used to enhance the results.

func (*LocationClient) QueryLocations

func (c *LocationClient) QueryLocations(query string) ([]*model.Location, error)

QueryLocation return locations that match the input query.

If the user's corporation has opted-in, asset and structure information is used to enhance the results.

type MarketClient

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

MarketClient retrieves market price information about types in the EVE universe.

func (*MarketClient) GetMarketPrice

func (c *MarketClient) GetMarketPrice(typeID int) (*model.MarketPrice, error)

GetMarketPrice returns the current market price for the given type ID.

func (*MarketClient) GetMarketPrices

func (c *MarketClient) GetMarketPrices(typeID int, typeIDs ...int) ([]*model.MarketPrice, error)

GetMarketPrices returns a slice of market prices for each of the given type IDs.

type ProductClient

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

ProductClient is the interface for managing corporation production chains.

Functionality in this client requires that the user's corporation is registered and opted-in to data collection.

func (*ProductClient) GetProduct

func (c *ProductClient) GetProduct(productID int) (*model.Product, error)

GetProduct attempts to load an existing production chain using its unique product ID.

This method requires that the user's corporation has opted-in to data collection.

func (*ProductClient) GetProducts

func (c *ProductClient) GetProducts() ([]*model.Product, error)

GetProducts gets all production chains for the current session's corporation.

This method requires that the user's corporation has opted-in to data collection.

func (*ProductClient) NewProduct

func (c *ProductClient) NewProduct(typeID int) (*model.Product, error)

NewProduct creates a new Production Chain for the given type ID.

If a production chain already exists for the given type ID, it will be returned.

This method requires that the user's corporation has opted-in to data collection.

func (*ProductClient) SaveProduct

func (c *ProductClient) SaveProduct(product *model.Product) error

SaveProduct attempts to save the given production chain to the backend database.

This method requires that the user's corporation has opted-in to data collection.

func (*ProductClient) UpdateProductPrices

func (c *ProductClient) UpdateProductPrices(product *model.Product) (*model.Product, error)

UpdateProductPrices updates all items in a production chain with the latest market sell price.

This method requires that the user's corporation has opted-in to data collection.

type StructureClient

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

StructureClient retrieves information about player-owned Citadels in EVE.

func (*StructureClient) GetCorpStructures

func (c *StructureClient) GetCorpStructures() ([]*model.CorporationStructure, error)

GetCorpStructures returns detailed information about corporation structures.

This method requires that the user's corporation has opted-in to data collection.

func (*StructureClient) GetStructure

func (c *StructureClient) GetStructure(structureID int) (*model.Structure, error)

GetStructure returns public information about the given structure.

type UserClient

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

UserClient handles authenticating a user session.

func (*UserClient) Authenticate

func (c *UserClient) Authenticate(username, password string) error

Authenticate attempts to authenticate with the GRPC server.

If authentication is successful, a token is stored in the client. The token is passed along with subsequent operations and used to authorize the user's access for things such as corporation-related functionality.

func (*UserClient) Authenticated

func (c *UserClient) Authenticated() bool

Authenticated returns true if the current session is authenticated.

Jump to

Keyboard shortcuts

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