Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3621b66437 |
@@ -11,6 +11,21 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Unmarshalling accidental numbers received from MAL to strings
|
||||||
|
func (f *FlexString) UnmarshalJSON(data []byte) error {
|
||||||
|
var s string
|
||||||
|
if err := json.Unmarshal(data, &s); err == nil {
|
||||||
|
*f = FlexString(s)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var n json.Number
|
||||||
|
if err := json.Unmarshal(data, &n); err == nil {
|
||||||
|
*f = FlexString(string(n))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return fmt.Errorf("FlexString: invalid value")
|
||||||
|
}
|
||||||
|
|
||||||
func MALHelper(method string, malUrl string, body url.Values) (json.RawMessage, string, error) {
|
func MALHelper(method string, malUrl string, body url.Values) (json.RawMessage, string, error) {
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
|
|
||||||
|
|||||||
16
MALTypes.go
16
MALTypes.go
@@ -1,6 +1,10 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type FlexString string
|
||||||
|
|
||||||
type MyAnimeListJWT struct {
|
type MyAnimeListJWT struct {
|
||||||
TokenType string `json:"token_type"`
|
TokenType string `json:"token_type"`
|
||||||
@@ -129,11 +133,11 @@ type MALAnime struct {
|
|||||||
Statistics struct {
|
Statistics struct {
|
||||||
NumListUsers int `json:"num_list_users" ts_type:"numListUsers"`
|
NumListUsers int `json:"num_list_users" ts_type:"numListUsers"`
|
||||||
Status struct {
|
Status struct {
|
||||||
Watching string `json:"watching" ts_type:"watching"`
|
Watching FlexString `json:"watching" ts_type:"string"`
|
||||||
Completed string `json:"completed" ts_type:"completed"`
|
Completed FlexString `json:"completed" ts_type:"string"`
|
||||||
OnHold string `json:"on_hold" ts_type:"onHold"`
|
OnHold FlexString `json:"on_hold" ts_type:"string"`
|
||||||
Dropped string `json:"dropped" ts_type:"dropped"`
|
Dropped FlexString `json:"dropped" ts_type:"string"`
|
||||||
PlanToWatch string `json:"plan_to_watch" ts_type:"planToWatch"`
|
PlanToWatch FlexString `json:"plan_to_watch" ts_type:"string"`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user