//LookupBook returns Book data from openBD
LookupBook returns Book data from openBD
// LookupBook returns Book data from openBD
func (a *AozoraAPI) LookupBook(ctx context.Context, id string) (*entity.Book, error) {
	bookId, err := strconv.Atoi(id)
	if err != nil {
		return nil, errs.New(
			fmt.Sprintf("invalid book id: %v", id),
			errs.WithCause(err),
			errs.WithContext("id", id),
		)
	}
	bk, err := a.server.CreateClient().LookupBookContext(ctx, bookId)
	if err != nil {
		return nil, errs.Wrap(err, errs.WithContext("id", id))
	}
	book := &entity.Book{
		Type:            a.Name(),
		ID:              strconv.Itoa(bk.BookID),
		Title:           bk.Title,
		SubTitle:        bk.Subtitle,
		OriginalTitle:   bk.OriginalTitle,
		URL:             bk.CardURL,
		ProductType:     "青空文庫",
		Codes:           []entity.Code{{Name: "図書カードNo.", Value: strconv.Itoa(bk.BookID)}},
		Creators:        getCreators(bk),
		PublicationDate: values.NewDate(bk.ReleaseDate.Time),
		LastRelease:     values.NewDate(bk.LastModified.Time),
		PublicDomain:    !bk.Copyright,
		FirstAppearance: bk.FirstAppearance,
		Service:         entity.Service{Name: "aozorahack", URL: "https://aozorahack.org/"},
	}
	return book, nil
}
func ( a * AozoraAPI ) LookupBook ( ctx context . Context , id string ) ( * entity . Book , error ) { bookId , err := strconv . Atoi ( id ) if err != nil { return nil , errs . New ( fmt . Sprintf ( " " , id ) , errs . WithCause ( err ) , errs . WithContext ( " " , id ) , ) } bk , err := a . server . CreateClient ( ) . LookupBookContext ( ctx , bookId ) if err != nil { return nil , errs . Wrap ( err , errs . WithContext ( " " , id ) ) } book := & entity . Book { Type : a . Name ( ) , ID : strconv . Itoa ( bk . BookID ) , Title : bk . Title , SubTitle : bk . Subtitle , OriginalTitle : bk . OriginalTitle , URL : bk . CardURL , ProductType : " Codes : [ ] entity . Code { { Name : " s t conv. I oa(bk.B o okID ) }} , Creators : getCreators ( bk ) , PublicationDate : values . NewDate ( bk . ReleaseDate . Time ) , LastRelease : values . NewDate ( bk . LastModified . Time ) , PublicDomain : ! bk . Copyright , FirstAppearance : bk . FirstAppearance , Service : entity . Service { Name : " " , URL : " " } , } return book , nil }
LookupBook returns Book data from openBD
LookupBook returns Book data from openBD