mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Use Account struct directly instead of maps
This commit is contained in:
parent
acc6c63ebd
commit
b53256ca3f
1 changed files with 4 additions and 9 deletions
|
|
@ -793,8 +793,9 @@ func (c *Crunchyroll) Account() (*Account, error) {
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
var jsonBody map[string]interface{}
|
account := &Account{}
|
||||||
if err = json.NewDecoder(resp.Body).Decode(&jsonBody); err != nil {
|
|
||||||
|
if err = json.NewDecoder(resp.Body).Decode(&account); err != nil {
|
||||||
return nil, fmt.Errorf("failed to parse 'me' response: %w", err)
|
return nil, fmt.Errorf("failed to parse 'me' response: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -804,15 +805,9 @@ func (c *Crunchyroll) Account() (*Account, error) {
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if err = json.NewDecoder(resp.Body).Decode(&jsonBody); err != nil {
|
if err = json.NewDecoder(resp.Body).Decode(&account); err != nil {
|
||||||
return nil, fmt.Errorf("failed to parse 'profile' response: %w", err)
|
return nil, fmt.Errorf("failed to parse 'profile' response: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
account := &Account{}
|
|
||||||
|
|
||||||
if err := decodeMapToStruct(jsonBody, account); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return account, nil
|
return account, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue