package goanilist import "encoding/json" type APIError interface { Get() *FlexibleError } type FlexibleError struct { RawError json.RawMessage `json:"error"` Error string ErrorMessage string `json:"error_message"` } type complexError struct { Error string `json:"error"` ErrorDescription string `json:"error_description"` } func (e *FlexibleError) ParseRawError() { ce := complexError{} err := json.Unmarshal(e.RawError, &ce) if err == nil { e.Error = ce.Error e.ErrorMessage = ce.ErrorDescription } else { e.Error = string(e.RawError) } } func (e *FlexibleError) Get() *FlexibleError { return e } type AccessTokenResult struct { FlexibleError AccessToken string `json:"access_token"` TokenType string `json:"token_type"` Expires int64 `json:"expires"` ExpiresIn int `json:"expires_in"` RefreshToken string `json:"refresh_token"` } type UserResult struct { FlexibleError ID int `json:"id"` DisplayName string `json:"display_name"` }