Documentation
¶
Index ¶
- Constants
- Variables
- func AuthToContext(parent context.Context, au *Auth) context.Context
- type Auth
- type AuthService
- type AuthStorage
- type BanService
- type Catalog
- type CatalogStorage
- type Delivery
- type DeliveryService
- type DeliveryStatus
- type DeliveryStorage
- type Errors
- type FileManager
- type FindMetadata
- type FindOpts
- type HammerParams
- type HammerService
- type Image
- type ImageService
- type Inventory
- type InventoryService
- type InventoryStatus
- type InventoryStorage
- type Item
- type ItemImportResult
- type ItemService
- type ItemStatus
- type ItemStorage
- type ManualSubscriptionParam
- type Market
- type MarketSaleSummary
- type MarketSalesGraph
- type MarketService
- type MarketStatus
- type MarketStatusCount
- type MarketStorage
- type MarketType
- type Report
- type ReportService
- type ReportStorage
- type ReportType
- type SalesStatus
- type SearchKeywordScore
- type StatsService
- type StatsStorage
- type SteamAsset
- type SteamClient
- type SteamPlayer
- type Task
- type TaskPriority
- type TaskStatus
- type TaskType
- type Track
- type TrackService
- type TrackStorage
- type User
- type UserBoon
- type UserService
- type UserStats
- type UserStatus
- type UserStorage
- type UserSubscription
- type Version
- type XErrors
Constants ¶
const ( MaxMarketQtyLimitPerFreeUser = 1 MaxMarketQtyLimitPerPremiumUser = 5 MarketAskExpirationDays = 30 MarketBidExpirationDays = 7 MarketSweepExpiredDays = 30 MarketSweepRemovedDays = 60 )
const ( TrendScoreRateView = 0.05 TrendScoreRateMarketEntry = 0.01 TrendScoreRateReserved = 4 TrendScoreRateSold = 4 TrendScoreRateBid = 2 )
Market trending score rates.
const ( TrackTypeView = "v" TrackTypeSearch = "s" TrackTypeProfileView = "p" TrackTypeItemView = 300 TrackTypeCatalogSearch = 310 TrackTypeProfileClick = 110 TrackTypeMarketListed = 220 TrackTypeMarketReserved = 230 TrackTypeMarketSold = 240 TrackTypeMarketBidCompleted = 241 TrackTypeMarketRemoved = 250 TrackTypeMarketCancelled = 260 TrackTypeMarketExpired = 270 )
Track types.
const ( BoonSupporterBadge = "SUPPORTER_BADGE" BoonTraderBadge = "TRADER_BADGE" BoonPartnerBadge = "PARTNER_BADGE" BoonRefresherShard = "REFRESHER_SHARD" BoonRefresherOrb = "REFRESHER_ORB" BoonShopKeepersContract = "SHOPKEEPERS_CONTRACT" BoonDedicatedPos5 = "DEDICATED_POS_5" )
const DeliveryRetryLimit = 30
DeliveryRetryLimit max retry to process verification.
const (
ReportLabelSurveyNext = "community-whats-next"
)
Report available labels.
Variables ¶
var ErrHammerNotWielded = errors.New("user is not wielding a hammer")
var MarketStatusTexts = map[MarketStatus]string{ MarketStatusPending: "pending", MarketStatusLive: "live", MarketStatusReserved: "reserved", MarketStatusSold: "sold", MarketStatusBidCompleted: "completed", MarketStatusRemoved: "removed", MarketStatusCancelled: "cancelled", MarketStatusExpired: "expired", }
var ReportTypeTexts = map[ReportType]string{ ReportTypeFeedback: "Feedback", ReportTypeSurvey: "Survey", ReportTypeBug: "Bug", ReportTypeScamAlert: "ScamAlert", ReportTypeScamIncident: "ScamIncident", }
var TaskStatusStrings = map[TaskStatus]string{ TaskStatusPending: "pending", TaskStatusProcessing: "processing", TaskStatusDone: "done", TaskStatusError: "error", }
Functions ¶
Types ¶
type Auth ¶
type Auth struct {
ID string `json:"id" db:"id,omitempty"`
UserID string `json:"user_id" db:"user_id,indexed,omitempty" valid:"required"`
Username string `json:"username" db:"username,indexed,omitempty" valid:"required"`
Password string `json:"-" db:"password,omitempty" valid:"required"`
RefreshToken string `json:"refresh_token" db:"refresh_token,indexed,omitempty"`
CreatedAt *time.Time `json:"created_at" db:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at" db:"updated_at,omitempty"`
}
Auth represents access authorization.
func AuthFromContext ¶
AuthFromContext returns an auth details from the given context if one is present. Return nil if auth detail cannot be found.
type AuthService ¶
type AuthService interface {
// SteamLogin redirects for authorization and process creation of auth.
SteamLogin(w http.ResponseWriter, r *http.Request) (*Auth, error)
// RevokeRefreshToken invalidates refresh token that will prevent on renewing
// short-lived access token and will result user have to re-login.
RevokeRefreshToken(refreshToken string) error
// RenewToken checks refresh token validity that allows to get new short-lived access token.
RenewToken(refreshToken string) (*Auth, error)
// Auth returns an auth details by id.
Auth(id string) (*Auth, error)
}
AuthService provides access to service.
func NewAuthService ¶ added in v0.23.0
func NewAuthService( salt string, sc SteamClient, as AuthStorage, us UserService, ) AuthService
NewAuthService returns a new Auth service.
type AuthStorage ¶
type AuthStorage interface {
// Get returns an auth details by id from data store.
Get(id string) (*Auth, error)
// GetByUsername returns an auth details by username from data store.
GetByUsername(username string) (*Auth, error)
// GetByUsernameAndPassword returns an auth details by username and password from data store.
GetByUsernameAndPassword(username, password string) (*Auth, error)
// GetByRefreshToken returns an auth details by refreshToken from data store.
GetByRefreshToken(refreshToken string) (*Auth, error)
// Create persists a new auth to data store.
Create(*Auth) error
// Update persists auth changes to data store.
Update(*Auth) error
}
AuthStorage defines operation for auth records.
type BanService ¶ added in v0.23.0
type BanService struct {
// contains filtered or unexported fields
}
func NewHammerService ¶ added in v0.23.0
func NewHammerService(us UserStorage, ms MarketStorage) *BanService
NewHammerService returns a new Ban service.
func (*BanService) Ban ¶ added in v0.23.0
func (s *BanService) Ban(ctx context.Context, p HammerParams) (*User, error)
func (*BanService) Suspend ¶ added in v0.23.0
func (s *BanService) Suspend(ctx context.Context, p HammerParams) (*User, error)
type Catalog ¶
type Catalog struct {
ID string `json:"id" db:"id,omitempty"`
Slug string `json:"slug" db:"slug,omitempty,indexed"`
Name string `json:"name" db:"name,omitempty,indexed"`
Hero string `json:"hero" db:"hero,omitempty,indexed"`
Image string `json:"image" db:"image,omitempty"`
Origin string `json:"origin" db:"origin,omitempty,indexed"`
Rarity string `json:"rarity" db:"rarity,omitempty,indexed"`
Contributors []string `json:"-" db:"contributors,omitempty"`
ViewCount int `json:"view_count" db:"view_count,omitempty,indexed"`
// Market summary details.
Quantity int `json:"quantity" db:"quantity,omitempty"`
LowestAsk float64 `json:"lowest_ask" db:"lowest_ask,omitempty"`
MedianAsk float64 `json:"median_ask" db:"median_ask,omitempty"`
RecentAsk *time.Time `json:"recent_ask" db:"recent_ask,omitempty,indexed"`
HighestBid float64 `json:"highest_bid" db:"highest_bid,omitempty"`
RecentBid *time.Time `json:"recent_bid" db:"recent_bid,omitempty,indexed"`
BidCount int `json:"bid_count" db:"bid_count,omitempty"`
ReservedCount int `json:"reserved_count" db:"reserved_count,omitempty"`
SoldCount int `json:"sold_count" db:"sold_count,omitempty"`
// Sale summary details are derived from reserved and sold status and not the same as sold.
SaleCount int `json:"sale_count" db:"sale_count,omitempty"`
AvgSale float64 `json:"avg_sale" db:"avg_sale,omitempty"`
RecentSale *time.Time `json:"recent_sale" db:"recent_sale,omitempty"`
CreatedAt *time.Time `json:"created_at" db:"created_at,omitempty,indexed"`
UpdatedAt *time.Time `json:"updated_at" db:"updated_at,omitempty,indexed"`
// Include related fields.
Asks []Market `json:"asks" db:"-"`
Bids []Market `json:"bids" db:"-"`
}
Catalog represents item market information.
type CatalogStorage ¶
type CatalogStorage interface {
// Find returns a list of catalogs from data store.
Find(opts FindOpts) ([]Catalog, error)
// Count returns number of catalog from data store.
Count(FindOpts) (int, error)
// Get returns catalog details by id from data store.
Get(id string) (*Catalog, error)
// Index persists a new catalog to data store.
Index(itemID string) (*Catalog, error)
// Trending returns a list if top 10 trending catalog.
Trending() ([]Catalog, error)
}
CatalogStorage defines operation for market indexed items.
type Delivery ¶
type Delivery struct {
ID string `json:"id" db:"id,omitempty,omitempty"`
MarketID string `json:"market_id" db:"market_id,omitempty,indexed" valid:"required"`
BuyerConfirmed *bool `json:"buyer_confirmed" db:"buyer_confirmed,omitempty"`
BuyerConfirmedAt *time.Time `json:"buyer_confirmed_at" db:"buyer_confirmed_at,omitempty"`
GiftOpened *bool `json:"gift_opened" db:"gift_opened,omitempty"`
Status DeliveryStatus `json:"status" db:"status,omitempty,indexed" valid:"required"`
Assets []SteamAsset `json:"steam_assets" db:"steam_assets,omitempty"`
Retries int `json:"retries" db:"retries,omitempty"`
VerifiedBy string `json:"verified_by" db:"verified_by,omitempty,indexed"`
ElapsedMs int64 `json:"elapsed_ms" db:"elapsed_ms,omitempty,indexed"`
CreatedAt *time.Time `json:"created_at" db:"created_at,omitempty,indexed,omitempty"`
UpdatedAt *time.Time `json:"updated_at" db:"updated_at,omitempty,indexed,omitempty"`
}
Delivery represents steam inventory delivery.
func (Delivery) AddAssets ¶
func (d Delivery) AddAssets(sa []SteamAsset) *Delivery
AddAssets handles addition of assets and remove duplicates.
func (Delivery) CheckCreate ¶
CheckCreate validates field on creating new delivery.
func (Delivery) IsGiftOpened ¶
func (Delivery) RetriesExceeded ¶
RetriesExceeded when it reached DeliveryRetryLimit reties.
type DeliveryService ¶
type DeliveryService interface {
// Deliveries return a list of deliveries.
Deliveries(opts FindOpts) ([]Delivery, *FindMetadata, error)
// Delivery returns Delivery details by id.
Delivery(id string) (*Delivery, error)
// Set saves new Delivery details.
Set(context.Context, *Delivery) error
}
DeliveryService provides access to Delivery service.
func NewDeliveryService ¶ added in v0.23.0
func NewDeliveryService(rs DeliveryStorage, ms MarketStorage) DeliveryService
NewDeliveryService returns a new delivery service.
type DeliveryStatus ¶
type DeliveryStatus uint
DeliveryStatus represents delivery status.
const ( // DeliveryStatusNoHit buyer's inventory successfully parsed, // but the item did not find any in match. DeliveryStatusNoHit DeliveryStatus = 100 // DeliveryStatusNameVerified item exists on buyer's inventory base on the item name challenge. // // No-gift info might mean: // 1. Buyer cleared the gift information // 2. Buyer is the original owner of item // 3. Item might come from another source DeliveryStatusNameVerified DeliveryStatus = 200 // DeliveryStatusSenderVerified both item existence and gift information matched the seller's avatar name. We could // also use the date received to check against delivery data to strengthen its validity. DeliveryStatusSenderVerified DeliveryStatus = 300 // DeliveryStatusPrivate buyer's inventory is not visible to the public, and we can do nothing about it. DeliveryStatusPrivate DeliveryStatus = 400 // DeliveryStatusError error occurred during API request or parsing inventory error. DeliveryStatusError DeliveryStatus = 500 )
Delivery statuses.
func (DeliveryStatus) String ¶
func (s DeliveryStatus) String() string
String returns text value of a delivery status.
type DeliveryStorage ¶
type DeliveryStorage interface {
// Find returns a list of deliveries from data store.
Find(opts FindOpts) ([]Delivery, error)
// Count returns number of deliveries from data store.
Count(FindOpts) (int, error)
// Get returns Delivery details by id from data store.
Get(id string) (*Delivery, error)
// GetByMarketID returns Delivery details by market id from data store.
GetByMarketID(marketID string) (*Delivery, error)
// Create persists a new Delivery to data store.
Create(*Delivery) error
// Update save changes of Delivery to data store.
Update(*Delivery) error
// ToVerify returns a list of deliveries to process from data store.
ToVerify(opts FindOpts) ([]Delivery, error)
}
DeliveryStorage defines operation for Delivery records.
type Errors ¶
type Errors uint
Errors represents app's error.
const ( CatalogErrNotFound Errors = iota + catalogErrorIndex CatalogErrRequiredID CatalogErrIndexing )
Catalog error types.
const ( DeliveryErrNotFound Errors = iota + deliveryErrorIndex DeliveryErrRequiredID DeliveryErrRequiredFields )
Delivery error types.
const ( InventoryErrNotFound Errors = iota + inventoryErrorIndex InventoryErrRequiredID InventoryErrRequiredFields )
Inventory error types.
Image error types.
const ( ItemErrNotFound Errors = iota + itemErrorIndex ItemErrRequiredID ItemErrRequiredFields ItemErrCreateItemExists ItemErrImport )
Item error types.
const ( MarketErrNotFound Errors = iota + marketErrorIndex MarketErrRequiredID MarketErrRequiredFields MarketErrInvalidStatus MarketErrNotesLimit MarketErrInvalidPrice MarketErrQtyLimitPerUser MarketErrRequiredPartnerURL MarketErrInvalidBidPrice MarketErrInvalidAskPrice )
Market error types.
const ( ReportErrNotFound Errors = iota + reportErrorIndex ReportErrRequiredID ReportErrRequiredFields )
Report error types.
type FileManager ¶
type FileManager interface {
// Save saves file and returns a file name.
Save(r io.Reader) (filename string, err error)
// SaveWithName saves file with pre-defined base name.
SaveWithName(r io.Reader, baseName string) (filename string, err error)
// Get return file path base on file name.
Get(filename string) (path string, err error)
// Delete uploaded file base on file name.
Delete(filename string) error
// Dir returns save path location.
Dir() string
}
FileManager defines operation for file on local file system.
type FindMetadata ¶
FindMetadata represents find metadata.
type FindOpts ¶
type FindOpts struct {
Keyword string
KeywordFields []string
Filter any
UserID string
Sort string
Desc bool
Page int
Limit int
Fields []string
WithMeta bool
// Advance options
IndexSorting bool // Use for sorting indexed field.
IndexKey string
}
FindOpts represents find options.
type HammerParams ¶
HammerParams represents parameters to drop some suspension and bans.
func (HammerParams) Validate ¶
func (p HammerParams) Validate() error
type HammerService ¶
type HammerService interface {
// Ban updates user status to ban and cancels all listings.
//
// "Drops the hammer to its eternal doom" is most likely to be permanent.
Ban(context.Context, HammerParams) (*User, error)
// Suspend updates user status to suspend and cancels all listings.
//
// Fits for those light and abusive offenders. might forget to lift if not reminded.
Suspend(context.Context, HammerParams) (*User, error)
// Lift update user status to "marked" and remove its ban or suspend a flag
// and will restore items if requested.
Lift(ctx context.Context, steamID string, restoreListings bool) error
}
HammerService represents operation for banning and suspending accounts.
type Image ¶
type Image struct {
FileID string `json:"file_id" db:"file_id,omitempty" valid:"required"`
Caption string `json:"caption" db:"caption,omitempty"`
}
Image represents file image information.
type ImageService ¶
type ImageService interface {
// Upload saves image details and actual file to local file system.
Upload(context.Context, io.Reader) (fileID string, err error)
// Image returns image details by id.
Image(fileID string) (path string, err error)
// Thumbnail downscales an image preserving its aspect ratio to the maximum dimensions.
// It will return the original image if original sizes are smaller than the provided dimensions.
Thumbnail(fileID string, width, height uint) (path string, err error)
// Delete purges image record and from local file system.
Delete(ctx context.Context, fileID string) error
}
ImageService provides access image services.
func NewImageService ¶ added in v0.23.0
func NewImageService(fm FileManager) ImageService
NewImageService returns a new Image service.
type Inventory ¶
type Inventory struct {
ID string `json:"id" db:"id,omitempty,omitempty"`
MarketID string `json:"market_id" db:"market_id,omitempty,indexed" valid:"required"`
Status InventoryStatus `json:"status" db:"status,omitempty,indexed" valid:"required"`
Assets []SteamAsset `json:"steam_assets" db:"steam_assets,omitempty"`
Retries int `json:"retries" db:"retries,omitempty"`
BundleCount int `json:"bundle_count" db:"bundle_count,omitempty"`
VerifiedBy string `json:"verified_by" db:"verified_by,omitempty,indexed"`
ElapsedMs int64 `json:"elapsed_ms" db:"elapsed_ms,omitempty,indexed"`
CreatedAt *time.Time `json:"created_at" db:"created_at,omitempty,indexed,omitempty"`
UpdatedAt *time.Time `json:"updated_at" db:"updated_at,omitempty,indexed,omitempty"`
}
Inventory represents steam inventory.
func (Inventory) CheckCreate ¶
CheckCreate validates field on creating new inventory.
func (Inventory) CountBundles ¶
func (Inventory) RetriesExceeded ¶
RetriesExceeded when it reached 5 retries.
type InventoryService ¶
type InventoryService interface {
// Inventories returns a list of deliveries.
Inventories(opts FindOpts) ([]Inventory, *FindMetadata, error)
// Inventory returns Inventory details by id.
Inventory(id string) (*Inventory, error)
// Set saves new Inventory details.
Set(context.Context, *Inventory) error
}
InventoryService provides access to Inventory service.
func NewInventoryService ¶ added in v0.23.0
func NewInventoryService(rs InventoryStorage, ms MarketStorage, cs CatalogStorage) InventoryService
NewInventoryService returns new inventory service.
type InventoryStatus ¶
type InventoryStatus uint
InventoryStatus represents inventory status.
const ( // InventoryStatusNoHit buyer's inventory successfully parsed, but the item did not find any in match. InventoryStatusNoHit InventoryStatus = 100 // InventoryStatusVerified item exists on inventory base on the item name challenge. InventoryStatusVerified InventoryStatus = 200 // InventoryStatusPrivate buyer's inventory is not visible to the public, and we can do nothing about it. InventoryStatusPrivate InventoryStatus = 400 // InventoryStatusError error occurred during API request or parsing inventory error. InventoryStatusError InventoryStatus = 500 )
Inventory statuses.
func (InventoryStatus) String ¶
func (s InventoryStatus) String() string
String returns text value of an inventory status.
type InventoryStorage ¶
type InventoryStorage interface {
// Find returns a list of inventories from data store.
Find(opts FindOpts) ([]Inventory, error)
// Count returns number of inventories from data store.
Count(FindOpts) (int, error)
// Get returns an Inventory details by id from data store.
Get(id string) (*Inventory, error)
// GetByMarketID returns Inventory details by market id from data store.
GetByMarketID(marketID string) (*Inventory, error)
// Create persists a new Inventory to data store.
Create(*Inventory) error
// Update save changes of Inventory to data store.
Update(*Inventory) error
}
InventoryStorage defines operation for Inventory records.
type Item ¶
type Item struct {
ID string `json:"id" db:"id,omitempty"`
Slug string `json:"slug" db:"slug,omitempty" valid:"required"`
Name string `json:"name" db:"name,omitempty" valid:"required"`
Hero string `json:"hero" db:"hero,omitempty" valid:"required"`
Image string `json:"image" db:"image,omitempty"`
Origin string `json:"origin" db:"origin,omitempty"`
Rarity string `json:"rarity" db:"rarity,omitempty"`
Contributors []string `json:"-" db:"contributors,omitempty"`
Active *bool `json:"active" db:"active,omitempty"`
ViewCount int `json:"view_count" db:"view_count,omitempty"`
CreatedAt *time.Time `json:"created_at" db:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at" db:"updated_at,omitempty"`
}
Item represents item information.
func (Item) CheckCreate ¶
CheckCreate validates field on creating new item.
func (Item) SetDefaults ¶
SetDefaults sets default values for a new item.
type ItemImportResult ¶
type ItemImportResult struct {
Created int `json:"created"`
Updated int `json:"updated"`
Total int `json:"total"`
}
ItemImportResult represents import process result.
type ItemService ¶
type ItemService interface {
// Items returns a list of items.
Items(opts FindOpts) ([]Item, *FindMetadata, error)
// Item returns item details by id.
Item(id string) (*Item, error)
// Create saves new item details.
Create(context.Context, *Item) error
// Update saves item details changes.
Update(context.Context, *Item) error
// Import creates new item from yaml format.
Import(ctx context.Context, f io.Reader) (ItemImportResult, error)
// TopOrigins returns a list of top origin/treasure base on view count.
TopOrigins() ([]string, error)
// TopHeroes returns a list of top heroes base on view count.
TopHeroes() ([]string, error)
}
ItemService provides access to item service.
func NewItemService ¶ added in v0.23.0
func NewItemService(allowedDomains []string, is ItemStorage, fm FileManager) ItemService
NewItemService returns new Item service.
type ItemStorage ¶
type ItemStorage interface {
// Find returns a list of items from data store.
Find(opts FindOpts) ([]Item, error)
// Count returns number of items from data store.
Count(FindOpts) (int, error)
// Get returns item details by id from data store.
Get(id string) (*Item, error)
// GetBySlug returns item details slug id from data store.
GetBySlug(slug string) (*Item, error)
// Create persists a new item to data store.
Create(*Item) error
// Update persists item changes to data store.
Update(*Item) error
// IsItemExist returns an error if item already exists by name.
IsItemExist(name string) error
// AddViewCount increments item view count to data store.
AddViewCount(id string) error
}
ItemStorage defines operation for item records.
type ManualSubscriptionParam ¶
type Market ¶
type Market struct {
ID string `json:"id" db:"id,omitempty"`
UserID string `json:"user_id" db:"user_id,omitempty,indexed" valid:"required"`
ItemID string `json:"item_id" db:"item_id,omitempty,indexed" valid:"required"`
Type MarketType `json:"type" db:"type,omitempty,indexed" valid:"required"`
Status MarketStatus `json:"status" db:"status,omitempty,indexed" valid:"required"`
Price float64 `json:"price" db:"price,omitempty,indexed" valid:"required"`
Currency string `json:"currency" db:"currency,omitempty"`
PartnerSteamID string `json:"partner_steam_id" db:"partner_steam_id,indexed,omitempty"`
Notes string `json:"notes" db:"notes,omitempty"`
CreatedAt *time.Time `json:"created_at" db:"created_at,omitempty,indexed"`
UpdatedAt *time.Time `json:"updated_at" db:"updated_at,omitempty,indexed"`
InventoryStatus InventoryStatus `json:"inventory_status" db:"inventory_status,omitempty,indexed"`
DeliveryStatus DeliveryStatus `json:"delivery_status" db:"delivery_status,omitempty,indexed"`
// Include related fields.
User *User `json:"user,omitempty" db:"user,omitempty"`
Item *Item `json:"item,omitempty" db:"item,omitempty"`
Delivery *Delivery `json:"delivery,omitempty" db:"delivery,omitempty"`
Inventory *Inventory `json:"inventory,omitempty" db:"inventory,omitempty"`
// reselling details.
Resell *bool `json:"resell" db:"resell,omitempty"`
SellerSteamID string `json:"seller_steam_id" db:"seller_steam_id,omitempty"`
// Search Indexing.
SearchText string `json:"-" db:"search_text,omitempty,indexed"`
UserRankScore int `json:"user_rank_score" db:"user_rank_score,omitempty,indexed"`
}
Market represents market information.
func (Market) CheckCreate ¶
CheckCreate validates field on creating new market.
func (Market) CheckUpdate ¶
CheckUpdate validates field on updating market.
func (Market) SetDefaults ¶
SetDefaults sets default values for a new market.
type MarketSaleSummary ¶
type MarketSalesGraph ¶
type MarketService ¶
type MarketService interface {
// Markets returns a list of markets.
Markets(ctx context.Context, opts FindOpts) ([]Market, *FindMetadata, error)
// Market returns market details by id.
Market(ctx context.Context, id string) (*Market, error)
// Create saves new market details.
Create(context.Context, *Market) error
// Update saves market details changes.
Update(context.Context, *Market) error
// UpdateUserRankScore sets new user ranking score on all live markets by user id.
UpdateUserRankScore(userID string) error
// AutoCompleteBid detects if there's a matching reservation on buy order and automatically
// resolve it by setting complete-bid status.
AutoCompleteBid(ctx context.Context, ask Market, partnerSteamID string) error
// Catalog returns a list of catalogs.
Catalog(opts FindOpts) ([]Catalog, *FindMetadata, error)
// CatalogDetails returns catalog details by item id.
CatalogDetails(id string, opts FindOpts) (*Catalog, error)
// TrendingCatalog returns a top 10 trending catalogs.
TrendingCatalog(opts FindOpts) ([]Catalog, *FindMetadata, error)
}
MarketService provides access to market service.
func NewMarketService ¶ added in v0.23.0
func NewMarketService( ss MarketStorage, us UserStorage, is ItemStorage, ts TrackStorage, cs CatalogStorage, st StatsStorage, vd DeliveryService, vi InventoryService, sc SteamClient, tp taskProcessor, lg logging.Logger, ) MarketService
NewMarketService returns new Market service.
type MarketStatus ¶
type MarketStatus uint
MarketStatus represents market status.
const ( MarketStatusPending MarketStatus = 100 MarketStatusLive MarketStatus = 200 MarketStatusReserved MarketStatus = 300 MarketStatusSold MarketStatus = 400 MarketStatusBidCompleted MarketStatus = 410 MarketStatusRemoved MarketStatus = 500 MarketStatusCancelled MarketStatus = 600 MarketStatusExpired MarketStatus = 700 )
Market statuses.
func (MarketStatus) String ¶
func (s MarketStatus) String() string
String returns text value of a market status.
type MarketStatusCount ¶
type MarketStatusCount struct {
Pending int `json:"pending" db:"pending"`
Live int `json:"live" db:"live"`
Reserved int `json:"reserved" db:"reserved"`
Sold int `json:"sold" db:"sold"`
Removed int `json:"removed" db:"removed"`
Cancelled int `json:"cancelled" db:"cancelled"`
BidLive int `json:"bid_live" db:"bid_live"`
BidCompleted int `json:"bid_completed" db:"bid_completed"`
DeliveryNoHit int `json:"delivery_no_hit" db:"delivery_no_hit"`
DeliveryNameVerified int `json:"delivery_name_verified" db:"delivery_name_verified"`
DeliverySenderVerified int `json:"delivery_sender_verified" db:"delivery_sender_verified"`
DeliveryPrivate int `json:"delivery_private" db:"delivery_private"`
DeliveryError int `json:"delivery_error" db:"delivery_error"`
InventoryNoHit int `json:"inventory_no_hit" db:"inventory_no_hit"`
InventoryVerified int `json:"inventory_verified" db:"inventory_verified"`
InventoryPrivate int `json:"inventory_private" db:"inventory_private"`
InventoryError int `json:"inventory_error" db:"inventory_error"`
ResellLive int `json:"resell_live" db:"resell_live"`
ResellReserved int `json:"resell_reserved" db:"resell_reserved"`
ResellSold int `json:"resell_sold" db:"resell_sold"`
ResellRemoved int `json:"resell_removed" db:"resell_removed"`
ResellCancelled int `json:"resell_cancelled" db:"resell_cancelled"`
}
MarketStatusCount represents the total number of records per status.
type MarketStorage ¶
type MarketStorage interface {
// Find returns a list of markets from data store.
Find(opts FindOpts) ([]Market, error)
// Count returns number of market from data store.
Count(FindOpts) (int, error)
// Get returns a market details by id from data store.
Get(id string) (*Market, error)
// Create persists a new market to data store.
Create(*Market) error
// Update persists market changes to data store.
Update(*Market) error
// BaseUpdate persists market changes to data store and
// will not update updated_at field.
BaseUpdate(*Market) error
// PendingInventoryStatus returns market entries that is pending for checking
// inventory status or needs re-processing of re-process error status.
PendingInventoryStatus(o FindOpts) ([]Market, error)
// PendingDeliveryStatus returns market entries that is pending for checking
// delivery status or needs re-processing of re-process error status.
PendingDeliveryStatus(o FindOpts) ([]Market, error)
RevalidateDeliveryStatus(o FindOpts) ([]Market, error)
// Index composes market data for faster search and retrieval.
Index(id string) (*Market, error)
// UpdateUserScore sets new rank score value of all live markets by user ID.
UpdateUserScore(userID string, rankScore int) error
// UpdateExpiring sets live items to expired status by expiration time.
UpdateExpiring(t MarketType, b UserBoon, expiration time.Time) (itemIDs []string, err error)
BulkDeleteByStatus(ms MarketStatus, cutOff time.Time, limit int) error
UpdateExpiringResell(b UserBoon) (itemIDs []string, err error)
}
MarketStorage defines operation for market records.
type MarketType ¶
type MarketType uint
MarketType represents market type.
const ( MarketTypeAsk MarketType = 10 // default MarketTypeBid MarketType = 20 )
Market types.
type Report ¶
type Report struct {
ID string `json:"id" db:"id,omitempty"`
UserID string `json:"user_id" db:"user_id,omitempty"`
Type ReportType `json:"type" db:"type,omitempty,indexed" valid:"required"`
Label string `json:"label" db:"label,omitempty,indexed"`
Text string `json:"text" db:"text,omitempty" valid:"required"`
CreatedAt *time.Time `json:"created_at" db:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at" db:"updated_at,omitempty"`
// Include related fields.
User *User `json:"user,omitempty" db:"user,omitempty"`
}
Report represents feedback from user or system that can be used on survey and bug reporting.
func (Report) CheckCreate ¶
CheckCreate validates field on creating a new report.
type ReportService ¶
type ReportService interface {
// Reports returns a list of reports.
Reports(opts FindOpts) ([]Report, *FindMetadata, error)
// Report returns report details by id.
Report(id string) (*Report, error)
// Create saves new report details.
Create(context.Context, *Report) error
}
ReportService provides access to report service.
func NewReportService ¶ added in v0.23.0
func NewReportService(rs ReportStorage, wp webhookPoster) ReportService
NewReportService returns new report service.
type ReportStorage ¶
type ReportStorage interface {
// Find returns a list of reports from the data store.
Find(opts FindOpts) ([]Report, error)
// Count returns number of reports from data store.
Count(FindOpts) (int, error)
// Get returns report details by id from data store.
Get(id string) (*Report, error)
// Create persists a new report to data store.
Create(*Report) error
}
ReportStorage defines operation for report records.
type ReportType ¶
type ReportType uint
ReportType report types.
const ( ReportTypeFeedback ReportType = 10 ReportTypeSurvey ReportType = 20 ReportTypeBug ReportType = 30 ReportTypeScamAlert ReportType = 40 ReportTypeScamIncident ReportType = 50 )
Report types.
func (ReportType) String ¶
func (t ReportType) String() string
type SalesStatus ¶
type SearchKeywordScore ¶
type StatsService ¶
type StatsService interface {
CountMarketStatus(opts FindOpts) (*MarketStatusCount, error)
CountMarketStatusV2(opts FindOpts) (*MarketStatusCount, error)
GraphMarketSales(opts FindOpts) ([]MarketSalesGraph, error)
TopKeywords() ([]SearchKeywordScore, error)
CountUserMarketStatus(userID string) (*MarketStatusCount, error)
CountUserMarketStatusBySteamID(partnerSteamID string) (*MarketStatusCount, error)
}
StatsService provides access to stats service.
func NewStatsService ¶ added in v0.23.0
func NewStatsService(ss StatsStorage, ts TrackStorage) StatsService
NewStatsService returns new Stats service.
type StatsStorage ¶
type StatsStorage interface {
CountMarketStatus(opts FindOpts) (*MarketStatusCount, error)
CountMarketStatusV2(opts FindOpts) (*MarketStatusCount, error)
GraphMarketSales(opts FindOpts) ([]MarketSalesGraph, error)
CountUserMarketStatus(userID string) (*MarketStatusCount, error)
CountUserMarketStatusBySteamID(partnerSteamID string) (*MarketStatusCount, error)
}
type SteamAsset ¶
type SteamAsset struct {
AssetID string `json:"asset_id" db:"asset_id,omitempty"`
ClassID string `json:"class_id" db:"class_id,omitempty"` // unique id of an item
InstanceID string `json:"instance_id" db:"instance_id,omitempty"`
Qty int `json:"qty" db:"qty,omitempty"`
Name string `json:"name" db:"name,omitempty"`
Image string `json:"image" db:"image,omitempty"`
Type string `json:"type" db:"type,omitempty"`
Hero string `json:"hero" db:"hero,omitempty"`
GiftFrom string `json:"gift_from" db:"gift_from,omitempty"`
Contains string `json:"contains" db:"contains,omitempty"`
DateReceived string `json:"date_received" db:"date_received,omitempty"`
Dedication string `json:"dedication" db:"dedication,omitempty"`
GiftOnce bool `json:"gift_once" db:"gift_once,omitempty"`
NotTradable bool `json:"not_tradable" db:"not_tradable,omitempty"`
Descriptions []string `json:"descriptions" db:"descriptions,omitempty"`
}
SteamAsset represents a simplified version of inventory item.
func (*SteamAsset) IsBundled ¶
func (s *SteamAsset) IsBundled() bool
func (*SteamAsset) IsBundledVariant ¶
func (s *SteamAsset) IsBundledVariant(name string) bool
IsBundledVariant detects the asset if it's a bundle variant and its common pattern that ends with string "GOLDEN"
func (*SteamAsset) IsCollectorsCache ¶
func (s *SteamAsset) IsCollectorsCache() bool
func (*SteamAsset) IsGoldenVariant ¶
func (s *SteamAsset) IsGoldenVariant(name string) bool
IsGoldenVariant detects the asset if it's a golden variant and its common pattern that starts with string "GOLDEN"
func (*SteamAsset) IsImmortal ¶
func (s *SteamAsset) IsImmortal() bool
func (*SteamAsset) StillWrapped ¶
func (s *SteamAsset) StillWrapped() bool
type SteamClient ¶
type SteamClient interface {
// AuthorizeURL returns authorization url to steam open id.
AuthorizeURL(r *http.Request) (redirectURL string, err error)
// Authenticate returns a player info on valid authorization.
Authenticate(r *http.Request) (*SteamPlayer, error)
// Player returns player summary base on steamID.
Player(steamID string) (*SteamPlayer, error)
// ResolveVanityURL returns steam id from profile url.
ResolveVanityURL(url string) (steamID string, err error)
}
SteamClient provides access to Steam API.
type SteamPlayer ¶
type SteamPlayer struct {
ID string `json:"id" db:"id"`
Name string `json:"name" db:"name"`
URL string `json:"url" db:"url"`
Avatar string `json:"avatar" db:"avatar"`
}
SteamPlayer represents steam player information.
type Task ¶
type Task struct {
ID string `json:"id" db:"id,omitempty,index"`
Status TaskStatus `json:"status" db:"status,index"`
Priority TaskPriority `json:"priority" db:"priority,omitempty,index"`
Type TaskType `json:"type" db:"type,omitempty,index"`
Payload any `json:"payload" db:"payload,omitempty"`
Retry int `json:"retry" db:"retry,omitempty"`
Note string `json:"note" db:"note,omitempty"`
ElapsedMs int64 `json:"elapsed_ms" db:"elapsed_ms,omitempty"`
CreatedAt *time.Time `json:"created_at" db:"created_at,omitempty,index"`
UpdatedAt *time.Time `json:"updated_at" db:"updated_at,omitempty"`
}
Task represents task data model.
type TaskPriority ¶
type TaskPriority uint8
TaskPriority represent task priority.
const ( TaskPriorityHigh TaskPriority = 1 TaskPriorityMedium TaskPriority = 2 TaskPriorityLow TaskPriority = 3 )
Task priorities.
func (TaskPriority) String ¶
func (p TaskPriority) String() string
type TaskStatus ¶
type TaskStatus uint8
TaskStatus represent task status.
const ( TaskStatusPending TaskStatus = 0 TaskStatusProcessing TaskStatus = 1 TaskStatusDone TaskStatus = 2 TaskStatusError TaskStatus = 6 )
Task status.
func (TaskStatus) String ¶
func (s TaskStatus) String() string
type Track ¶
type Track struct {
ID string `json:"id" db:"id,omitempty"`
Type string `json:"type" db:"type,omitempty,indexed"`
ItemID string `json:"item_id" db:"item_id,omitempty,indexed"`
UserID string `json:"user_id" db:"user_id,omitempty,indexed"`
Keyword string `json:"keyword" db:"keyword,omitempty"`
ClientIP string `json:"client_ip" db:"client_ip,omitempty"`
UserAgent string `json:"user_agent" db:"user_agent,omitempty"`
Referer string `json:"referer" db:"referer,omitempty"`
Cookies []string `json:"cookies" db:"cookies,omitempty"`
SessUserID string `json:"sess_user_id" db:"sess_user_id,omitempty"`
CreatedAt time.Time `json:"created_at" db:"created_at,omitempty,indexed"`
}
Track represents tracking data.
func (*Track) SetDefaults ¶
SetDefaults sets default values from http.Request.
type TrackService ¶
type TrackService interface {
// Tracks returns a list of tracks.
Tracks(FindOpts) ([]Track, *FindMetadata, error)
// Track returns track details by id.
Track(id string) (*Track, error)
// CreateFromRequest saves new track from http request. Primarily used on client side.
CreateFromRequest(r *http.Request) error
// CreateSearchKeyword saves new keyword tracking data.
CreateSearchKeyword(r *http.Request, keyword string) error
}
TrackService provides access to track service.
func NewTrackService ¶ added in v0.23.0
func NewTrackService(ts TrackStorage, ps ItemStorage) TrackService
NewTrackService returns new track service.
type TrackStorage ¶
type TrackStorage interface {
// Find returns a list of tracks from data store.
Find(FindOpts) ([]Track, error)
// Count returns number of tracks from data store.
Count(FindOpts) (int, error)
// Get returns track details by id from data store.
Get(id string) (*Track, error)
// Create persists a new track to data store.
Create(*Track) error
// TopKeywords returns top search keywords this week.
TopKeywords() ([]SearchKeywordScore, error)
}
TrackStorage defines operation for track records.
type User ¶
type User struct {
ID string `json:"id" db:"id,omitempty"`
SteamID string `json:"steam_id" db:"steam_id,indexed,omitempty" valid:"required"`
Name string `json:"name" db:"name,omitempty" valid:"required"`
URL string `json:"url" db:"url,omitempty" valid:"required"`
Avatar string `json:"avatar" db:"avatar,omitempty" valid:"required"`
Status UserStatus `json:"status" db:"status,indexed,omitempty"`
Notes string `json:"notes" db:"notes,omitempty"`
Donation float64 `json:"donation" db:"donation,omitempty"`
DonatedAt *time.Time `json:"donated_at" db:"donated_at,omitempty"`
CreatedAt *time.Time `json:"created_at" db:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at" db:"updated_at,omitempty"`
MarketStats MarketStatusCount `json:"market_stats" db:"market_stats,omitempty"`
RankScore int `json:"rank_score" db:"rank_score,omitempty"`
Subscription UserSubscription `json:"subscription" db:"subscription,indexed,omitempty"`
SubscribedAt *time.Time `json:"subscribed_at" db:"subscribed_at,omitempty"`
SubscriptionType string `json:"subscription_type" db:"subscription_type"`
SubscriptionEndsAt *time.Time `json:"subscription_ends_at" db:"subscription_ends_at,omitempty"`
Boons []string `json:"boons" db:"boons,omitempty"`
Hammer bool `json:"hammer" db:"hammer,omitempty"`
}
User represents user information.
func (User) CalcRankScore ¶
func (u User) CalcRankScore(stats MarketStatusCount) *User
CalcRankScore return user score base on profile and market activity.
func (User) CheckCreate ¶
CheckCreate validates field on creating new user.
func (User) CheckStatus ¶
CheckStatus checks for reported and banned status.
func (User) CheckUpdate ¶
CheckUpdate validates field on update user.
func (User) TaskPriorityQueue ¶
func (u User) TaskPriorityQueue() TaskPriority
type UserService ¶
type UserService interface {
// Users returns a list of users.
Users(opts FindOpts) ([]User, error)
// FlaggedUsers returns a list of flagged/reported users.
FlaggedUsers(opts FindOpts) ([]User, error)
// User returns user details by id.
User(id string) (*User, error)
// Create saves new user and download profile image to local file.
Create(*User) error
// UserFromContext returns user details from context.
UserFromContext(context.Context) (*User, error)
// Update saves user changes.
Update(context.Context, *User) error
// SteamSync saves updated steam info.
SteamSync(sp *SteamPlayer) (*User, error)
// ProcessSubscription validates and process subscription features.
ProcessSubscription(ctx context.Context, subscriptionID string) (*User, error)
// UpdateSubscriptionFromWebhook handles user subscription updates form http request.
UpdateSubscriptionFromWebhook(ctx context.Context, r *http.Request) (*User, error)
ProcessManualSubscription(ctx context.Context, form ManualSubscriptionParam) (*User, error)
}
UserService provides access to user service.
func NewUserService ¶ added in v0.23.0
func NewUserService(us UserStorage, fm FileManager, sc subscriptionChecker) UserService
NewUserService returns a new User service.
type UserStatus ¶
type UserStatus uint
const ( UserStatusSuspended UserStatus = 300 UserStatusBanned UserStatus = 400 )
User statuses.
type UserStorage ¶
type UserStorage interface {
// Find returns a list of users from data store.
Find(opts FindOpts) ([]User, error)
// FindFlagged returns a list of flagged users from data store.
FindFlagged(opts FindOpts) ([]User, error)
// Get returns user details by id from data store.
Get(id string) (*User, error)
// Create persists a new user to data store.
Create(*User) error
// Update persists user changes to data store.
Update(*User) error
// BaseUpdate persists user changes to data store without updating metadata.
BaseUpdate(*User) error
// ExpiringSubscribers return a list of users that has expiring subscription.
ExpiringSubscribers(ctx context.Context, now time.Time) ([]User, error)
// PurgeSubscription removes subscription data and boons.
PurgeSubscription(ctx context.Context, userID string) error
}
UserStorage defines operation for user records.
type UserSubscription ¶
type UserSubscription uint
const ( UserSubscriptionResell UserSubscription = 1 UserSubscriptionSupporter UserSubscription = 100 UserSubscriptionTrader UserSubscription = 101 UserSubscriptionPartner UserSubscription = 109 )
func UserSubscriptionFromString ¶
func UserSubscriptionFromString(s string) UserSubscription
func (UserSubscription) Boons ¶
func (s UserSubscription) Boons() []string
func (UserSubscription) String ¶
func (s UserSubscription) String() string
type Version ¶
type Version struct {
Production bool `json:"production"`
Tag string `json:"version"`
Commit string `json:"hash"`
Built string `json:"built"`
}
Version represents application version.
func NewVersion ¶
NewVersion returns a formatted version details.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
dxserver
command
|
|
|
dxworker
command
|
|
|
filecache/example
command
|
|
|
Package paypal is copied from https://github.com/plutov/paypal because I don't want to import the library and lazy to write a client, app just needs a few things.
|
Package paypal is copied from https://github.com/plutov/paypal because I don't want to import the library and lazy to write a client, app just needs a few things. |
|
example
command
|
|
|
example
command
|
|
|
example
command
|
|
|
tools
|
|
|
inventoryparser
command
|
|
|
logparser
command
|
|
|
example/delivery
command
|
|
|
example/inventory
command
|
|