tradeoffer

package
v0.0.0-...-e27a884 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Implements methods to interact with the official Trade Offer API.

See: https://developer.valvesoftware.com/wiki/Steam_Web_API/IEconService

Index

Constants

View Source
const (
	TradeOfferState_Invalid                  TradeOfferState = 1  // Invalid
	TradeOfferState_Active                                   = 2  // This trade offer has been sent, neither party has acted on it yet.
	TradeOfferState_Accepted                                 = 3  // The trade offer was accepted by the recipient and items were exchanged.
	TradeOfferState_Countered                                = 4  // The recipient made a counter offer
	TradeOfferState_Expired                                  = 5  // The trade offer was not accepted before the expiration date
	TradeOfferState_Canceled                                 = 6  // The sender cancelled the offer
	TradeOfferState_Declined                                 = 7  // The recipient declined the offer
	TradeOfferState_InvalidItems                             = 8  // Some of the items in the offer are no longer available (indicated by the missing flag in the output)
	TradeOfferState_CreatedNeedsConfirmation                 = 9  // The offer hasn't been sent yet and is awaiting email/mobile confirmation. The offer is only visible to the sender.
	TradeOfferState_CanceledBySecondFactor                   = 10 // Either party canceled the offer via email/mobile. The offer is visible to both parties, even if the sender canceled it before it was sent.
	TradeOfferState_InEscrow                                 = 11 // The trade has been placed on hold. The items involved in the trade have all been removed from both parties' inventories and will be automatically delivered in the future.
)
View Source
const (
	TradeOfferConfirmationMethod_Invalid   TradeOfferConfirmationMethod = 0
	TradeOfferConfirmationMethod_Email                                  = 1
	TradeOfferConfirmationMethod_MobileApp                              = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKey

type APIKey string

type Asset

type Asset struct {
	AppId      uint32 `json:"-"`
	ContextId  uint64 `json:",string"`
	AssetId    uint64 `json:",string"`
	CurrencyId uint64 `json:",string"`
	ClassId    uint64 `json:",string"`
	InstanceId uint64 `json:",string"`
	Amount     uint64 `json:",string"`
	Missing    bool
}

type Client

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

func NewClient

func NewClient(key APIKey, sessionId, steamLogin, steamLoginSecure string) *Client

func (*Client) Accept

func (c *Client) Accept(offerId uint64) error

Accept received trade offer It is best to confirm that offer was actually accepted by calling GetOffer after Accept and checking offer state

func (*Client) AcceptWithRetry

func (c *Client) AcceptWithRetry(offerId uint64, retryCount int, retryDelay time.Duration) error

func (*Client) Cancel

func (c *Client) Cancel(offerId uint64) error

func (*Client) CancelWithRetry

func (c *Client) CancelWithRetry(offerId uint64, retryCount int, retryDelay time.Duration) error

func (*Client) Create

func (c *Client) Create(other steamid.SteamId, accessToken *string, myItems, theirItems []TradeItem, counteredOfferId *uint64, message string) (uint64, error)

Sends a new trade offer to the given Steam user. You can optionally specify an access token if you've got one. In addition, `counteredOfferId` can be non-nil, indicating the trade offer this is a counter for. On success returns trade offer id

func (*Client) CreateWithRetry

func (c *Client) CreateWithRetry(other steamid.SteamId, accessToken *string, myItems, theirItems []TradeItem, counteredOfferId *uint64, message string, retryCount int, retryDelay time.Duration) (uint64, error)

func (*Client) Decline

func (c *Client) Decline(offerId uint64) error

func (*Client) DeclineWithRetry

func (c *Client) DeclineWithRetry(offerId uint64, retryCount int, retryDelay time.Duration) error

func (*Client) GetOffer

func (c *Client) GetOffer(offerId uint64) (*TradeOfferResult, error)

func (*Client) GetOfferEscrowDuration

func (c *Client) GetOfferEscrowDuration(offerId uint64) (*EscrowDuration, error)

Get duration of escrow in days. Call this after receiving a trade offer

func (*Client) GetOfferWithRetry

func (c *Client) GetOfferWithRetry(offerId uint64, retryCount int, retryDelay time.Duration) (*TradeOfferResult, error)

func (*Client) GetOffers

func (c *Client) GetOffers(getSent bool, getReceived bool, getDescriptions bool, activeOnly bool, historicalOnly bool, timeHistoricalCutoff *uint32) (*TradeOffersResult, error)

func (*Client) GetOffersWithRetry

func (c *Client) GetOffersWithRetry(getSent bool, getReceived bool, getDescriptions bool, activeOnly bool, historicalOnly bool, timeHistoricalCutoff *uint32, retryCount int, retryDelay time.Duration) (*TradeOffersResult, error)

func (*Client) GetOwnInventory

func (c *Client) GetOwnInventory(contextId uint64, appId uint32) (*inventory.Inventory, error)

func (*Client) GetOwnInventoryWithRetry

func (c *Client) GetOwnInventoryWithRetry(contextId uint64, appId uint32, retryCount int, retryDelay time.Duration) (*inventory.Inventory, error)

func (*Client) GetPartnerEscrowDuration

func (c *Client) GetPartnerEscrowDuration(other steamid.SteamId, accessToken *string) (*EscrowDuration, error)

Get duration of escrow in days. Call this before sending a trade offer

func (*Client) GetPartnerInventory

func (c *Client) GetPartnerInventory(other steamid.SteamId, contextId uint64, appId uint32, offerId *uint64) (*inventory.Inventory, error)

func (*Client) GetPartnerInventoryWithRetry

func (c *Client) GetPartnerInventoryWithRetry(other steamid.SteamId, contextId uint64, appId uint32, offerId *uint64, retryCount int, retryDelay time.Duration) (*inventory.Inventory, error)

func (*Client) GetTradeReceipt

func (c *Client) GetTradeReceipt(tradeId uint64) ([]*TradeReceiptItem, error)

Can be used to verify accepted tradeoffer and find out received asset ids

func (*Client) GetTradeReceiptWithRetry

func (c *Client) GetTradeReceiptWithRetry(tradeId uint64, retryCount int, retryDelay time.Duration) ([]*TradeReceiptItem, error)

type Description

type Description struct {
	AppId      uint32 `json:"appid"`
	ClassId    uint64 `json:"classid,string"`
	InstanceId uint64 `json:"instanceid,string"`

	IconUrl      string `json:"icon_url"`
	IconUrlLarge string `json:"icon_url_large"`

	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                  bool   `json:"tradable"`
	Commodity                 bool   `json:"commodity"`
	MarketTradableRestriction uint32 `json:"market_tradable_restriction"`

	Descriptions inventory.DescriptionLines `json:"descriptions"`
	Actions      []*inventory.Action        `json:"actions"`
}

type EscrowDuration

type EscrowDuration struct {
	DaysMyEscrow    uint32
	DaysTheirEscrow uint32
}

type SteamError

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

SteamError can be returned by Create, Accept, Decline and Cancel methods. It means we got response from steam, but it was in unknown format or request was declined.

func (*SteamError) Error

func (e *SteamError) Error() string

type TradeItem

type TradeItem struct {
	AppId      uint32 `json:"appid"`
	ContextId  uint64 `json:"contextid,string"`
	Amount     uint64 `json:"amount"`
	AssetId    uint64 `json:"assetid,string,omitempty"`
	CurrencyId uint64 `json:"currencyid,string,omitempty"`
}

type TradeOffer

type TradeOffer struct {
	TradeOfferId       uint64                       `json:",string"`
	TradeId            uint64                       `json:",string"`
	OtherAccountId     uint32                       `json:"accountid_other"`
	OtherSteamId       steamid.SteamId              `json:"-"`
	Message            string                       `json:"message"`
	ExpirationTime     uint32                       `json:"expiraton_time"`
	State              TradeOfferState              `json:"trade_offer_state"`
	ToGive             []*Asset                     `json:"items_to_give"`
	ToReceive          []*Asset                     `json:"items_to_receive"`
	IsOurOffer         bool                         `json:"is_our_offer"`
	TimeCreated        uint32                       `json:"time_created"`
	TimeUpdated        uint32                       `json:"time_updated"`
	EscrowEndDate      uint32                       `json:"escrow_end_date"`
	ConfirmationMethod TradeOfferConfirmationMethod `json:"confirmation_method"`
}

func (*TradeOffer) UnmarshalJSON

func (t *TradeOffer) UnmarshalJSON(data []byte) error

type TradeOfferConfirmationMethod

type TradeOfferConfirmationMethod uint

type TradeOfferResult

type TradeOfferResult struct {
	Offer        *TradeOffer
	Descriptions []*Description
}

type TradeOfferState

type TradeOfferState uint

type TradeOffersResult

type TradeOffersResult struct {
	Sent         []*TradeOffer `json:"trade_offers_sent"`
	Received     []*TradeOffer `json:"trade_offers_received"`
	Descriptions []*Description
}

type TradeReceiptItem

type TradeReceiptItem struct {
	AssetId   uint64 `json:"id,string"`
	AppId     uint32
	ContextId uint64
	Owner     uint64 `json:",string"`
	Pos       uint32
	inventory.Description
}

Jump to

Keyboard shortcuts

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