/
en-lineup-item.go
50 lines (40 loc) · 1.52 KB
/
en-lineup-item.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
package amiibo
import (
"path/filepath"
"strings"
)
// ENGLineupItem is the unfettered Nintendo Amiibo product additional information from nintendo.com.
//
// ENGLineupItem contains additional information for a Nintendo Amiibo product.
type ENGLineupItem struct {
// Description is the verbose Nintendo Amiibo product summary.
//
// Description is often a null field.
Description string `json:"description"`
// LastModified is the Nintendo Amiibo product release date in milliseconds.
LastModified int64 `json:"lastModified"`
// Path is the relative path to the Nintendo Amiibo product information page according to the nintendo.com CDN.
Path string `json:"path"`
// Title is the name of the Nintendo Amiibo product.
//
// Title can contain special characters that require filtering.
Title string `json:"title"`
// URL is the relative path URL to the Nintendo Amiibo product information page.
//
// URL requires nintendo.com to be prepended to the URL.
URL string `json:"url"`
}
// GetID returns the ENGLineupItem ID.
func (e ENGLineupItem) GetID() string {
return strings.TrimSuffix(filepath.Base(e.URL), ".html")
}
// ReadENGLineupItem reads a ENGLineupItem from disc.
func ReadENGLineupItem(dir string, filename string) (v ENGLineupItem, err error) {
err = readJSONFile(dir, filename, &v)
return v, err
}
// WriteENGLineupItem writes a ENGLineupItem to disc.
func WriteENGLineupItem(dir string, filename string, v *ENGLineupItem) (fullpath string, err error) {
fullpath, err = writeJSONFile(dir, filename, v)
return
}