@@ -6,7 +6,10 @@ import (
6
6
"time"
7
7
)
8
8
9
- const locationsBasePath = "locations"
9
+ const (
10
+ locationsBasePath = "locations"
11
+ locationsResourceName = "locations"
12
+ )
10
13
11
14
// LocationService is an interface for interfacing with the location endpoints
12
15
// of the Shopify API.
@@ -18,6 +21,9 @@ type LocationService interface {
18
21
Get (ctx context.Context , id uint64 , options interface {}) (* Location , error )
19
22
// Retrieves a count of locations
20
23
Count (ctx context.Context , options interface {}) (int , error )
24
+
25
+ // MetafieldsService used for Location resource to communicate with Metafields resource
26
+ MetafieldsService
21
27
}
22
28
23
29
type Location struct {
@@ -100,6 +106,42 @@ func (s *LocationServiceOp) Count(ctx context.Context, options interface{}) (int
100
106
return s .client .Count (ctx , path , options )
101
107
}
102
108
109
+ // ListMetafields for a Location resource.
110
+ func (s * LocationServiceOp ) ListMetafields (ctx context.Context , locationId uint64 , options interface {}) ([]Metafield , error ) {
111
+ metafieldService := & MetafieldServiceOp {client : s .client , resource : locationsResourceName , resourceId : locationId }
112
+ return metafieldService .List (ctx , options )
113
+ }
114
+
115
+ // Count metafields for a Location resource.
116
+ func (s * LocationServiceOp ) CountMetafields (ctx context.Context , locationId uint64 , options interface {}) (int , error ) {
117
+ metafieldService := & MetafieldServiceOp {client : s .client , resource : locationsResourceName , resourceId : locationId }
118
+ return metafieldService .Count (ctx , options )
119
+ }
120
+
121
+ // GetMetafield for a Location resource.
122
+ func (s * LocationServiceOp ) GetMetafield (ctx context.Context , locationId uint64 , metafieldId uint64 , options interface {}) (* Metafield , error ) {
123
+ metafieldService := & MetafieldServiceOp {client : s .client , resource : locationsResourceName , resourceId : locationId }
124
+ return metafieldService .Get (ctx , metafieldId , options )
125
+ }
126
+
127
+ // CreateMetafield for a Location resource.
128
+ func (s * LocationServiceOp ) CreateMetafield (ctx context.Context , locationId uint64 , metafield Metafield ) (* Metafield , error ) {
129
+ metafieldService := & MetafieldServiceOp {client : s .client , resource : locationsResourceName , resourceId : locationId }
130
+ return metafieldService .Create (ctx , metafield )
131
+ }
132
+
133
+ // UpdateMetafield for a Location resource.
134
+ func (s * LocationServiceOp ) UpdateMetafield (ctx context.Context , locationId uint64 , metafield Metafield ) (* Metafield , error ) {
135
+ metafieldService := & MetafieldServiceOp {client : s .client , resource : locationsResourceName , resourceId : locationId }
136
+ return metafieldService .Update (ctx , metafield )
137
+ }
138
+
139
+ // DeleteMetafield for a Location resource.
140
+ func (s * LocationServiceOp ) DeleteMetafield (ctx context.Context , locationId uint64 , metafieldId uint64 ) error {
141
+ metafieldService := & MetafieldServiceOp {client : s .client , resource : locationsResourceName , resourceId : locationId }
142
+ return metafieldService .Delete (ctx , metafieldId )
143
+ }
144
+
103
145
// Represents the result from the locations/X.json endpoint
104
146
type LocationResource struct {
105
147
Location * Location `json:"location"`
0 commit comments