tradeapi

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Wrapper around the HTTP trading API for type safety 'n' stuff.

Index

Constants

View Source
const (
	TradeStatus_Open      TradeStatus = 0
	TradeStatus_Complete              = 1
	TradeStatus_Empty                 = 2 // when both parties trade no items
	TradeStatus_Cancelled             = 3
	TradeStatus_Timeout               = 4 // the partner timed out
	TradeStatus_Failed                = 5
)
View Source
const (
	Action_AddItem     Action = 0
	Action_RemoveItem         = 1
	Action_Ready              = 2
	Action_Unready            = 3
	Action_Accept             = 4
	Action_SetCurrency        = 6
	Action_ChatMessage        = 7
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action uint

type Currency

type Currency struct {
	AppId      uint64 `json:",string"`
	ContextId  uint64 `json:",string"`
	CurrencyId uint64 `json:",string"`
	Amount     uint64 `json:",string"`
}

type Event

type Event struct {
	SteamId   steamid.SteamId `json:",string"`
	Action    Action          `json:",string"`
	Timestamp uint64

	AppId     uint32
	ContextId uint64 `json:",string"`
	AssetId   uint64 `json:",string"`

	Text string // only used for chat messages

	// The following is used for SetCurrency
	CurrencyId uint64 `json:",string"`
	OldAmount  uint64 `json:"old_amount,string"`
	NewAmount  uint64 `json:"amount,string"`
}

type EventList

type EventList map[uint]*Event

func (*EventList) UnmarshalJSON

func (e *EventList) UnmarshalJSON(data []byte) error

The EventList can either be an array or an object of id -> event

type Main

type Main struct {
	PartnerOnProbation bool
}

type Status

type Status struct {
	Success     bool
	Error       string
	NewVersion  bool        `json:"newversion"`
	TradeStatus TradeStatus `json:"trade_status"`
	Version     uint
	LogPos      int
	Me          User
	Them        User
	Events      EventList
}

type Trade

type Trade struct {
	LogPos  uint // not automatically updated
	Version uint // Incremented for each item change by Steam; not automatically updated.
	// contains filtered or unexported fields
}

func New

func New(sessionId, steamLogin, steamLoginSecure string, other steamid.SteamId) *Trade

Creates a new Trade based on the given cookies `sessionid`, `steamLogin`, `steamLoginSecure` and the trade partner's Steam ID.

func (*Trade) AddItem

func (t *Trade) AddItem(slot uint, itemId, contextId uint64, appId uint32) (*Status, error)

func (*Trade) Cancel

func (t *Trade) Cancel() (*Status, error)

func (*Trade) Chat

func (t *Trade) Chat(message string) (*Status, error)

func (*Trade) Confirm

func (t *Trade) Confirm() (*Status, error)

func (*Trade) GetForeignInventory

func (t *Trade) GetForeignInventory(contextId uint64, appId uint32, start *uint) (*inventory.PartialInventory, error)

Thread-safe.

func (*Trade) GetMain

func (t *Trade) GetMain() (*Main, error)

Fetches the main HTML page and parses it. Thread-safe.

func (*Trade) GetOwnInventory

func (t *Trade) GetOwnInventory(contextId uint64, appId uint32) (*inventory.Inventory, error)

Thread-safe.

func (*Trade) GetStatus

func (t *Trade) GetStatus() (*Status, error)

func (*Trade) RemoveItem

func (t *Trade) RemoveItem(slot uint, itemId, contextId uint64, appId uint32) (*Status, error)

func (*Trade) SetCurrency

func (t *Trade) SetCurrency(amount uint, currencyId, contextId uint64, appId uint32) (*Status, error)

func (*Trade) SetReady

func (t *Trade) SetReady(ready bool) (*Status, error)

type TradeStatus

type TradeStatus uint

type User

type User struct {
	Ready             jsont.UintBool
	Confirmed         jsont.UintBool
	SecSinceTouch     int  `json:"sec_since_touch"`
	ConnectionPending bool `json:"connection_pending"`
	Assets            interface{}
	Currency          interface{} // either []*Currency or empty string
}

Jump to

Keyboard shortcuts

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