inventory

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2020 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package inventory includes types as used in the trade package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Name string
	Link string
}

type App

type App struct {
	AppID            uint32
	Name             string
	Icon             string
	Link             string
	AssetCount       uint32   `json:"asset_count"`
	TradePermissions string   `json:"trade_permissions"`
	Contexts         Contexts `json:"rgContexts"`
}

type AppInfo

type AppInfo struct {
	AppID uint32
	Name  string
	Icon  string
	Link  string
}

type Apps

type Apps map[string]*App

func GetApps

func GetApps(client *http.Client, steamID steamid.SteamID) (Apps, error)

func (*Apps) Get

func (i *Apps) Get(appID uint32) (*App, error)

func (*Apps) ToMap

func (i *Apps) ToMap() map[string]*App

type Context

type Context struct {
	ContextID  uint64 `json:"id,string"`
	AssetCount uint32 `json:"asset_count"`
	Name       string
}

type Contexts

type Contexts map[string]*Context

func (*Contexts) Get

func (c *Contexts) Get(contextID uint64) (*Context, error)

func (*Contexts) ToMap

func (c *Contexts) ToMap() map[string]*Context

type Currencies

type Currencies map[string]*Currency

func (*Currencies) ToMap

func (c *Currencies) ToMap() map[string]*Currency

func (*Currencies) UnmarshalJSON

func (c *Currencies) UnmarshalJSON(data []byte) error

type Currency

type Currency struct {
	ID         uint64 `json:",string"`
	ClassID    uint64 `json:",string"`
	IsCurrency bool   `json:"is_currency"`
	Pos        uint32
}

type Description

type Description struct {
	AppID      uint32 `json:",string"`
	ClassID    uint64 `json:",string"`
	InstanceID uint64 `json:",string"`

	IconURL      string `json:"icon_url"`
	IconLargeURL string `json:"icon_url_large"`
	IconDragURL  string `json:"icon_drag_url"`

	Name           string
	MarketName     string `json:"market_name"`
	MarketHashName string `json:"market_hash_name"`

	// Colors in hex, for example `B2B2B2`
	NameColor       string `json:"name_color"`
	BackgroundColor string `json:"background_color"`

	Type string

	Tradable                  jsont.UintBool
	Marketable                jsont.UintBool
	Commodity                 jsont.UintBool
	MarketTradableRestriction uint32 `json:"market_tradable_restriction,string"`

	Descriptions DescriptionLines
	Actions      []*Action
	// Application-specific data, like "def_index" and "quality" for TF2
	AppData map[string]string
	Tags    []*Tag
}

type DescriptionLine

type DescriptionLine struct {
	Value string
	Type  *string // Is `html` for HTML descriptions
	Color *string
}

type DescriptionLines

type DescriptionLines []*DescriptionLine

func (*DescriptionLines) UnmarshalJSON

func (d *DescriptionLines) UnmarshalJSON(data []byte) error

type Descriptions

type Descriptions map[string]*Description

Descriptions key format is %d_%d, first %d is ClassID, second is InstanceID

func (*Descriptions) Get

func (d *Descriptions) Get(classID uint64, instanceID uint64) (*Description, error)

func (*Descriptions) ToMap

func (d *Descriptions) ToMap() map[string]*Description

func (*Descriptions) UnmarshalJSON

func (d *Descriptions) UnmarshalJSON(data []byte) error

type GenericInventory

type GenericInventory map[uint32]map[uint64]*Inventory

func NewGenericInventory

func NewGenericInventory() GenericInventory

func (*GenericInventory) Add

func (i *GenericInventory) Add(appID uint32, contextID uint64, inv *Inventory)

func (*GenericInventory) Get

func (i *GenericInventory) Get(appID uint32, contextID uint64) (*Inventory, error)

Get inventory for specified appID and contextID

type Inventory

type Inventory struct {
	Items        Items        `json:"rgInventory"`
	Currencies   Currencies   `json:"rgCurrency"`
	Descriptions Descriptions `json:"rgDescriptions"`
	AppInfo      *AppInfo     `json:"rgAppInfo"`
}

func GetFullInventory

func GetFullInventory(fetch PartialInventoryFetcher) (*Inventory, error)

func GetOwnInventory

func GetOwnInventory(client *http.Client, contextID uint64, appID uint32) (*Inventory, error)

func Merge

func Merge(dst *Inventory, srcs ...*Inventory) *Inventory

Merge merges the given srcs into dst.

func NewInventory

func NewInventory() *Inventory

type Item

type Item struct {
	ID         uint64 `json:",string"`
	ClassID    uint64 `json:",string"`
	InstanceID uint64 `json:",string"`
	Amount     uint64 `json:",string"`
	Pos        uint32
}

type Items

type Items map[string]*Item

Items key is an AssetID

func (*Items) Get

func (i *Items) Get(assetID uint64) (*Item, error)

func (*Items) ToMap

func (i *Items) ToMap() map[string]*Item

func (*Items) UnmarshalJSON

func (i *Items) UnmarshalJSON(data []byte) error

type MoreStart

type MoreStart uint

func (*MoreStart) UnmarshalJSON

func (m *MoreStart) UnmarshalJSON(data []byte) error

type PartialInventory

type PartialInventory struct {
	Inventory

	Success   bool
	Error     string
	More      bool
	MoreStart MoreStart `json:"more_start"`
}

PartialInventory is a partial inventory as sent by the Steam API.

func GetOwnPartialInventory

func GetOwnPartialInventory(
	client *http.Client,
	contextID uint64,
	appID uint32,
	start uint,
) (*PartialInventory, error)

func PerformRequest

func PerformRequest(client *http.Client, req *http.Request) (*PartialInventory, error)

type PartialInventoryFetcher

type PartialInventoryFetcher func(start uint) (*PartialInventory, error)

type Tag

type Tag struct {
	InternalName string `json:"internal_name"`
	Name         string
	Category     string
	CategoryName string `json:"category_name"`
}

Jump to

Keyboard shortcuts

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