forked from bold-commerce/go-shopify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeme.go
52 lines (44 loc) · 1.32 KB
/
theme.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"
"time"
)
const themesBasePath = "themes"
// Options for theme list
type ThemeListOptions struct {
ListOptions
Role string `url:"role,omitempty"`
}
// ThemeService is an interface for interfacing with the themes endpoints
// of the Shopify API.
// See: https://help.shopify.com/api/reference/theme
type ThemeService interface {
List(interface{}) ([]Theme, error)
}
// ThemeServiceOp handles communication with the theme related methods of
// the Shopify API.
type ThemeServiceOp struct {
client *Client
}
// Theme represents a Shopify theme
type Theme struct {
ID int64 `json:"id"`
Name string `json:"name"`
Previewable bool `json:"previewable"`
Processing bool `json:"processing"`
Role string `json:"role"`
ThemeStoreID int64 `json:"theme_store_id"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
}
// ThemesResource is the result from the themes.json endpoint
type ThemesResource struct {
Themes []Theme `json:"themes"`
}
// List all themes
func (s *ThemeServiceOp) List(options interface{}) ([]Theme, error) {
path := fmt.Sprintf("%s/%s.json", globalApiPathPrefix, themesBasePath)
resource := new(ThemesResource)
err := s.client.Get(path, resource, options)
return resource.Themes, err
}