25 lines
422 B
Go
25 lines
422 B
Go
package anilibria
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"git.thefoxon.ru/anilibria/anilibria-go/model"
|
|
)
|
|
|
|
func GetTitleByCode(code string) (title *model.Title, err error) {
|
|
|
|
reqBody, status, err := request("GET", fmt.Sprintf("/v3/title?code=%s", code), nil)
|
|
|
|
if status != 200 {
|
|
return nil, errors.New(errorFetchTitle)
|
|
}
|
|
|
|
if err = json.Unmarshal(reqBody, &title); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return
|
|
}
|