Documentation ¶
Index ¶
- Constants
- Variables
- type Cargo
- type ErrorResponse
- type Flightplan
- type Loan
- type Location
- type LocationType
- type MarketplaceGood
- type Order
- type Ship
- type User
- func (u *User) GetFlightplan(flightplanID string) (*Flightplan, error)
- func (u *User) GetShipInfo(shipID string) (*Ship, error)
- func (u *User) JettisonCargo(shipID, good string, quantity int) error
- func (u *User) SubmitFlightplan(shipID, destination string) (*Flightplan, error)
- func (u *User) SubmitPurchaseOrder(shipID, good string, quantity int) (*Ship, error)
- func (u *User) SubmitSellOrder(shipID, good string, quantity int) (*Ship, *Order, error)
Constants ¶
View Source
const ( ErrorCodeGoodNotInMarketplace = 2001 ErrorCodeInsufficientFunds = 2004 ErrorCodeNotFound = 404 )
Known error codes
View Source
const ( LocationTypeUnknown = iota LocationTypePlanet LocationTypeMoon LocationTypeWormhole LocationTypeAsteroid LocationTypeGasGiant )
View Source
const (
URLBase = "https://api.spacetraders.io/"
)
Variables ¶
View Source
var ( ErrorSystemNotFound = errors.New("stapi: system not found") ErrorLocationNotFound = errors.New("stapi: location is not detectable or does not exist") )
View Source
var ( URLUserInfo = func(username string) string { return URLBase + "users/" + username } URLSystemLocations = func(system string) string { return URLBase + "game/systems/" + system + "/locations" } URLLocationInformation = func(location string) string { return URLBase + "game/locations/" + location } URLMarketplaceAtLocation = func(location string) string { return URLBase + "game/locations/" + location + "/marketplace" } URLSubmitPurchaseOrder = func(username string) string { return URLBase + "users/" + username + "/purchase-orders" } URLSubmitSellOrder = func(username string) string { return URLBase + "users/" + username + "/sell-orders" } URLJettisonCargo = func(username, ship string) string { return URLBase + "users/" + username + "/ships/" + ship + "/jettison" } URLSubmitFlightplan = func(username string) string { return URLBase + "users/" + username + "/flight-plans" } URLGetFlightplanInformation = func(username, flightplanID string) string { return URLBase + "users/" + username + "/flight-plans/" + flightplanID } URLGetShipInfo = func(username, shipID string) string { return URLBase + "users/" + username + "/ships/" + shipID } )
View Source
var (
ErrorCannotViewMarketplace = errors.New("stapi: marketplace listings are only visible to docked ships at this location")
)
View Source
var ErrorFailedRatelimit = errors.New("stapi: unable to make request (too many responses with 429)")
View Source
var (
ErrorUserNotFound = errors.New("stapi: user not found")
)
Functions ¶
This section is empty.
Types ¶
type ErrorResponse ¶
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
type Flightplan ¶
type Flightplan struct { ID string `json:"id"` ShipID string `json:"shipId"` CreatedAt *time.Time `json:"createdAt"` ArrivesAt *time.Time `json:"arrivesAt"` Destination string `json:"destination"` Departure string `json:"departure"` Distance int `json:"distance"` FuelConsumed int `json:"fuelConsumed"` FuelRemaining int `json:"fuelRemaining"` TerminatedAt *time.Time `json:"terminatedAt"` FlightTimeRemaining int `json:"timeRemainingInSeconds"` }
type Location ¶
type Location struct { Symbol string `json:"symbol"` Type LocationType `json:"type"` Name string `json:"name"` XCoordinate int `json:"x"` YCoordinate int `json:"y"` Ships []*Ship `json:"ships"` AvailableGoods []*MarketplaceGood `json:"marketplace"` }
func GetLocationInfo ¶
func GetSystemLocations ¶
type LocationType ¶
type LocationType uint
func (*LocationType) UnmarshalJSON ¶
func (l *LocationType) UnmarshalJSON(data []byte) error
type MarketplaceGood ¶
type MarketplaceGood struct { Symbol string `json:"symbol"` VolumePerUnit int `json:"volumePerUnit"` PricePerUnit int `json:"pricePerUnit"` Spread int `json:"spread"` PurchasePricePerUnit int `json:"purchasePricePerUnit"` SellPricePerUnit int `json:"sellPricePerUnit"` QuantityAvailable int `json:"quantityAvailable"` }
func GetMarketplaceAtLocation ¶
func GetMarketplaceAtLocation(location string) ([]*MarketplaceGood, error)
type Ship ¶
type Ship struct { ID string `json:"id"` Location string `json:"location"` XCoordinate int `json:"x"` YCoordinate int `json:"y"` Cargo []*Cargo `json:"cargo"` SpaceAvailable int `json:"spaceAvailable"` Type string `json:"type"` Class string `json:"class"` MaxCargo int `json:"maxCargo"` Speed int `json:"speed"` Manufacturer string `json:"manufacturer"` Plating int `json:"plating"` Weapons int `json:"weapons"` }
func (*Ship) GetCurrentFuel ¶
type User ¶
type User struct { Username string `json:"username"` Credits int `json:"credits"` Ships []*Ship `json:"ships"` Loans []*Loan `json:"loans"` // contains filtered or unexported fields }
func GetUserInfo ¶
func (*User) GetFlightplan ¶
func (u *User) GetFlightplan(flightplanID string) (*Flightplan, error)
func (*User) SubmitFlightplan ¶
func (u *User) SubmitFlightplan(shipID, destination string) (*Flightplan, error)
func (*User) SubmitPurchaseOrder ¶
Click to show internal directories.
Click to hide internal directories.