Skip to content

Commit

Permalink
Create a fulfillment for one or many fulfillment orders (#241)
Browse files Browse the repository at this point in the history
* Add line_items_by_fulfillment_order

* Add line_items_by_fulfillment_order

* Add tracking_info to Fulfillment

* Use FulfillmentOrderLineItemQuantity struct for LineItemByFulfillmentOrder fulfillment_order_line_items

* Create separate LineItemByFulfillmentOrderItemQuantity struct
  • Loading branch information
AndrewChau authored Nov 14, 2023
1 parent 26d463b commit 6eac8e0
Showing 1 changed file with 39 additions and 16 deletions.
55 changes: 39 additions & 16 deletions fulfillment.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,45 @@ type FulfillmentServiceOp struct {

// Fulfillment represents a Shopify fulfillment.
type Fulfillment struct {
ID int64 `json:"id,omitempty"`
OrderID int64 `json:"order_id,omitempty"`
LocationID int64 `json:"location_id,omitempty"`
Status string `json:"status,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
Service string `json:"service,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
TrackingCompany string `json:"tracking_company,omitempty"`
ShipmentStatus string `json:"shipment_status,omitempty"`
TrackingNumber string `json:"tracking_number,omitempty"`
TrackingNumbers []string `json:"tracking_numbers,omitempty"`
TrackingUrl string `json:"tracking_url,omitempty"`
TrackingUrls []string `json:"tracking_urls,omitempty"`
Receipt Receipt `json:"receipt,omitempty"`
LineItems []LineItem `json:"line_items,omitempty"`
NotifyCustomer bool `json:"notify_customer"`
ID int64 `json:"id,omitempty"`
OrderID int64 `json:"order_id,omitempty"`
LocationID int64 `json:"location_id,omitempty"`
Status string `json:"status,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
Service string `json:"service,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
TrackingCompany string `json:"tracking_company,omitempty"`
ShipmentStatus string `json:"shipment_status,omitempty"`
TrackingInfo FulfillmentTrackingInfo `json:"tracking_info,omitempty"`
TrackingNumber string `json:"tracking_number,omitempty"`
TrackingNumbers []string `json:"tracking_numbers,omitempty"`
TrackingUrl string `json:"tracking_url,omitempty"`
TrackingUrls []string `json:"tracking_urls,omitempty"`
Receipt Receipt `json:"receipt,omitempty"`
LineItems []LineItem `json:"line_items,omitempty"`
LineItemsByFulfillmentOrder []LineItemByFulfillmentOrder `json:"line_items_by_fulfillment_order,omitempty"`
NotifyCustomer bool `json:"notify_customer"`
}

// FulfillmentTrackingInfo represents the tracking information used to create a Fulfillment.
// https://shopify.dev/docs/api/admin-rest/2023-01/resources/fulfillment#post-fulfillments
type FulfillmentTrackingInfo struct {
Company string `json:"company,omitempty"`
Number string `json:"number,omitempty"`
Url string `json:"url,omitempty"`
}

// LineItemByFulfillmentOrder represents the FulfillmentOrders (and optionally the items) used to create a Fulfillment.
// https://shopify.dev/docs/api/admin-rest/2023-01/resources/fulfillment#post-fulfillments
type LineItemByFulfillmentOrder struct {
FulfillmentOrderID int64 `json:"fulfillment_order_id,omitempty"`
FulfillmentOrderLineItems []LineItemByFulfillmentOrderItemQuantity `json:"fulfillment_order_line_items,omitempty"`
}

// LineItemByFulfillmentOrderItemQuantity represents the quantity to fulfill for one item.
type LineItemByFulfillmentOrderItemQuantity struct {
Id int64 `json:"id"`
Quantity int64 `json:"quantity"`
}

// Receipt represents a Shopify receipt.
Expand Down

0 comments on commit 6eac8e0

Please sign in to comment.