forked from bold-commerce/go-shopify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfulfillment_order.go
52 lines (45 loc) · 1.97 KB
/
fulfillment_order.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package goshopify
import (
"fmt"
)
// FulfillmentOrderService is an interface for interfacing with the fulfillment endpoints
// of the Shopify API.
// https://shopify.dev/api/admin-rest/2022-10/resources/fulfillmentorder
type FulfillmentOrderService interface {
List(interface{}) ([]FulfillmentOrder, error)
}
// FulfillmentOrdersService is an interface for other Shopify resources
// to interface with the fulfillment endpoints of the Shopify API.
// https://help.shopify.com/api/reference/fulfillment
type FulfillmentOrdersService interface {
ListFulfillmentOrders(int64, interface{}) ([]FulfillmentOrder, error)
}
// FulfillmentOrderServiceOp handles communication with the fulfillment order
// related methods of the Shopify API.
type FulfillmentOrderServiceOp struct {
client *Client
resource string
resourceID int64
}
// FulfillmentOrder represents a Shopify fulfillment order.
type FulfillmentOrder struct {
ID int64 `json:"id,omitempty"`
ShopID int64 `json:"shop_id,omitempty"`
OrderID int64 `json:"order_id,omitempty"`
Status string `json:"status,omitempty"`
LineItems []FulfillmentOrderLineItem `json:"line_items"`
// Note: There are a lot of other possible fields however current we only care about ID and LineItems
// https://shopify.dev/api/admin-rest/2022-10/resources/fulfillmentorder#resource-object
}
// FulfillmentOrdersResource represents the result from the orders/{order_id}/fulfillment_orders.json endpoint
type FulfillmentOrdersResource struct {
FulfillmentOrders []FulfillmentOrder `json:"fulfillment_orders"`
}
// List fulfillment orders
func (s *FulfillmentOrderServiceOp) List(options interface{}) ([]FulfillmentOrder, error) {
prefix := FulfillmentOrderPathPrefix(s.resource, s.resourceID)
path := fmt.Sprintf("%s.json", prefix)
resource := new(FulfillmentOrdersResource)
err := s.client.Get(path, resource, options)
return resource.FulfillmentOrders, err
}