cardtrader

package
v0.0.0-...-2cfd05f Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 18 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MaxBulkUploadItems = 450

	GameIdMagic = 1
)
View Source
const (
	CategoryMagicSingles = iota + 1
	CategoryMagicTokens
	CategoryMagicOversized
	CategoryMagicBoosterBoxes
	CategoryMagicBoosters
	CategoryMagicCompleteSets
	CategoryMagicStarterDecks
	CategoryMagicEmptyPackaging
	CategoryMagicBooks
	CategoryMagicBoxDisplays

	CategoryMagicSleeves
	CategoryMagicBoxedSet

	CategoryMagicAlbums
	CategoryMagicDeckBoxes
	CategoryMagicPreconstructedDecks
	CategoryMagicMemorabilia
	CategoryMagicPlaymats
	CategoryMagicLifeCounter
	CategoryMagicCardStorage
	CategoryMagicDice
	CategoryMagicBundles
	CategoryMagicTournamentPrereleasePacks
	CategoryMagicDividers
	CategoryMagicBinderPages

	CategoryMagicGamingStones
)

Variables

This section is empty.

Functions

func ConvertItems

func ConvertItems(blueprints map[int]*Blueprint, products []OrderItem, rates ...float64) mtgban.InventoryRecord

func ConvertProducts

func ConvertProducts(blueprints map[int]*Blueprint, products []Product, rates ...float64) mtgban.InventoryRecord

func FormatBlueprints

func FormatBlueprints(blueprints []Blueprint, inExpansions []Expansion, sealed bool) (map[int]*Blueprint, map[int]string)

func Preprocess

func Preprocess(bp *Blueprint) (*mtgmatcher.Card, error)

Types

type Blueprint

type Blueprint struct {
	Id         int    `json:"id"`
	Name       string `json:"name"`
	Version    string `json:"version"`
	CategoryId int    `json:"category_id"`
	GameId     int    `json:"game_id"`
	Slug       string `json:"slug"`
	ScryfallId string `json:"scryfall_id"`
	Expansion  struct {
		Name string `json:"name"`
		Code string `json:"code"`
	} `json:"expansion"`
	// Returned by product
	Properties struct {
		Number   string `json:"collector_number"`
		Language string `json:"mtg_language"`
	} `json:"properties_hash"`
	// Returned by market
	FixedProperties struct {
		Number   string `json:"collector_number"`
		Language string `json:"mtg_language"`
	} `json:"fixed_properties"`
	ExpansionId int `json:"expansion_id"`
}

type BlueprintError

type BlueprintError struct {
	ErrorCode string   `json:"error_code"`
	Errors    []string `json:"errors"`
	Extra     struct {
		Message string `json:"message"`
	} `json:"extra"`
	RequestId string `json:"request_id"`
}

type BlueprintFilter

type BlueprintFilter struct {
	Blueprint Blueprint `json:"blueprint"`
	Products  []Product `json:"products"`
}

type BulkProduct

type BulkProduct struct {
	// The id of the Product to edit
	Id int `json:"id,omitempty"`

	// The id of the Blueprint to put on sale
	BlueprintId int `json:"blueprint_id,omitempty"`

	// The price of the product, indicated in your current currency
	Price float64 `json:"price,omitempty"`

	// The quantity to be put up for sale
	Quantity int `json:"quantity,omitempty"`

	// A public-facing description field
	Description string `json:"description,omitempty"`

	// A secondary internal-only field
	UserDataField string `json:"user_data_field,omitempty"`

	// A list of optional properties
	Properties struct {
		Condition string `json:"condition,omitempty"`
		Language  string `json:"mtg_language,omitempty"`
		Foil      bool   `json:"mtg_foil,omitempty"`
		Signed    bool   `json:"signed,omitempty"`
		Altered   bool   `json:"altered,omitempty"`
	} `json:"properties,omitempty"`
}

This is slightly different from the main Product type

type CTAuthClient

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

func NewCTAuthClient

func NewCTAuthClient(token string) *CTAuthClient

func (*CTAuthClient) AddProductToCart

func (ct *CTAuthClient) AddProductToCart(productId, quantity int, zero bool) (*CTCartResponse, error)

func (*CTAuthClient) Blueprints

func (ct *CTAuthClient) Blueprints(expansionId int) ([]Blueprint, error)

func (*CTAuthClient) BulkCreate

func (ct *CTAuthClient) BulkCreate(products []BulkProduct) ([]string, error)

Create new listings using the products slice, separating into multiple requests if there are more than MaxBulkUploadItems elements. A list of job ids is returned to monitor the execution status.

func (*CTAuthClient) BulkDelete

func (ct *CTAuthClient) BulkDelete(products []BulkProduct) ([]string, error)

Delete existing listings using the products slice, separating into multiple requests if there are more than MaxBulkUploadItems elements. A list of job ids is returned to monitor the execution status.

func (*CTAuthClient) BulkUpdate

func (ct *CTAuthClient) BulkUpdate(products []BulkProduct) ([]string, error)

Update existing listings using the products slice, separating into multiple requests if there are more than MaxBulkUploadItems elements. A list of job ids is returned to monitor the execution status.

func (*CTAuthClient) Expansions

func (ct *CTAuthClient) Expansions() ([]Expansion, error)

func (*CTAuthClient) ExportStock

func (ct *CTAuthClient) ExportStock(blueprints map[int]*Blueprint) (mtgban.InventoryRecord, error)

Use the Simple API Token to convert your own inventory to a standard InventoryRecord

func (*CTAuthClient) ProductsExport

func (ct *CTAuthClient) ProductsExport() ([]Product, error)

func (*CTAuthClient) ProductsForExpansion

func (ct *CTAuthClient) ProductsForExpansion(id int) (map[int][]Product, error)

Returns all products from an Expansion, with the 15 cheapest listings per product

type CTCartResponse

type CTCartResponse struct {
	ID       int `json:"id"`
	Subcarts []struct {
		ID     int `json:"id"`
		Seller struct {
			ID       int    `json:"id"`
			Username string `json:"username"`
		} `json:"seller"`
		CartItems []struct {
			Quantity      int    `json:"quantity"`
			PriceCents    int    `json:"price_cents"`
			PriceCurrency string `json:"price_currency"`
			Product       struct {
				ID     int    `json:"id"`
				NameEn string `json:"name_en"`
			} `json:"product"`
		} `json:"cart_items"`
	} `json:"subcarts"`

	Subtotal                         CTPrice `json:"subtotal"`
	SafeguardFeeAmount               CTPrice `json:"safeguard_fee_amount"`
	CtZeroFeeAmount                  CTPrice `json:"ct_zero_fee_amount"`
	PaymentMethodFeePercentageAmount CTPrice `json:"payment_method_fee_percentage_amount"`
	PaymentMethodFeeFixedAmount      CTPrice `json:"payment_method_fee_fixed_amount"`
	ShippingCost                     CTPrice `json:"shipping_cost"`

	ErrorCode string `json:"error_code"`
	Extra     struct {
		Message string `json:"message"`
	} `json:"extra"`
	RequestID string `json:"request_id"`
}

type CTClient

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

func NewCTClient

func NewCTClient() *CTClient

func (*CTClient) ProductsForBlueprint

func (ct *CTClient) ProductsForBlueprint(id int) (*BlueprintFilter, error)

type CTLoggedClient

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

func NewCTLoggedClient

func NewCTLoggedClient(user, pass string) (*CTLoggedClient, error)

func (*CTLoggedClient) Add2Cart

func (ct *CTLoggedClient) Add2Cart(productId int, qty int, bundle bool) error

func (*CTLoggedClient) GetItemsForOrder

func (ct *CTLoggedClient) GetItemsForOrder(orderId int) ([]OrderItem, error)

func (*CTLoggedClient) NewToken

func (ct *CTLoggedClient) NewToken() (string, error)

type CTPrice

type CTPrice struct {
	Cents       int    `json:"cents"`
	CurrencyIso string `json:"currency_iso"`
}

type CardtraderMarket

type CardtraderMarket struct {
	LogCallback mtgban.LogCallbackFunc

	MaxConcurrency int
	ShareCode      string

	// Only retrieve data from a single edition
	TargetEdition string

	// Keep same-conditions entries
	KeepDuplicates bool
	// contains filtered or unexported fields
}

func NewScraperMarket

func NewScraperMarket(token string) (*CardtraderMarket, error)

func (*CardtraderMarket) Activate

func (ct *CardtraderMarket) Activate(user, pass string) error

func (*CardtraderMarket) Add

func (*CardtraderMarket) Info

func (ct *CardtraderMarket) Info() (info mtgban.ScraperInfo)

func (*CardtraderMarket) InitializeInventory

func (ct *CardtraderMarket) InitializeInventory(reader io.Reader) error

func (*CardtraderMarket) Inventory

func (ct *CardtraderMarket) Inventory() (mtgban.InventoryRecord, error)

func (*CardtraderMarket) InventoryForSeller

func (ct *CardtraderMarket) InventoryForSeller(sellerName string) (mtgban.InventoryRecord, error)

func (*CardtraderMarket) MarketNames

func (tcg *CardtraderMarket) MarketNames() []string

type CardtraderSealed

type CardtraderSealed struct {
	LogCallback    mtgban.LogCallbackFunc
	MaxConcurrency int
	ShareCode      string

	// Only retrieve data from a single edition
	TargetEdition string
	// contains filtered or unexported fields
}

func NewScraperSealed

func NewScraperSealed(token string) (*CardtraderSealed, error)

func (*CardtraderSealed) Info

func (ct *CardtraderSealed) Info() (info mtgban.ScraperInfo)

func (*CardtraderSealed) InitializeInventory

func (ct *CardtraderSealed) InitializeInventory(reader io.Reader) error

func (*CardtraderSealed) Inventory

func (ct *CardtraderSealed) Inventory() (mtgban.InventoryRecord, error)

func (*CardtraderSealed) InventoryForSeller

func (ct *CardtraderSealed) InventoryForSeller(sellerName string) (mtgban.InventoryRecord, error)

func (*CardtraderSealed) MarketNames

func (tcg *CardtraderSealed) MarketNames() []string

type Expansion

type Expansion struct {
	Id     int    `json:"id"`
	GameId int    `json:"game_id"`
	Code   string `json:"code"`
	Name   string `json:"name"`
}

type OrderItem

type OrderItem struct {
	Id            int    `json:"id"`
	BlueprintId   int    `json:"blueprint_id"`
	Quantity      int    `json:"quantity"`
	Description   string `json:"description"`
	PriceCents    int    `json:"price_cents"`
	PriceCurrency string `json:"price_currency"`
	Properties    struct {
		Condition string `json:"condition"`
		Language  string `json:"mtg_language"`
		Foil      bool   `json:"mtg_foil"`
	} `json:"properties_hash"`
}

A variant of Product

type Product

type Product struct {
	Id          int    `json:"id"`
	BlueprintId int    `json:"blueprint_id"`
	Quantity    int    `json:"quantity"`
	Description string `json:"description"`
	OnVacation  bool   `json:"on_vacation"`
	Bundle      bool   `json:"bundle"`
	Properties  struct {
		Condition string `json:"condition"`
		Language  string `json:"mtg_language"`
		Number    string `json:"collector_number"`
		Foil      bool   `json:"mtg_foil"`
		Altered   bool   `json:"altered"`
		Signed    bool   `json:"signed"`
	} `json:"properties_hash"`
	User struct {
		Name        string `json:"username"`
		SinglesZero bool   `json:"can_sell_via_hub"`
		SealedZero  bool   `json:"can_sell_sealed_with_ct_zero"`
	} `json:"user"`
	Price struct {
		Cents    int    `json:"cents"`
		Currency string `json:"currency"`
	} `json:"price"`

	UserDataField string `json:"user_data_field"`
	PriceCents    int    `json:"price_cents"`
	PriceCurrency string `json:"price_currency"`
}

Jump to

Keyboard shortcuts

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