package coach_client import ( "context" "fmt" "net/url" "time" ) type Inventory struct { Id string `json:"id"` Ats int `json:"ats"` PreOrderable bool `json:"preorderable"` BackOrderable bool `json:"backorderable"` Orderable bool `json:"orderable"` AllocationResetDate time.Time `json:"allocationResetDate,omitempty"` Perpetual bool `json:"perpetual"` StockLevel int `json:"stockLevel"` } type InventoryResponse struct { Inventory struct { Status string `json:"status"` InventoryListID string `json:"inventoryListID"` InventoryInfo Inventory `json:"inventoryInfo"` } `json:"inventory"` } func (c *Client) RequestInventory(ctx context.Context, pid string) (inv Inventory, err error) { sctx, cancel := context.WithTimeout(ctx, c.defaultTimeOut) defer cancel() var resp InventoryResponse urlPath := fmt.Sprintf("https://www.coachoutlet.com/api/inventory?vgId=%s&includeVariantData=false", url.QueryEscape(pid)) err = tryRequest(sctx, urlPath, &resp, c.pool.RandomIterator()) inv = resp.Inventory.InventoryInfo return }