manapool

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2025 License: MIT Imports: 12 Imported by: 0

README

Manapool Go Client

⚠️ Pre-Release (v0.2.0): This library is under active development. The API may change before v1.0.0. Planned features are tracked in GitHub issues GitHub issues.

A Go client library for the Manapool API. This library provides a Go interface for managing your Magic: The Gathering inventory on Manapool.

Go Reference Go Report Card

Features

Currently Implemented (v0.2.0)
  • Seller Inventory Endpoints - Get account, list inventory, lookup by TCG SKU
  • Type-Safe - Full Go type definitions for all API models
  • Automatic Rate Limiting - Built-in rate limiter to respect API limits
  • Automatic Retries - Configurable retry logic with exponential backoff
  • Context Support - First-class context support for cancellation and timeouts
  • Error Handling - Specific error types with helper methods
  • Tested - 96.5% test coverage with integration tests
  • Production Use - Used in production for TCG inventory management
  • Zero Dependencies - Only depends on golang.org/x/time/rate
Planned Features

Planned features are tracked in GitHub:

  • 🔜 Additional Lookups () - Scryfall ID, product ID, TCGPlayer ID lookups
  • 🔜 Order Management () - List and view seller orders
  • 🔜 Order Fulfillment () - Mark orders as shipped/fulfilled
  • 🔜 Inventory Updates () - Create, update, delete inventory items
  • 🔜 Webhook Support () - Register and manage webhooks
  • 🔜 Release Readiness () - v1.0.0 stabilization and publishing steps
  • 🔜 Repository Extraction () - Move the client into a standalone repository

Installation

go get github.com/repricah/manapool

Quick Start

package main

import (
    "context"
    "fmt"
    "log"
    "time"

    "github.com/repricah/manapool"
)

func main() {
    // Create client with your API credentials
    client := manapool.NewClient(
        "your-api-token",
        "your-email@example.com",
        manapool.WithTimeout(30*time.Second),
        manapool.WithRateLimit(10, 1), // 10 requests/second, burst of 1
    )

    ctx := context.Background()

    // Get your seller account information
    account, err := client.GetSellerAccount(ctx)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Account: %s (%s)\n", account.Username, account.Email)
    fmt.Printf("Singles Live: %v, Sealed Live: %v\n",
        account.SinglesLive, account.SealedLive)

    // Get your inventory with pagination
    opts := manapool.InventoryOptions{
        Limit:  500, // max 500 items per request
        Offset: 0,
    }
    inventory, err := client.GetSellerInventory(ctx, opts)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Total inventory: %d items\n", inventory.Pagination.Total)

    // Print first few items
    for _, item := range inventory.Inventory {
        fmt.Printf("  %s - $%.2f (qty: %d)\n",
            item.Product.Single.Name,
            item.PriceDollars(),
            item.Quantity)
    }
}

Beads Integration

If you're using this client in Beads applications, follow the same patterns you would in Go services: configure credentials via environment variables, propagate context for cancellation, respect rate limits, and surface structured errors to the UI or logs.

client := manapool.NewClient(
    os.Getenv("MANAPOOL_TOKEN"),
    os.Getenv("MANAPOOL_EMAIL"),
    manapool.WithTimeout(30*time.Second),
    manapool.WithRateLimit(10, 1),
)

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

opts := manapool.InventoryOptions{
    Limit:  100,
    Offset: 0,
}
inventory, err := client.GetSellerInventory(ctx, opts)
if err != nil {
    var apiErr *manapool.APIError
    if errors.As(err, &apiErr) {
        // Display a user-friendly message in Beads UI.
        return
    }
    // Handle network/unknown errors.
    return
}

Beads resources:

Usage Examples

Authentication

The Manapool API uses token-based authentication with two required headers:

client := manapool.NewClient("your-api-token", "your-email@example.com")
Get Seller Account
account, err := client.GetSellerAccount(ctx)
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Account: %s\n", account.Username)
fmt.Printf("Verified: %v\n", account.Verified)
fmt.Printf("Payouts Enabled: %v\n", account.PayoutsEnabled)
Get Inventory with Pagination
opts := manapool.InventoryOptions{
    Limit:  500,
    Offset: 0,
}

inventory, err := client.GetSellerInventory(ctx, opts)
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Total: %d, Returned: %d\n",
    inventory.Pagination.Total,
    inventory.Pagination.Returned)
Iterate All Inventory

Use the helper function to automatically handle pagination:

err := manapool.IterateInventory(ctx, client, func(item *manapool.InventoryItem) error {
    fmt.Printf("%s: $%.2f (TCG SKU: %d)\n",
        item.Product.Single.Name,
        item.PriceDollars(),
        item.Product.TCGPlayerSKU)
    return nil
})
if err != nil {
    log.Fatal(err)
}
Look Up Item by TCGPlayer SKU
item, err := client.GetInventoryByTCGPlayerID(ctx, "4549403")
if err != nil {
    var apiErr *manapool.APIError
    if errors.As(err, &apiErr) && apiErr.IsNotFound() {
        fmt.Println("Item not found in inventory")
        return
    }
    log.Fatal(err)
}

fmt.Printf("Found: %s\n", item.Product.Single.Name)
fmt.Printf("Price: $%.2f\n", item.PriceDollars())
fmt.Printf("Quantity: %d\n", item.Quantity)
fmt.Printf("Condition: %s\n", item.Product.Single.ConditionName())

Configuration Options

Custom HTTP Client
customClient := &http.Client{
    Timeout: 60 * time.Second,
    Transport: &http.Transport{
        MaxIdleConns:    10,
        IdleConnTimeout: 90 * time.Second,
    },
}

client := manapool.NewClient(token, email,
    manapool.WithHTTPClient(customClient),
)
Rate Limiting
client := manapool.NewClient(token, email,
    manapool.WithRateLimit(5, 2), // 5 requests/second, burst of 2
)
Retry Configuration
client := manapool.NewClient(token, email,
    manapool.WithRetry(5, 2*time.Second), // 5 retries, 2s initial backoff
)
Custom Logger
type myLogger struct{}

func (l *myLogger) Debugf(format string, args ...interface{}) {
    log.Printf("[DEBUG] "+format, args...)
}

func (l *myLogger) Errorf(format string, args ...interface{}) {
    log.Printf("[ERROR] "+format, args...)
}

client := manapool.NewClient(token, email,
    manapool.WithLogger(&myLogger{}),
)
All Options Together
client := manapool.NewClient(token, email,
    manapool.WithHTTPClient(customHTTP),
    manapool.WithBaseURL("https://custom.api.com/v1/"),
    manapool.WithRateLimit(10, 1),
    manapool.WithRetry(3, time.Second),
    manapool.WithTimeout(30*time.Second),
    manapool.WithUserAgent("my-app/1.0"),
    manapool.WithLogger(logger),
)

Error Handling

The library provides specific error types for different scenarios:

API Errors
inventory, err := client.GetSellerInventory(ctx, opts)
if err != nil {
    var apiErr *manapool.APIError
    if errors.As(err, &apiErr) {
        switch {
        case apiErr.IsNotFound():
            fmt.Println("Resource not found")
        case apiErr.IsUnauthorized():
            fmt.Println("Invalid credentials")
        case apiErr.IsForbidden():
            fmt.Println("Access denied")
        case apiErr.IsRateLimited():
            fmt.Println("Rate limit exceeded")
        case apiErr.IsServerError():
            fmt.Println("Server error, retry later")
        default:
            fmt.Printf("API error: %v\n", apiErr)
        }
        return
    }
    log.Fatal(err)
}
Validation Errors
item, err := client.GetInventoryByTCGPlayerID(ctx, "")
if err != nil {
    var valErr *manapool.ValidationError
    if errors.As(err, &valErr) {
        fmt.Printf("Validation error for %s: %s\n", valErr.Field, valErr.Message)
        return
    }
}
Network Errors
inventory, err := client.GetSellerInventory(ctx, opts)
if err != nil {
    var netErr *manapool.NetworkError
    if errors.As(err, &netErr) {
        fmt.Printf("Network error: %v\n", netErr)
        // Maybe retry with exponential backoff
        return
    }
}

Type Definitions

Account
type Account struct {
    Username       string
    Email          string
    Verified       bool
    SinglesLive    bool
    SealedLive     bool
    PayoutsEnabled bool
}
InventoryItem
type InventoryItem struct {
    ID            string
    ProductType   string
    ProductID     string
    Product       Product
    PriceCents    int      // Price in cents
    Quantity      int
    EffectiveAsOf Timestamp
}

// Helper methods
func (i InventoryItem) PriceDollars() float64 // Convert cents to dollars
Product
type Product struct {
    Type         string
    ID           string
    TCGPlayerSKU int
    Single       Single
    Sealed       Sealed
}
Single (Card)
type Single struct {
    ScryfallID  string
    MTGJsonID   string
    Name        string
    Set         string
    Number      string
    LanguageID  string
    ConditionID string // NM, LP, MP, HP, DMG
    FinishID    string // NF (non-foil), FO (foil), EF (etched foil)
}

// Helper methods
func (s Single) ConditionName() string // Returns "Near Mint", "Near Mint Foil", etc.

Testing

The library includes comprehensive tests with 96.5% coverage:

go test -v -cover ./...

Run tests with race detector:

go test -race -v ./...

Generate coverage report:

go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-feature)
  3. Write tests for your changes
  4. Ensure tests pass and coverage remains high
  5. Commit your changes (git commit -m 'Add new feature')
  6. Push to the branch (git push origin feature/new-feature)
  7. Open a Pull Request

License

MIT License - see LICENSE file for details

Support

Changelog

v0.2.0 (2025-12-23)
  • 🔄 Rename module to github.com/repricah/manapool
  • 🧹 Remove references to tcg-repricer
  • ⚖️ Use neutral tone in documentation
  • 👤 Corrected authorship to jblotus
v0.2.0 (2025-01-28)
  • 🎉 Initial pre-release
  • ✅ Seller account endpoint (GetSellerAccount)
  • ✅ Seller inventory endpoints (GetSellerInventory, GetInventoryByTCGPlayerID, IterateInventory)
  • ✅ Test coverage (96.5%)
  • ✅ Rate limiting and retries
  • ✅ Context support for all operations
  • ✅ Structured error handling with helper methods
  • ✅ Configurable client options
  • ⚠️ API may change before v1.0.0

Documentation

Overview

Package manapool provides a client library for the Manapool API.

The Manapool API allows sellers to manage their inventory, view account information, and interact with their Manapool store programmatically.

Basic Usage

client := manapool.NewClient("your-api-token", "your-email@example.com")
account, err := client.GetSellerAccount(context.Background())
if err != nil {
    log.Fatal(err)
}
fmt.Printf("Account: %s (%s)\n", account.Username, account.Email)

Authentication

The Manapool API uses token-based authentication with two required headers:

  • X-ManaPool-Access-Token: Your API access token
  • X-ManaPool-Email: Your account email address

Rate Limiting

The client includes built-in rate limiting to avoid overwhelming the API. Configure rate limits using WithRateLimit option:

client := manapool.NewClient(token, email,
    manapool.WithRateLimit(10, 1), // 10 requests per second, burst of 1
)

Error Handling

All methods return errors that can be inspected for API-specific details:

inventory, err := client.GetSellerInventory(ctx, opts)
if err != nil {
    if apiErr, ok := err.(*manapool.APIError); ok {
        fmt.Printf("API Error: %d - %s\n", apiErr.StatusCode, apiErr.Message)
    }
    return err
}

Index

Constants

View Source
const (
	// DefaultBaseURL is the default base URL for the Manapool API.
	DefaultBaseURL = "https://manapool.com/api/v1/"

	// DefaultTimeout is the default HTTP client timeout.
	DefaultTimeout = 30 * time.Second

	// DefaultRateLimit is the default rate limit (requests per second).
	DefaultRateLimit = 10.0

	// DefaultRateBurst is the default rate limit burst.
	DefaultRateBurst = 1

	// DefaultMaxRetries is the default maximum number of retry attempts.
	DefaultMaxRetries = 3

	// DefaultInitialBackoff is the default initial backoff duration for retries.
	DefaultInitialBackoff = 1 * time.Second

	// Version is the library version.
	Version = "0.2.0"
)

Variables

This section is empty.

Functions

func IterateInventory

func IterateInventory(ctx context.Context, client APIClient, callback func(*InventoryItem) error) error

IterateInventory is a helper function that automatically handles pagination and calls the provided callback for each inventory item.

This is useful when you need to process all inventory items without manually managing pagination. The iteration continues until all items are processed or an error occurs.

Example:

err := manapool.IterateInventory(ctx, client, func(item *manapool.InventoryItem) error {
    fmt.Printf("%s: $%.2f (qty: %d)\n",
        item.Product.Single.Name, item.PriceDollars(), item.Quantity)
    return nil
})
if err != nil {
    log.Fatal(err)
}

Parameters:

  • ctx: Context for cancellation and timeouts
  • client: The Manapool API client
  • callback: Function called for each inventory item

Returns:

  • error: Any error that occurred during iteration

Types

type APIClient

type APIClient interface {
	// GetSellerAccount retrieves the seller account information.
	GetSellerAccount(ctx context.Context) (*Account, error)

	// GetSellerInventory retrieves the seller's inventory with pagination.
	GetSellerInventory(ctx context.Context, opts InventoryOptions) (*InventoryResponse, error)

	// GetInventoryByTCGPlayerID retrieves a specific inventory item by TCGPlayer SKU.
	GetInventoryByTCGPlayerID(ctx context.Context, tcgplayerID string) (*InventoryItem, error)
}

APIClient defines the interface for interacting with the Manapool API. This interface allows for easy mocking and testing.

type APIError

type APIError struct {
	// StatusCode is the HTTP status code returned by the API
	StatusCode int

	// Message is the error message from the API or a descriptive error message
	Message string

	// RequestID is the unique identifier for the request (if available)
	RequestID string

	// Response is the raw HTTP response (may be nil)
	Response *http.Response
}

APIError represents an error returned by the Manapool API. It contains the HTTP status code, error message, and optional request ID for debugging purposes.

func NewAPIError

func NewAPIError(statusCode int, message string) *APIError

NewAPIError creates a new APIError.

func (*APIError) Error

func (e *APIError) Error() string

Error implements the error interface.

func (*APIError) IsForbidden

func (e *APIError) IsForbidden() bool

IsForbidden returns true if the error is a 403 Forbidden error.

func (*APIError) IsNotFound

func (e *APIError) IsNotFound() bool

IsNotFound returns true if the error is a 404 Not Found error.

func (*APIError) IsRateLimited

func (e *APIError) IsRateLimited() bool

IsRateLimited returns true if the error is a 429 Too Many Requests error.

func (*APIError) IsServerError

func (e *APIError) IsServerError() bool

IsServerError returns true if the error is a 5xx server error.

func (*APIError) IsUnauthorized

func (e *APIError) IsUnauthorized() bool

IsUnauthorized returns true if the error is a 401 Unauthorized error.

type Account

type Account struct {
	Username       string `json:"username"`
	Email          string `json:"email"`
	Verified       bool   `json:"verified"`
	SinglesLive    bool   `json:"singles_live"`
	SealedLive     bool   `json:"sealed_live"`
	PayoutsEnabled bool   `json:"payouts_enabled"`
}

Account represents a Manapool seller account.

type Address

type Address struct {
	Name       string  `json:"name,omitempty"`
	Line1      string  `json:"line1"`
	Line2      *string `json:"line2,omitempty"`
	Line3      *string `json:"line3,omitempty"`
	City       string  `json:"city"`
	State      string  `json:"state"`
	PostalCode string  `json:"postal_code"`
	Country    string  `json:"country"`
}

Address represents a shipping/billing address.

type BuyerCredit

type BuyerCredit struct {
	UserCreditCents int `json:"user_credit_cents"`
}

BuyerCredit represents buyer credit.

type BuyerOrderDetails

type BuyerOrderDetails struct {
	ID                string                   `json:"id"`
	CreatedAt         Timestamp                `json:"created_at"`
	SubtotalCents     int                      `json:"subtotal_cents"`
	TaxCents          int                      `json:"tax_cents"`
	ShippingCents     int                      `json:"shipping_cents"`
	TotalCents        int                      `json:"total_cents"`
	OrderNumber       string                   `json:"order_number"`
	OrderSellerDetail []BuyerOrderSellerDetail `json:"order_seller_details"`
}

BuyerOrderDetails represents detailed buyer order data.

type BuyerOrderFulfillment

type BuyerOrderFulfillment struct {
	Status          *string    `json:"status"`
	TrackingCompany *string    `json:"tracking_company"`
	TrackingNumber  *string    `json:"tracking_number"`
	TrackingURL     *string    `json:"tracking_url"`
	InTransitAt     *Timestamp `json:"in_transit_at"`
}

BuyerOrderFulfillment represents fulfillment details for a buyer order.

type BuyerOrderItem

type BuyerOrderItem struct {
	PriceCents int               `json:"price_cents"`
	Quantity   int               `json:"quantity"`
	Product    BuyerOrderProduct `json:"product"`
}

BuyerOrderItem represents an item in a buyer order.

type BuyerOrderProduct

type BuyerOrderProduct struct {
	ProductType string            `json:"product_type"`
	ProductID   string            `json:"product_id"`
	Single      *BuyerOrderSingle `json:"single"`
	Sealed      *BuyerOrderSealed `json:"sealed"`
}

BuyerOrderProduct represents a product in a buyer order item.

type BuyerOrderResponse

type BuyerOrderResponse struct {
	Order BuyerOrderDetails `json:"order"`
}

BuyerOrderResponse represents a buyer order response.

type BuyerOrderSealed

type BuyerOrderSealed struct {
	MTGJsonID  string `json:"mtgjson_id"`
	Name       string `json:"name"`
	Set        string `json:"set"`
	LanguageID string `json:"language_id"`
}

BuyerOrderSealed represents a sealed product in a buyer order.

type BuyerOrderSellerDetail

type BuyerOrderSellerDetail struct {
	OrderNumber    string                  `json:"order_number"`
	SellerID       string                  `json:"seller_id"`
	SellerUsername string                  `json:"seller_username"`
	ItemCount      int                     `json:"item_count"`
	Fulfillments   []BuyerOrderFulfillment `json:"fulfillments,omitempty"`
	Items          []BuyerOrderItem        `json:"items,omitempty"`
}

BuyerOrderSellerDetail represents seller details in a buyer order.

type BuyerOrderSingle

type BuyerOrderSingle struct {
	ScryfallID  string `json:"scryfall_id"`
	MTGJsonID   string `json:"mtgjson_id"`
	Name        string `json:"name"`
	Set         string `json:"set"`
	Number      string `json:"number"`
	LanguageID  string `json:"language_id"`
	ConditionID string `json:"condition_id"`
	FinishID    string `json:"finish_id"`
}

BuyerOrderSingle represents a single product in a buyer order.

type BuyerOrderSummary

type BuyerOrderSummary struct {
	ID                string                   `json:"id"`
	CreatedAt         Timestamp                `json:"created_at"`
	SubtotalCents     int                      `json:"subtotal_cents"`
	TaxCents          int                      `json:"tax_cents"`
	ShippingCents     int                      `json:"shipping_cents"`
	TotalCents        int                      `json:"total_cents"`
	OrderNumber       string                   `json:"order_number"`
	OrderSellerDetail []BuyerOrderSellerDetail `json:"order_seller_details"`
}

BuyerOrderSummary represents a summary of a buyer order.

type BuyerOrdersOptions

type BuyerOrdersOptions struct {
	Since  *Timestamp
	Limit  int
	Offset int
}

BuyerOrdersOptions defines filters for buyer orders.

type BuyerOrdersResponse

type BuyerOrdersResponse struct {
	Orders []BuyerOrderSummary `json:"orders"`
}

BuyerOrdersResponse represents a list of buyer orders.

type CardInfo

type CardInfo struct {
	Name              string   `json:"name"`
	SetCode           string   `json:"set_code"`
	SetName           string   `json:"set_name"`
	CardNumber        string   `json:"card_number"`
	Rarity            string   `json:"rarity"`
	FromPriceCents    *int     `json:"from_price_cents"`
	QuantityAvailable int      `json:"quantity_available"`
	ReleaseDate       string   `json:"release_date"`
	LegalFormats      []string `json:"legal_formats"`
	FlavorName        *string  `json:"flavor_name"`
	Layout            *string  `json:"layout"`
	IsToken           bool     `json:"is_token"`
	PromoTypes        []string `json:"promo_types"`
	Finishes          []string `json:"finishes"`
	Text              *string  `json:"text"`
	ColorIdentity     []string `json:"color_identity"`
	EdhrecSaltiness   *string  `json:"edhrecSaltiness"`
	Power             *string  `json:"power"`
	Defense           *string  `json:"defense"`
	ManaCost          *string  `json:"mana_cost"`
	ManaValue         *string  `json:"mana_value"`
}

CardInfo represents card metadata.

type CardInfoRequest

type CardInfoRequest struct {
	CardNames []string `json:"card_names"`
}

CardInfoRequest represents a card info request.

type CardInfoResponse

type CardInfoResponse struct {
	Cards    []CardInfo `json:"cards"`
	NotFound []string   `json:"not_found"`
}

CardInfoResponse represents a card info response.

type Client

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

Client is the Manapool API client. It implements the APIClient interface.

func NewClient

func NewClient(authToken, email string, opts ...ClientOption) *Client

NewClient creates a new Manapool API client. The authToken and email parameters are required for authentication. Additional options can be passed to configure the client.

Example:

client := manapool.NewClient("your-token", "your-email@example.com",
    manapool.WithTimeout(60 * time.Second),
    manapool.WithRateLimit(5, 2),
)

func (*Client) CreateDeck

func (c *Client) CreateDeck(ctx context.Context, req DeckCreateRequest) (*DeckCreateResponse, error)

CreateDeck validates a deck and returns details.

func (*Client) CreateInventoryBulk

func (c *Client) CreateInventoryBulk(ctx context.Context, items []InventoryBulkItemBySKU) (*InventoryItemsResponse, error)

CreateInventoryBulk creates or updates (upserts) inventory in bulk by SKU.

func (*Client) CreateInventoryBulkByProduct

func (c *Client) CreateInventoryBulkByProduct(ctx context.Context, items []InventoryBulkItemByProduct) (*InventoryItemsResponse, error)

CreateInventoryBulkByProduct creates or updates (upserts) inventory in bulk by product.

func (*Client) CreateInventoryBulkBySKU

func (c *Client) CreateInventoryBulkBySKU(ctx context.Context, items []InventoryBulkItemBySKU) (*InventoryItemsResponse, error)

CreateInventoryBulkBySKU creates or updates (upserts) inventory in bulk by TCGPlayer SKU.

func (*Client) CreateInventoryBulkByScryfall

func (c *Client) CreateInventoryBulkByScryfall(ctx context.Context, items []InventoryBulkItemByScryfall) (*InventoryItemsResponse, error)

CreateInventoryBulkByScryfall creates or updates (upserts) inventory in bulk by Scryfall ID.

func (*Client) CreateInventoryBulkByTCGPlayerID

func (c *Client) CreateInventoryBulkByTCGPlayerID(ctx context.Context, items []InventoryBulkItemByTCGPlayerID) (*InventoryItemsResponse, error)

CreateInventoryBulkByTCGPlayerID creates or updates (upserts) inventory in bulk by TCGPlayer ID.

func (*Client) CreatePendingOrder

func (c *Client) CreatePendingOrder(ctx context.Context, req PendingOrderRequest) (*PendingOrder, error)

CreatePendingOrder creates a pending order.

func (*Client) DeleteInventoryBySKU

func (c *Client) DeleteInventoryBySKU(ctx context.Context, sku int) (*InventoryListingResponse, error)

DeleteInventoryBySKU deletes an inventory item by TCGPlayer SKU.

func (*Client) DeleteSellerInventoryByProduct

func (c *Client) DeleteSellerInventoryByProduct(ctx context.Context, productType, productID string) (*InventoryListingResponse, error)

DeleteSellerInventoryByProduct deletes inventory by product ID.

func (*Client) DeleteSellerInventoryBySKU

func (c *Client) DeleteSellerInventoryBySKU(ctx context.Context, sku int) (*InventoryListingResponse, error)

DeleteSellerInventoryBySKU deletes a seller inventory item by SKU.

func (*Client) DeleteSellerInventoryByScryfall

func (c *Client) DeleteSellerInventoryByScryfall(ctx context.Context, scryfallID string, opts InventoryByScryfallOptions) (*InventoryListingResponse, error)

DeleteSellerInventoryByScryfall deletes inventory by Scryfall ID.

func (*Client) DeleteSellerInventoryByTCGPlayerID

func (c *Client) DeleteSellerInventoryByTCGPlayerID(ctx context.Context, tcgplayerID int, opts InventoryByTCGPlayerOptions) (*InventoryListingResponse, error)

DeleteSellerInventoryByTCGPlayerID deletes inventory by TCGPlayer ID.

func (*Client) DeleteWebhook

func (c *Client) DeleteWebhook(ctx context.Context, id string) error

DeleteWebhook deletes a webhook by ID.

func (*Client) GetBuyerCredit

func (c *Client) GetBuyerCredit(ctx context.Context) (*BuyerCredit, error)

GetBuyerCredit retrieves buyer credit balance.

func (*Client) GetBuyerOrder

func (c *Client) GetBuyerOrder(ctx context.Context, id string) (*BuyerOrderResponse, error)

GetBuyerOrder retrieves a buyer order by ID.

func (*Client) GetBuyerOrders

func (c *Client) GetBuyerOrders(ctx context.Context, opts BuyerOrdersOptions) (*BuyerOrdersResponse, error)

GetBuyerOrders retrieves buyer orders with optional filtering.

func (*Client) GetCardInfo

func (c *Client) GetCardInfo(ctx context.Context, req CardInfoRequest) (*CardInfoResponse, error)

GetCardInfo retrieves card information for a list of card names.

func (*Client) GetInventoryBySKU

func (c *Client) GetInventoryBySKU(ctx context.Context, sku int) (*InventoryListingResponse, error)

GetInventoryBySKU retrieves an inventory item by TCGPlayer SKU.

func (*Client) GetInventoryByTCGPlayerID

func (c *Client) GetInventoryByTCGPlayerID(ctx context.Context, tcgplayerID string) (*InventoryItem, error)

GetInventoryByTCGPlayerID retrieves a specific inventory item by its TCGPlayer SKU.

This is useful when you need to look up a specific card by its TCGPlayer ID to check its current Manapool price and quantity.

Example:

item, err := client.GetInventoryByTCGPlayerID(ctx, "4549403")
if err != nil {
    var apiErr *manapool.APIError
    if errors.As(err, &apiErr) && apiErr.IsNotFound() {
        fmt.Println("Item not found in inventory")
        return
    }
    log.Fatal(err)
}
fmt.Printf("Found: %s - $%.2f (qty: %d)\n",
    item.Product.Single.Name, item.PriceDollars(), item.Quantity)

Parameters:

  • ctx: Context for cancellation and timeouts
  • tcgplayerID: The TCGPlayer SKU to look up

Returns:

  • *InventoryItem: The inventory item
  • error: Any error that occurred during the request (404 if not found)

func (*Client) GetInventoryListing

func (c *Client) GetInventoryListing(ctx context.Context, id string) (*InventoryItemResponse, error)

GetInventoryListing retrieves a single inventory listing by ID.

func (*Client) GetInventoryListings

func (c *Client) GetInventoryListings(ctx context.Context, ids []string) (*InventoryListingsResponse, error)

GetInventoryListings retrieves inventory listings by ID.

func (*Client) GetOrder

func (c *Client) GetOrder(ctx context.Context, id string) (*OrderDetailsResponse, error)

GetOrder retrieves order details by ID.

func (*Client) GetOrders

func (c *Client) GetOrders(ctx context.Context, opts OrdersOptions) (*OrdersResponse, error)

GetOrders retrieves order summaries.

func (*Client) GetPendingOrder

func (c *Client) GetPendingOrder(ctx context.Context, id string) (*PendingOrder, error)

GetPendingOrder retrieves a pending order by ID.

func (*Client) GetSealedPrices

func (c *Client) GetSealedPrices(ctx context.Context) (*SealedPricesList, error)

GetSealedPrices retrieves prices for all in-stock sealed products.

func (*Client) GetSellerAccount

func (c *Client) GetSellerAccount(ctx context.Context) (*Account, error)

GetSellerAccount retrieves the authenticated seller's account information.

This endpoint returns account details including username, email, verification status, and whether singles/sealed products are live on the marketplace.

Example:

account, err := client.GetSellerAccount(ctx)
if err != nil {
    log.Fatal(err)
}
fmt.Printf("Account: %s (%s)\n", account.Username, account.Email)
fmt.Printf("Singles Live: %v, Sealed Live: %v\n",
    account.SinglesLive, account.SealedLive)

Returns:

  • *Account: The account information
  • error: Any error that occurred during the request

func (*Client) GetSellerInventory

func (c *Client) GetSellerInventory(ctx context.Context, opts InventoryOptions) (*InventoryResponse, error)

GetSellerInventory retrieves the seller's inventory with pagination support.

The inventory includes all products (singles and sealed) with their current prices, quantities, and product details. Results are paginated.

Example:

opts := manapool.InventoryOptions{
    Limit:  500,  // max 500
    Offset: 0,    // start at beginning
}
resp, err := client.GetSellerInventory(ctx, opts)
if err != nil {
    log.Fatal(err)
}
fmt.Printf("Total items: %d, Returned: %d\n",
    resp.Pagination.Total, resp.Pagination.Returned)
for _, item := range resp.Inventory {
    fmt.Printf("  %s: $%.2f (qty: %d)\n",
        item.Product.Single.Name, item.PriceDollars(), item.Quantity)
}

Parameters:

  • ctx: Context for cancellation and timeouts
  • opts: Pagination options (limit and offset)

Returns:

  • *InventoryResponse: The inventory items and pagination metadata
  • error: Any error that occurred during the request

func (*Client) GetSellerInventoryByProduct

func (c *Client) GetSellerInventoryByProduct(ctx context.Context, productType, productID string) (*InventoryListingResponse, error)

GetSellerInventoryByProduct retrieves inventory by product ID.

func (*Client) GetSellerInventoryBySKU

func (c *Client) GetSellerInventoryBySKU(ctx context.Context, sku int) (*InventoryListingResponse, error)

GetSellerInventoryBySKU retrieves a seller inventory item by SKU.

func (*Client) GetSellerInventoryByScryfall

func (c *Client) GetSellerInventoryByScryfall(ctx context.Context, scryfallID string, opts InventoryByScryfallOptions) (*InventoryListingResponse, error)

GetSellerInventoryByScryfall retrieves inventory by Scryfall ID.

func (*Client) GetSellerInventoryByTCGPlayerID

func (c *Client) GetSellerInventoryByTCGPlayerID(ctx context.Context, tcgplayerID int, opts InventoryByTCGPlayerOptions) (*InventoryListingResponse, error)

GetSellerInventoryByTCGPlayerID retrieves inventory by TCGPlayer ID.

func (*Client) GetSellerOrder

func (c *Client) GetSellerOrder(ctx context.Context, id string) (*OrderDetailsResponse, error)

GetSellerOrder retrieves seller order details by ID.

func (*Client) GetSellerOrderReports

func (c *Client) GetSellerOrderReports(ctx context.Context, id string) (*OrderReportsResponse, error)

GetSellerOrderReports retrieves order reports for a seller order.

func (*Client) GetSellerOrders

func (c *Client) GetSellerOrders(ctx context.Context, opts OrdersOptions) (*OrdersResponse, error)

GetSellerOrders retrieves seller order summaries.

func (*Client) GetSinglesPrices

func (c *Client) GetSinglesPrices(ctx context.Context) (*SinglesPricesList, error)

GetSinglesPrices retrieves prices for all in-stock singles.

func (*Client) GetVariantPrices

func (c *Client) GetVariantPrices(ctx context.Context) (*VariantPricesList, error)

GetVariantPrices retrieves prices for all in-stock variants.

func (*Client) GetWebhook

func (c *Client) GetWebhook(ctx context.Context, id string) (*Webhook, error)

GetWebhook retrieves a webhook by ID.

func (*Client) GetWebhooks

func (c *Client) GetWebhooks(ctx context.Context, topic string) (*WebhooksResponse, error)

GetWebhooks retrieves registered webhooks.

func (*Client) OptimizeCart

func (c *Client) OptimizeCart(ctx context.Context, req OptimizerRequest) (*OptimizedCart, error)

OptimizeCart creates an optimized cart.

func (*Client) PurchasePendingOrder

func (c *Client) PurchasePendingOrder(ctx context.Context, id string, req PurchasePendingOrderRequest) (*PendingOrder, error)

PurchasePendingOrder purchases a pending order.

func (*Client) RegisterWebhook

func (c *Client) RegisterWebhook(ctx context.Context, req WebhookRegisterRequest) (*Webhook, error)

RegisterWebhook registers a webhook.

func (*Client) SubmitJobApplication

func (c *Client) SubmitJobApplication(ctx context.Context, req JobApplicationRequest) (*JobApplicationResponse, error)

SubmitJobApplication submits a job application.

func (*Client) UpdateInventoryBySKU

func (c *Client) UpdateInventoryBySKU(ctx context.Context, sku int, update InventoryUpdateRequest) (*InventoryListingResponse, error)

UpdateInventoryBySKU updates an inventory item by TCGPlayer SKU.

func (*Client) UpdateOrderFulfillment

func (c *Client) UpdateOrderFulfillment(ctx context.Context, id string, req OrderFulfillmentRequest) (*OrderFulfillmentResponse, error)

UpdateOrderFulfillment updates the fulfillment for an order.

func (*Client) UpdatePendingOrder

func (c *Client) UpdatePendingOrder(ctx context.Context, id string, req PendingOrderRequest) (*PendingOrder, error)

UpdatePendingOrder updates a pending order.

func (*Client) UpdateSellerAccount

func (c *Client) UpdateSellerAccount(ctx context.Context, update SellerAccountUpdate) (*Account, error)

UpdateSellerAccount updates the seller account settings.

func (*Client) UpdateSellerInventoryByProduct

func (c *Client) UpdateSellerInventoryByProduct(ctx context.Context, productType, productID string, update InventoryUpdateRequest) (*InventoryListingResponse, error)

UpdateSellerInventoryByProduct updates inventory by product ID.

func (*Client) UpdateSellerInventoryBySKU

func (c *Client) UpdateSellerInventoryBySKU(ctx context.Context, sku int, update InventoryUpdateRequest) (*InventoryListingResponse, error)

UpdateSellerInventoryBySKU updates a seller inventory item by SKU.

func (*Client) UpdateSellerInventoryByScryfall

func (c *Client) UpdateSellerInventoryByScryfall(ctx context.Context, scryfallID string, opts InventoryByScryfallOptions, update InventoryUpdateRequest) (*InventoryListingResponse, error)

UpdateSellerInventoryByScryfall updates inventory by Scryfall ID.

func (*Client) UpdateSellerInventoryByTCGPlayerID

func (c *Client) UpdateSellerInventoryByTCGPlayerID(ctx context.Context, tcgplayerID int, opts InventoryByTCGPlayerOptions, update InventoryUpdateRequest) (*InventoryListingResponse, error)

UpdateSellerInventoryByTCGPlayerID updates inventory by TCGPlayer ID.

func (*Client) UpdateSellerOrderFulfillment

func (c *Client) UpdateSellerOrderFulfillment(ctx context.Context, id string, req OrderFulfillmentRequest) (*OrderFulfillmentResponse, error)

UpdateSellerOrderFulfillment updates a seller order fulfillment.

type ClientOption

type ClientOption func(*Client)

ClientOption is a function that configures a Client.

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL sets a custom base URL for the API. This is useful for testing against a mock server or staging environment.

The default base URL is https://manapool.com/api/v1/

Example:

client := manapool.NewClient(token, email,
    manapool.WithBaseURL("https://staging.manapool.com/api/v1/"),
)

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ClientOption

WithHTTPClient sets a custom HTTP client. Use this to configure timeouts, transport, TLS settings, etc.

Example:

customClient := &http.Client{
    Timeout: 30 * time.Second,
    Transport: &http.Transport{
        MaxIdleConns: 10,
    },
}
client := manapool.NewClient(token, email,
    manapool.WithHTTPClient(customClient),
)

func WithLogger

func WithLogger(logger Logger) ClientOption

WithLogger sets a custom logger for the client. The logger must implement the Logger interface.

Example:

type myLogger struct{}
func (l *myLogger) Debugf(format string, args ...interface{}) {
    log.Printf("[DEBUG] "+format, args...)
}
func (l *myLogger) Errorf(format string, args ...interface{}) {
    log.Printf("[ERROR] "+format, args...)
}

client := manapool.NewClient(token, email,
    manapool.WithLogger(&myLogger{}),
)

func WithRateLimit

func WithRateLimit(requestsPerSecond float64, burst int) ClientOption

WithRateLimit configures rate limiting for API requests. The rate is specified as requests per second, and burst is the maximum number of requests that can be made in a single burst.

Default: 10 requests per second with a burst of 1.

Example:

client := manapool.NewClient(token, email,
    manapool.WithRateLimit(5, 2), // 5 req/sec, burst of 2
)

func WithRetry

func WithRetry(maxRetries int, initialBackoff time.Duration) ClientOption

WithRetry configures automatic retry behavior for failed requests. maxRetries specifies the maximum number of retry attempts. initialBackoff specifies the initial backoff duration (doubled on each retry).

Default: 3 retries with 1 second initial backoff.

Example:

client := manapool.NewClient(token, email,
    manapool.WithRetry(5, 2*time.Second), // 5 retries, 2s initial backoff
)

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout sets the HTTP client timeout. This is a convenience method that wraps WithHTTPClient.

Default: 30 seconds.

Example:

client := manapool.NewClient(token, email,
    manapool.WithTimeout(60 * time.Second),
)

func WithUserAgent

func WithUserAgent(userAgent string) ClientOption

WithUserAgent sets a custom User-Agent header for API requests.

Default: "manapool-go/<version>"

Example:

client := manapool.NewClient(token, email,
    manapool.WithUserAgent("my-app/1.0"),
)

type DeckColorIdentityViolation

type DeckColorIdentityViolation struct {
	Name            string   `json:"name"`
	CardColors      []string `json:"card_colors"`
	CommanderColors []string `json:"commander_colors"`
}

DeckColorIdentityViolation represents a color identity violation.

type DeckCreateRequest

type DeckCreateRequest struct {
	CommanderNames []string    `json:"commander_names"`
	OtherCards     []OtherCard `json:"other_cards"`
}

DeckCreateRequest represents a deck create request.

type DeckCreateResponse

type DeckCreateResponse struct {
	Valid   bool                  `json:"valid"`
	BuyURL  string                `json:"buy_url,omitempty"`
	Details DeckValidationDetails `json:"details"`
}

DeckCreateResponse represents the deck validation response.

type DeckQuantityViolation

type DeckQuantityViolation struct {
	Name       string `json:"name"`
	Quantity   int    `json:"quantity"`
	MaxAllowed int    `json:"max_allowed"`
}

DeckQuantityViolation represents a quantity violation.

type DeckValidationDetails

type DeckValidationDetails struct {
	CommanderCount          int                          `json:"commander_count"`
	TotalCardCount          int                          `json:"total_card_count"`
	AllCardsLegal           bool                         `json:"all_cards_legal"`
	IllegalCards            []string                     `json:"illegal_cards"`
	CardsNotFound           []string                     `json:"cards_not_found"`
	ValidQuantities         bool                         `json:"valid_quantities"`
	QuantityViolations      []DeckQuantityViolation      `json:"quantity_violations"`
	ValidColorIdentity      bool                         `json:"valid_color_identity"`
	ColorIdentityViolations []DeckColorIdentityViolation `json:"color_identity_violations"`
	ValidPartnership        bool                         `json:"valid_partnership"`
	PartnerViolations       []string                     `json:"partner_violations"`
}

DeckValidationDetails represents deck validation details.

type InventoryBulkItemByProduct

type InventoryBulkItemByProduct struct {
	ProductType string `json:"product_type"`
	ProductID   string `json:"product_id"`
	PriceCents  int    `json:"price_cents"`
	Quantity    int    `json:"quantity"`
}

InventoryBulkItemByProduct represents bulk inventory items by product.

type InventoryBulkItemBySKU

type InventoryBulkItemBySKU struct {
	TCGPlayerSKU int `json:"tcgplayer_sku"`
	PriceCents   int `json:"price_cents"`
	Quantity     int `json:"quantity"`
}

InventoryBulkItemBySKU represents bulk inventory items by SKU.

type InventoryBulkItemByScryfall

type InventoryBulkItemByScryfall struct {
	ScryfallID  string `json:"scryfall_id"`
	LanguageID  string `json:"language_id"`
	FinishID    string `json:"finish_id"`
	ConditionID string `json:"condition_id"`
	PriceCents  int    `json:"price_cents"`
	Quantity    int    `json:"quantity"`
}

InventoryBulkItemByScryfall represents bulk inventory items by Scryfall ID.

type InventoryBulkItemByTCGPlayerID

type InventoryBulkItemByTCGPlayerID struct {
	TCGPlayerID int     `json:"tcgplayer_id"`
	LanguageID  string  `json:"language_id"`
	FinishID    *string `json:"finish_id"`
	ConditionID *string `json:"condition_id"`
	PriceCents  int     `json:"price_cents"`
	Quantity    int     `json:"quantity"`
}

InventoryBulkItemByTCGPlayerID represents bulk inventory items by TCGPlayer ID.

type InventoryByScryfallOptions

type InventoryByScryfallOptions struct {
	LanguageID  string
	FinishID    string
	ConditionID string
}

InventoryByScryfallOptions defines lookup options by Scryfall ID.

type InventoryByTCGPlayerOptions

type InventoryByTCGPlayerOptions struct {
	LanguageID  string
	FinishID    string
	ConditionID string
}

InventoryByTCGPlayerOptions defines lookup options by TCGPlayer ID.

type InventoryItem

type InventoryItem struct {
	ID            string    `json:"id"`
	ProductType   string    `json:"product_type"`
	ProductID     string    `json:"product_id"`
	Product       Product   `json:"product"`
	PriceCents    int       `json:"price_cents"`
	Quantity      int       `json:"quantity"`
	EffectiveAsOf Timestamp `json:"effective_as_of"`
}

InventoryItem represents a single inventory item in the Manapool system.

func (InventoryItem) PriceDollars

func (i InventoryItem) PriceDollars() float64

PriceDollars returns the price in dollars (converts from cents).

type InventoryItemResponse

type InventoryItemResponse struct {
	InventoryItem InventoryItem `json:"inventory_item"`
}

InventoryItemResponse represents inventory item response for /inventory/listings/{id}.

type InventoryItemsResponse

type InventoryItemsResponse struct {
	Inventory []InventoryItem `json:"inventory"`
}

InventoryItemsResponse represents a response with inventory items.

type InventoryListingResponse

type InventoryListingResponse struct {
	Inventory InventoryItem `json:"inventory"`
}

InventoryListingResponse represents a response with a single inventory item.

type InventoryListingsResponse

type InventoryListingsResponse struct {
	InventoryItems []InventoryItem `json:"inventory_items"`
}

InventoryListingsResponse represents inventory listing items.

type InventoryOptions

type InventoryOptions struct {
	// Limit specifies the maximum number of items to return (default: 500, max: 500)
	Limit int

	// Offset specifies the starting position in the result set (default: 0)
	Offset int
}

InventoryOptions contains options for querying seller inventory.

func (*InventoryOptions) Validate

func (o *InventoryOptions) Validate() error

Validate validates the inventory options and sets defaults.

type InventoryResponse

type InventoryResponse struct {
	Inventory  []InventoryItem `json:"inventory"`
	Pagination Pagination      `json:"pagination"`
}

InventoryResponse represents a paginated response from the inventory API.

type InventoryUpdateRequest

type InventoryUpdateRequest struct {
	PriceCents int `json:"price_cents"`
	Quantity   int `json:"quantity"`
}

InventoryUpdateRequest represents a request to update inventory.

type JobApplicationRequest

type JobApplicationRequest struct {
	FirstName           string
	LastName            string
	Email               string
	LinkedInURL         string
	GitHubURL           string
	Application         []byte
	ApplicationFilename string
}

JobApplicationRequest represents a job application.

type JobApplicationResponse

type JobApplicationResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

JobApplicationResponse represents a job application response.

type Logger

type Logger interface {
	// Debugf logs a debug message.
	Debugf(format string, args ...interface{})

	// Errorf logs an error message.
	Errorf(format string, args ...interface{})
}

Logger is an interface for logging. Implement this interface to provide custom logging.

type NetworkError

type NetworkError struct {
	Message string
	Err     error
}

NetworkError represents a network-related error (connection issues, timeouts, etc.).

func NewNetworkError

func NewNetworkError(message string, err error) *NetworkError

NewNetworkError creates a new NetworkError.

func (*NetworkError) Error

func (e *NetworkError) Error() string

Error implements the error interface.

func (*NetworkError) Unwrap

func (e *NetworkError) Unwrap() error

Unwrap returns the underlying error.

type OptimizedCart

type OptimizedCart struct {
	Cart   []OptimizedCartItem `json:"cart"`
	Totals OptimizedCartTotals `json:"totals"`
}

OptimizedCart represents an optimized cart response.

type OptimizedCartItem

type OptimizedCartItem struct {
	InventoryID      string `json:"inventory_id"`
	QuantitySelected int    `json:"quantity_selected"`
}

OptimizedCartItem represents a selected inventory item.

type OptimizedCartTotals

type OptimizedCartTotals struct {
	SubtotalCents int `json:"subtotal_cents"`
	ShippingCents int `json:"shipping_cents"`
	TotalCents    int `json:"total_cents"`
	SellerCount   int `json:"seller_count"`
}

OptimizedCartTotals represents cart totals.

type OptimizerCartItem

type OptimizerCartItem struct {
	Type                      string   `json:"type"`
	Name                      string   `json:"name,omitempty"`
	SetCode                   string   `json:"set_code,omitempty"`
	CollectorNumber           string   `json:"collector_number,omitempty"`
	IsToken                   *bool    `json:"is_token,omitempty"`
	IncludeNonSanctionedLegal *bool    `json:"include_non_sanctioned_legal,omitempty"`
	MTGJsonID                 *string  `json:"mtgjson_id,omitempty"`
	LanguageIDs               []string `json:"language_ids,omitempty"`
	FinishIDs                 []string `json:"finish_ids,omitempty"`
	ConditionIDs              []string `json:"condition_ids,omitempty"`
	URI                       string   `json:"uri,omitempty"`
	TCGPlayerSKUIds           []int    `json:"tcgplayer_sku_ids,omitempty"`
	ProductType               string   `json:"product_type,omitempty"`
	ProductIDs                []string `json:"product_ids,omitempty"`
	QuantityRequested         int      `json:"quantity_requested"`
	Index                     *int     `json:"index,omitempty"`
}

OptimizerCartItem represents an item requested by the optimizer.

type OptimizerRequest

type OptimizerRequest struct {
	Cart               []OptimizerCartItem `json:"cart"`
	Model              string              `json:"model,omitempty"`
	DestinationCountry string              `json:"destination_country,omitempty"`
	ExcludeSellerIDs   []string            `json:"exclude_seller_ids,omitempty"`
	AllowSellerIDs     []string            `json:"allow_seller_ids,omitempty"`
	ShipFromCountries  []string            `json:"ship_from_countries,omitempty"`
}

OptimizerRequest represents a cart optimization request.

type OrderDetails

type OrderDetails struct {
	OrderSummary
	BuyerID         string             `json:"buyer_id"`
	ShippingAddress Address            `json:"shipping_address"`
	Payment         OrderPayment       `json:"payment"`
	Fulfillments    []OrderFulfillment `json:"fulfillments"`
	Items           []OrderItem        `json:"items"`
}

OrderDetails represents detailed order data.

type OrderDetailsResponse

type OrderDetailsResponse struct {
	Order OrderDetails `json:"order"`
}

OrderDetailsResponse represents detailed order response.

type OrderFulfillment

type OrderFulfillment struct {
	Status              *string    `json:"status"`
	TrackingCompany     *string    `json:"tracking_company"`
	TrackingNumber      *string    `json:"tracking_number"`
	TrackingURL         *string    `json:"tracking_url"`
	InTransitAt         *Timestamp `json:"in_transit_at"`
	EstimatedDeliveryAt *Timestamp `json:"estimated_delivery_at"`
	DeliveredAt         *Timestamp `json:"delivered_at"`
}

OrderFulfillment represents order fulfillment.

type OrderFulfillmentRequest

type OrderFulfillmentRequest struct {
	Status              *string    `json:"status"`
	TrackingCompany     *string    `json:"tracking_company"`
	TrackingNumber      *string    `json:"tracking_number"`
	TrackingURL         *string    `json:"tracking_url"`
	InTransitAt         *Timestamp `json:"in_transit_at"`
	EstimatedDeliveryAt *Timestamp `json:"estimated_delivery_at"`
	DeliveredAt         *Timestamp `json:"delivered_at"`
}

OrderFulfillmentRequest represents a fulfillment update request.

type OrderFulfillmentResponse

type OrderFulfillmentResponse struct {
	Fulfillment OrderFulfillment `json:"fulfillment"`
}

OrderFulfillmentResponse represents fulfillment response.

type OrderItem

type OrderItem struct {
	TCGSKU      *int    `json:"tcgsku"`
	ProductID   string  `json:"product_id"`
	ProductType string  `json:"product_type"`
	Product     Product `json:"product"`
	Quantity    int     `json:"quantity"`
	PriceCents  int     `json:"price_cents"`
}

OrderItem represents an order item.

type OrderPayment

type OrderPayment struct {
	SubtotalCents int `json:"subtotal_cents"`
	ShippingCents int `json:"shipping_cents"`
	TotalCents    int `json:"total_cents"`
	FeeCents      int `json:"fee_cents"`
	NetCents      int `json:"net_cents"`
}

OrderPayment represents payment details.

type OrderReport

type OrderReport struct {
	ReportID            string              `json:"report_id"`
	OrderID             string              `json:"order_id"`
	OrderReportedIssues OrderReportedIssues `json:"order_reported_issues"`
}

OrderReport represents an order report.

type OrderReportedCharge

type OrderReportedCharge struct {
	SellerChargeCents *int    `json:"seller_charge_cents"`
	PayoutID          *string `json:"payout_id"`
}

OrderReportedCharge represents a charge entry.

type OrderReportedIssues

type OrderReportedIssues struct {
	Comment                   *string                    `json:"comment"`
	CreatedAt                 Timestamp                  `json:"created_at"`
	ProposedRemediationMethod *string                    `json:"proposed_remediation_method"`
	ReporterRole              string                     `json:"reporter_role"`
	IsNonDeliveryReport       bool                       `json:"is_nondelivery_report"`
	Rescinded                 bool                       `json:"rescinded"`
	Items                     []OrderReportedItem        `json:"items"`
	Remediations              []OrderReportedRemediation `json:"remediations"`
	Charges                   []OrderReportedCharge      `json:"charges"`
}

OrderReportedIssues represents reported issues.

type OrderReportedItem

type OrderReportedItem struct {
	OrderItemID string `json:"order_item_id"`
	Quantity    int    `json:"quantity"`
}

OrderReportedItem represents a reported order item.

type OrderReportedRemediation

type OrderReportedRemediation struct {
	RemediationExpenseCents *int      `json:"remediation_expense_cents"`
	Comment                 *string   `json:"comment"`
	CreatedAt               Timestamp `json:"created_at"`
}

OrderReportedRemediation represents a remediation entry.

type OrderReportsResponse

type OrderReportsResponse struct {
	Reports []OrderReport `json:"reports"`
}

OrderReportsResponse represents order reports.

type OrderSummary

type OrderSummary struct {
	ID                      string    `json:"id"`
	CreatedAt               Timestamp `json:"created_at"`
	Label                   string    `json:"label"`
	TotalCents              int       `json:"total_cents"`
	ShippingMethod          string    `json:"shipping_method"`
	LatestFulfillmentStatus *string   `json:"latest_fulfillment_status"`
}

OrderSummary represents order summary information.

type OrdersOptions

type OrdersOptions struct {
	Since           *Timestamp
	IsUnfulfilled   *bool
	IsFulfilled     *bool
	HasFulfillments *bool
	Label           string
	Limit           int
	Offset          int
}

OrdersOptions defines filters for order listing endpoints.

type OrdersResponse

type OrdersResponse struct {
	Orders []OrderSummary `json:"orders"`
}

OrdersResponse represents order summaries.

type OtherCard

type OtherCard struct {
	Name     string `json:"name"`
	Quantity int    `json:"quantity"`
}

OtherCard represents a non-commander card in a deck.

type Pagination

type Pagination struct {
	Total    int `json:"total"`
	Returned int `json:"returned"`
	Offset   int `json:"offset"`
	Limit    int `json:"limit"`
}

Pagination contains pagination metadata for API responses.

type PendingOrder

type PendingOrder struct {
	ID                string                 `json:"id"`
	ShippingOverrides map[string]string      `json:"shipping_overrides,omitempty"`
	LineItems         []PendingOrderLineItem `json:"line_items"`
	Status            string                 `json:"status"`
	Totals            PendingOrderTotals     `json:"totals"`
	Order             *PendingOrderCompleted `json:"order"`
}

PendingOrder represents a pending order response.

type PendingOrderCompleted

type PendingOrderCompleted struct {
	ID string `json:"id"`
}

PendingOrderCompleted represents a completed order reference.

type PendingOrderLineItem

type PendingOrderLineItem struct {
	InventoryID      string `json:"inventory_id"`
	QuantitySelected int    `json:"quantity_selected"`
}

PendingOrderLineItem represents a pending order line item.

type PendingOrderRequest

type PendingOrderRequest struct {
	ShippingOverrides map[string]string      `json:"shipping_overrides,omitempty"`
	LineItems         []PendingOrderLineItem `json:"line_items"`
	TaxAddress        *Address               `json:"tax_address,omitempty"`
	ShippingAddress   *Address               `json:"shipping_address,omitempty"`
}

PendingOrderRequest represents a pending order create/update request.

type PendingOrderTotals

type PendingOrderTotals struct {
	SubtotalCents int `json:"subtotal_cents"`
	ShippingCents int `json:"shipping_cents"`
	TaxCents      int `json:"tax_cents"`
	TotalCents    int `json:"total_cents"`
}

PendingOrderTotals represents totals for a pending order.

type PricesMeta

type PricesMeta struct {
	AsOf Timestamp `json:"as_of"`
}

PricesMeta describes price export metadata.

type Product

type Product struct {
	Type         string  `json:"type"`
	ID           string  `json:"id"`
	TCGPlayerSKU *int    `json:"tcgplayer_sku"`
	Single       *Single `json:"single"`
	Sealed       *Sealed `json:"sealed"`
}

Product represents a product in the Manapool inventory.

type PurchasePendingOrderRequest

type PurchasePendingOrderRequest struct {
	PaymentMethod   string  `json:"payment_method"`
	BillingAddress  Address `json:"billing_address"`
	ShippingAddress Address `json:"shipping_address"`
	ApplyBuyerFee   *bool   `json:"apply_buyer_fee,omitempty"`
}

PurchasePendingOrderRequest represents a purchase request.

type Sealed

type Sealed struct {
	MTGJsonID   string `json:"mtgjson_id"`
	TCGPlayerID *int   `json:"tcgplayer_id"`
	Name        string `json:"name"`
	Set         string `json:"set"`
	LanguageID  string `json:"language_id"`
}

Sealed represents a sealed product (booster boxes, etc.).

type SealedPriceListing

type SealedPriceListing struct {
	URL                string `json:"url"`
	ProductType        string `json:"product_type"`
	ProductID          string `json:"product_id"`
	SetCode            string `json:"set_code"`
	Name               string `json:"name"`
	TCGPlayerProductID *int   `json:"tcgplayer_product_id"`
	LanguageID         string `json:"language_id"`
	LowPrice           int    `json:"low_price"`
	AvailableQuantity  int    `json:"available_quantity"`
}

SealedPriceListing represents a sealed price listing.

type SealedPricesList

type SealedPricesList struct {
	Meta PricesMeta           `json:"meta"`
	Data []SealedPriceListing `json:"data"`
}

SealedPricesList represents the sealed prices export.

type SellerAccountUpdate

type SellerAccountUpdate struct {
	SinglesLive *bool `json:"singles_live"`
	SealedLive  *bool `json:"sealed_live"`
}

SellerAccountUpdate represents a seller account update request.

type Single

type Single struct {
	ScryfallID  string `json:"scryfall_id"`
	MTGJsonID   string `json:"mtgjson_id"`
	TCGPlayerID *int   `json:"tcgplayer_id"`
	Name        string `json:"name"`
	Set         string `json:"set"`
	Number      string `json:"number"`
	LanguageID  string `json:"language_id"`
	ConditionID string `json:"condition_id"`
	FinishID    string `json:"finish_id"`
}

Single represents a single card product.

func (Single) ConditionName

func (s Single) ConditionName() string

ConditionName returns the standardized condition name for a single card. It combines the condition ID and finish ID into a human-readable string.

Condition IDs:

  • NM: Near Mint
  • LP: Lightly Played
  • MP: Moderately Played
  • HP: Heavily Played
  • DMG: Damaged

Finish IDs:

  • NF: Non-foil (no suffix)
  • FO: Foil (adds " Foil" suffix)
  • EF: Etched Foil (adds " Foil" suffix)

type SinglePriceListing

type SinglePriceListing struct {
	URL                    string  `json:"url"`
	Name                   string  `json:"name"`
	SetCode                string  `json:"set_code"`
	Number                 string  `json:"number"`
	MultiverseID           *string `json:"multiverse_id"`
	ScryfallID             string  `json:"scryfall_id"`
	AvailableQuantity      int     `json:"available_quantity"`
	PriceCents             *int    `json:"price_cents"`
	PriceCentsLPPlus       *int    `json:"price_cents_lp_plus"`
	PriceCentsNM           *int    `json:"price_cents_nm"`
	PriceCentsFoil         *int    `json:"price_cents_foil"`
	PriceCentsLPPlusFoil   *int    `json:"price_cents_lp_plus_foil"`
	PriceCentsNMFoil       *int    `json:"price_cents_nm_foil"`
	PriceCentsEtched       *int    `json:"price_cents_etched"`
	PriceCentsLPPlusEtched *int    `json:"price_cents_lp_plus_etched"`
	PriceCentsNMEtched     *int    `json:"price_cents_nm_etched"`
}

SinglePriceListing represents a single price listing.

type SinglesPricesList

type SinglesPricesList struct {
	Meta PricesMeta           `json:"meta"`
	Data []SinglePriceListing `json:"data"`
}

SinglesPricesList represents the singles prices export.

type Timestamp

type Timestamp struct {
	time.Time
}

Timestamp is a custom time type that handles Manapool's timestamp format. The Manapool API returns timestamps in multiple formats:

  • RFC3339Nano: "2025-08-05T20:38:54.549229Z"
  • No-colon offset: "2025-08-05T20:38:54.549229+0000"

func (Timestamp) MarshalJSON

func (t Timestamp) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for Timestamp.

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler for Timestamp.

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError represents an error that occurs during input validation.

func NewValidationError

func NewValidationError(field, message string) *ValidationError

NewValidationError creates a new ValidationError.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error implements the error interface.

type VariantPriceListing

type VariantPriceListing struct {
	URL                string  `json:"url"`
	ProductType        string  `json:"product_type"`
	ProductID          string  `json:"product_id"`
	SetCode            string  `json:"set_code"`
	Number             string  `json:"number"`
	Name               string  `json:"name"`
	ScryfallID         string  `json:"scryfall_id"`
	TCGPlayerProductID *int    `json:"tcgplayer_product_id"`
	LanguageID         string  `json:"language_id"`
	ConditionID        *string `json:"condition_id"`
	FinishID           *string `json:"finish_id"`
	LowPrice           int     `json:"low_price"`
	AvailableQuantity  int     `json:"available_quantity"`
}

VariantPriceListing represents a variant price listing.

type VariantPricesList

type VariantPricesList struct {
	Meta PricesMeta            `json:"meta"`
	Data []VariantPriceListing `json:"data"`
}

VariantPricesList represents the variant prices export.

type Webhook

type Webhook struct {
	ID          string `json:"id"`
	Topic       string `json:"topic"`
	CallbackURL string `json:"callback_url"`
}

Webhook represents a webhook registration.

type WebhookRegisterRequest

type WebhookRegisterRequest struct {
	Topic       string `json:"topic"`
	CallbackURL string `json:"callback_url"`
}

WebhookRegisterRequest represents webhook register request.

type WebhooksResponse

type WebhooksResponse struct {
	Webhooks []Webhook `json:"webhooks"`
}

WebhooksResponse represents webhooks list response.

Jump to

Keyboard shortcuts

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