29 lines
477 B
Go
29 lines
477 B
Go
package anilibria
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"git.thefoxon.ru/anilibria/anilibria-go/model"
|
|
)
|
|
|
|
func GetTitleByID(id uint64) (title *model.Title, err error) {
|
|
|
|
if id == 0 {
|
|
return nil, errors.New(errorTitleIdIsZero)
|
|
}
|
|
|
|
reqBody, status, err := request("GET", fmt.Sprintf("/v3/title?id=%d", id), nil)
|
|
|
|
if status != 200 {
|
|
return nil, errors.New(errorFetchTitle)
|
|
}
|
|
|
|
if err = json.Unmarshal(reqBody, &title); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return
|
|
}
|