onepiece-tcg-notion-importer/types.go

78 lines
2.0 KiB
Go

package main
import (
"encoding/json"
"time"
)
type isoDate struct {
time.Time
}
func (d *isoDate) UnmarshalJSON(b []byte) error {
var s string
if err := json.Unmarshal(b, &s); err != nil {
return err
}
t, _ := time.Parse("2006-01-02", s)
d.Time = t
return nil
}
func (d isoDate) MarshalJSON() ([]byte, error) {
return json.Marshal(d.Format("2006-01-02"))
}
// {"src_id":"0","name":"TBD","intl":"0","release_date":null,"imageURL":"","t":"0","filter":""}
type source struct {
SourceID string `json:"src_id"`
Name string `json:"name"`
International string `json:"intl"`
ReleaseDate isoDate `json:"release_date"`
ImageURL string `json:"image_url"`
T string `json:"t"`
Filter string `json:"filter"`
}
/* {
"gid": "47",
"cid": "OP01-047",
"n": "Trafalgar Law",
"t": "2",
"col": "7",
"cs": "5",
"tr": "Supernovas\/ Heart Pirates",
"a": "1",
"p": "6000",
"cp": null,
"l": null,
"r": "5",
"ar": null,
"iu": "https:\/\/onepiece-cardgame.dev\/images\/cards\/OP01-047_616aca_jp.jpg",
"e": "<Blocker>\r\n[On Play] You may return one of your Characters to your hand: Play 1 Cost 3 or lower Character Card from your hand.",
"al": null,
"intl": "0",
"srcN": "Romance Dawn [OP-01]",
"srcD": null
} */
type card struct {
GlobalID string `json:"gid"`
CardID string `json:"cid"`
Name string `json:"n"`
Type string `json:"t"`
Color string `json:"col"`
Source string `json:"cs"`
Tr string `json:"tr"`
AttackType string `json:"a"`
P string `json:"p"`
Cp string `json:"cp"`
L interface{} `json:"l"`
Rarity string `json:"r"`
Ar string `json:"ar"`
ImageURL string `json:"iu"`
E string `json:"e"`
Al interface{} `json:"al"`
International string `json:"intl"`
SourceName string `json:"srcN"`
SrcD interface{} `json:"srcD"`
}