Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add product status to list options #236

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions product.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,23 @@ type ProductServiceOp struct {
client *Client
}

type productStatus string
// ProductStatus represents a Shopify product status.
type ProductStatus string
oliver006 marked this conversation as resolved.
Show resolved Hide resolved

// https://shopify.dev/docs/api/admin-rest/2023-07/resources/product#resource-object
const (
//The product is ready to sell and is available to customers on the online store,
//sales channels, and apps. By default, existing products are set to active.
ProductStatusActive productStatus = "active"
ProductStatusActive ProductStatus = "active"

//The product is no longer being sold and isn't available to customers on sales
//channels and apps.
ProductStatusArchived productStatus = "archived"
ProductStatusArchived ProductStatus = "archived"

//The product isn't ready to sell and is unavailable to customers on sales
//channels and apps. By default, duplicated and unarchived products are set to
//draft.
ProductStatucDraft productStatus = "draft"
ProductStatucDraft ProductStatus = "draft"
)

// Product represents a Shopify product
Expand All @@ -65,7 +66,7 @@ type Product struct {
PublishedAt *time.Time `json:"published_at,omitempty"`
PublishedScope string `json:"published_scope,omitempty"`
Tags string `json:"tags,omitempty"`
Status productStatus `json:"status,omitempty"`
Status ProductStatus `json:"status,omitempty"`
Options []ProductOption `json:"options,omitempty"`
Variants []Variant `json:"variants,omitempty"`
Image Image `json:"image,omitempty"`
Expand All @@ -88,14 +89,15 @@ type ProductOption struct {

type ProductListOptions struct {
ListOptions
CollectionID int64 `url:"collection_id,omitempty"`
ProductType string `url:"product_type,omitempty"`
Vendor string `url:"vendor,omitempty"`
Handle string `url:"handle,omitempty"`
PublishedAtMin time.Time `url:"published_at_min,omitempty"`
PublishedAtMax time.Time `url:"published_at_max,omitempty"`
PublishedStatus string `url:"published_status,omitempty"`
PresentmentCurrencies string `url:"presentment_currencies,omitempty"`
CollectionID int64 `url:"collection_id,omitempty"`
ProductType string `url:"product_type,omitempty"`
Vendor string `url:"vendor,omitempty"`
Handle string `url:"handle,omitempty"`
PublishedAtMin time.Time `url:"published_at_min,omitempty"`
PublishedAtMax time.Time `url:"published_at_max,omitempty"`
PublishedStatus string `url:"published_status,omitempty"`
PresentmentCurrencies string `url:"presentment_currencies,omitempty"`
Status []ProductStatus `url:"status,omitempty,comma"`
}

// Represents the result from the products/X.json endpoint
Expand Down