Skip to content

Profile Service

The SkoobProfileService lets you modify your Skoob profile by labeling, shelving and rating books.

Example

import os
from pyskoob import SkoobClient
from pyskoob.models.enums import BookStatus

with SkoobClient() as client:
    client.auth.login(
        email=os.getenv("SKOOB_EMAIL"),
        password=os.getenv("SKOOB_PASSWORD"),
    )
    client.profile.update_book_status(10, BookStatus.READ)

Profile management helpers for authenticated Skoob users.

AsyncSkoobProfileService

Bases: _ProfileServiceMixin, AsyncAuthenticatedService

Asynchronous variant of :class:SkoobProfileService.

Source code in pyskoob/profile.py
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
class AsyncSkoobProfileService(_ProfileServiceMixin, AsyncAuthenticatedService):  # pragma: no cover - thin async wrapper
    """Asynchronous variant of :class:`SkoobProfileService`."""

    def __init__(self, client: AsyncHTTPClient, auth_service: AsyncAuthService):
        super().__init__(client, auth_service)

    async def add_book_label(self, edition_id: int, label: BookLabel) -> bool:
        """Add a label to a book in the authenticated profile.

        Parameters
        ----------
        edition_id : int
            Edition identifier of the book.
        label : BookLabel
            Label to associate with the book.

        Returns
        -------
        bool
            ``True`` if the label was added successfully.
        """

        return await self._add_book_label(edition_id, label)

    async def remove_book_label(self, edition_id: int) -> bool:
        """Remove a label from a book in the authenticated profile.

        Parameters
        ----------
        edition_id : int
            Edition identifier of the book.

        Returns
        -------
        bool
            ``True`` if the label was removed successfully.
        """

        return await self._remove_book_label(edition_id)

    async def update_book_status(self, edition_id: int, status: BookStatus) -> bool:
        """Update the user's status for a book.

        Parameters
        ----------
        edition_id : int
            Edition identifier of the book.
        status : BookStatus
            New status to assign to the book.

        Returns
        -------
        bool
            ``True`` if the status was updated successfully.
        """

        return await self._update_book_status(edition_id, status)

    async def remove_book_status(self, edition_id: int) -> bool:
        """Remove the user's status for a book.

        Parameters
        ----------
        edition_id : int
            Edition identifier of the book.

        Returns
        -------
        bool
            ``True`` if the status was removed successfully.
        """

        return await self._remove_book_status(edition_id)

    async def change_book_shelf(self, edition_id: int, bookshelf: BookShelf) -> bool:
        """Move a book to a different bookshelf.

        Parameters
        ----------
        edition_id : int
            Edition identifier of the book.
        bookshelf : BookShelf
            Destination bookshelf.

        Returns
        -------
        bool
            ``True`` if the book was moved successfully.
        """

        return await self._change_book_shelf(edition_id, bookshelf)

    async def rate_book(self, edition_id: int, rating: float) -> bool:
        """Rate a book in the authenticated profile.

        Parameters
        ----------
        edition_id : int
            Edition identifier of the book.
        rating : float
            Rating between ``0`` and ``5``.

        Returns
        -------
        bool
            ``True`` if the rating was stored successfully.
        """

        return await self._rate_book(edition_id, rating)

add_book_label(edition_id, label) async

Add a label to a book in the authenticated profile.

Parameters:

Name Type Description Default
edition_id int

Edition identifier of the book.

required
label BookLabel

Label to associate with the book.

required

Returns:

Type Description
bool

True if the label was added successfully.

Source code in pyskoob/profile.py
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
async def add_book_label(self, edition_id: int, label: BookLabel) -> bool:
    """Add a label to a book in the authenticated profile.

    Parameters
    ----------
    edition_id : int
        Edition identifier of the book.
    label : BookLabel
        Label to associate with the book.

    Returns
    -------
    bool
        ``True`` if the label was added successfully.
    """

    return await self._add_book_label(edition_id, label)

change_book_shelf(edition_id, bookshelf) async

Move a book to a different bookshelf.

Parameters:

Name Type Description Default
edition_id int

Edition identifier of the book.

required
bookshelf BookShelf

Destination bookshelf.

required

Returns:

Type Description
bool

True if the book was moved successfully.

Source code in pyskoob/profile.py
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
async def change_book_shelf(self, edition_id: int, bookshelf: BookShelf) -> bool:
    """Move a book to a different bookshelf.

    Parameters
    ----------
    edition_id : int
        Edition identifier of the book.
    bookshelf : BookShelf
        Destination bookshelf.

    Returns
    -------
    bool
        ``True`` if the book was moved successfully.
    """

    return await self._change_book_shelf(edition_id, bookshelf)

rate_book(edition_id, rating) async

Rate a book in the authenticated profile.

Parameters:

Name Type Description Default
edition_id int

Edition identifier of the book.

required
rating float

Rating between 0 and 5.

required

Returns:

Type Description
bool

True if the rating was stored successfully.

Source code in pyskoob/profile.py
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
async def rate_book(self, edition_id: int, rating: float) -> bool:
    """Rate a book in the authenticated profile.

    Parameters
    ----------
    edition_id : int
        Edition identifier of the book.
    rating : float
        Rating between ``0`` and ``5``.

    Returns
    -------
    bool
        ``True`` if the rating was stored successfully.
    """

    return await self._rate_book(edition_id, rating)

remove_book_label(edition_id) async

Remove a label from a book in the authenticated profile.

Parameters:

Name Type Description Default
edition_id int

Edition identifier of the book.

required

Returns:

Type Description
bool

True if the label was removed successfully.

Source code in pyskoob/profile.py
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
async def remove_book_label(self, edition_id: int) -> bool:
    """Remove a label from a book in the authenticated profile.

    Parameters
    ----------
    edition_id : int
        Edition identifier of the book.

    Returns
    -------
    bool
        ``True`` if the label was removed successfully.
    """

    return await self._remove_book_label(edition_id)

remove_book_status(edition_id) async

Remove the user's status for a book.

Parameters:

Name Type Description Default
edition_id int

Edition identifier of the book.

required

Returns:

Type Description
bool

True if the status was removed successfully.

Source code in pyskoob/profile.py
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
async def remove_book_status(self, edition_id: int) -> bool:
    """Remove the user's status for a book.

    Parameters
    ----------
    edition_id : int
        Edition identifier of the book.

    Returns
    -------
    bool
        ``True`` if the status was removed successfully.
    """

    return await self._remove_book_status(edition_id)

update_book_status(edition_id, status) async

Update the user's status for a book.

Parameters:

Name Type Description Default
edition_id int

Edition identifier of the book.

required
status BookStatus

New status to assign to the book.

required

Returns:

Type Description
bool

True if the status was updated successfully.

Source code in pyskoob/profile.py
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
async def update_book_status(self, edition_id: int, status: BookStatus) -> bool:
    """Update the user's status for a book.

    Parameters
    ----------
    edition_id : int
        Edition identifier of the book.
    status : BookStatus
        New status to assign to the book.

    Returns
    -------
    bool
        ``True`` if the status was updated successfully.
    """

    return await self._update_book_status(edition_id, status)

SkoobProfileService

Bases: _ProfileServiceMixin, AuthenticatedService

Perform profile-related actions such as labeling and rating books.

Source code in pyskoob/profile.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
class SkoobProfileService(_ProfileServiceMixin, AuthenticatedService):
    """Perform profile-related actions such as labeling and rating books."""

    def __init__(self, client: SyncHTTPClient, auth_service: AuthService):
        """Initialize the service with dependencies.

        This service requires an authenticated session via
        :class:`AuthService` and is typically used alongside
        :class:`UserService` when manipulating the logged user's bookshelf
        and other profile metadata.

        Parameters
        ----------
        client : SyncHTTPClient
            The HTTP client to use for requests.
        auth_service : AuthService
            The authentication service.
        """
        super().__init__(client, auth_service)

    def add_book_label(self, edition_id: int, label: BookLabel) -> bool:
        """
        Adds a label to a book.

        Parameters
        ----------
        edition_id : int
            The edition ID of the book.
        label : BookLabel
            The label to add.

        Returns
        -------
        bool
            True if the label was added successfully, False otherwise.

        Examples
        --------
        >>> service.add_book_label(10, BookLabel.FAVORITE)
        True
        """
        return run_sync(self._add_book_label(edition_id, label))

    def remove_book_label(self, edition_id: int) -> bool:
        """
        Removes a label from a book.

        Parameters
        ----------
        edition_id : int
            The edition ID of the book.

        Returns
        -------
        bool
            True if the label was removed successfully, False otherwise.

        Examples
        --------
        >>> service.remove_book_label(10)
        True
        """
        return run_sync(self._remove_book_label(edition_id))

    def update_book_status(self, edition_id: int, status: BookStatus) -> bool:
        """
        Updates the status of a book.

        Parameters
        ----------
        edition_id : int
            The edition ID of the book.
        status : BookStatus
            The new status for the book.

        Returns
        -------
        bool
            True if the status was updated successfully, False otherwise.

        Examples
        --------
        >>> service.update_book_status(10, BookStatus.READ)
        True
        """
        return run_sync(self._update_book_status(edition_id, status))

    def remove_book_status(self, edition_id: int) -> bool:
        """
        Removes the status of a book.

        Parameters
        ----------
        edition_id : int
            The edition ID of the book.

        Returns
        -------
        bool
            True if the status was removed successfully, False otherwise.

        Examples
        --------
        >>> service.remove_book_status(10)
        True
        """
        return run_sync(self._remove_book_status(edition_id))

    def change_book_shelf(self, edition_id: int, bookshelf: BookShelf) -> bool:
        """
        Changes the bookshelf of a book.

        Parameters
        ----------
        edition_id : int
            The edition ID of the book.
        bookshelf : BookShelf
            The new bookshelf for the book.

        Returns
        -------
        bool
            True if the bookshelf was changed successfully, False otherwise.

        Examples
        --------
        >>> service.change_book_shelf(10, BookShelf.BOOK)
        True
        """
        return run_sync(self._change_book_shelf(edition_id, bookshelf))

    def rate_book(self, edition_id: int, rating: float) -> bool:
        """Rates a book.

        Parameters
        ----------
        edition_id : int
            The edition ID of the book.
        rating : float
            The rating to give to the book (from 0 to 5).

        Returns
        -------
        bool
            True if the book was rated successfully.

        Raises
        ------
        ValueError
            If the rating is not between 0 and 5.
        ProfileError
            If the service fails to persist the rating.

        Examples
        --------
        >>> service.rate_book(10, 4.5)
        True
        """
        return run_sync(self._rate_book(edition_id, rating))

__init__(client, auth_service)

Initialize the service with dependencies.

This service requires an authenticated session via :class:AuthService and is typically used alongside :class:UserService when manipulating the logged user's bookshelf and other profile metadata.

Parameters:

Name Type Description Default
client SyncHTTPClient

The HTTP client to use for requests.

required
auth_service AuthService

The authentication service.

required
Source code in pyskoob/profile.py
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
def __init__(self, client: SyncHTTPClient, auth_service: AuthService):
    """Initialize the service with dependencies.

    This service requires an authenticated session via
    :class:`AuthService` and is typically used alongside
    :class:`UserService` when manipulating the logged user's bookshelf
    and other profile metadata.

    Parameters
    ----------
    client : SyncHTTPClient
        The HTTP client to use for requests.
    auth_service : AuthService
        The authentication service.
    """
    super().__init__(client, auth_service)

add_book_label(edition_id, label)

Adds a label to a book.

Parameters:

Name Type Description Default
edition_id int

The edition ID of the book.

required
label BookLabel

The label to add.

required

Returns:

Type Description
bool

True if the label was added successfully, False otherwise.

Examples:

>>> service.add_book_label(10, BookLabel.FAVORITE)
True
Source code in pyskoob/profile.py
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
def add_book_label(self, edition_id: int, label: BookLabel) -> bool:
    """
    Adds a label to a book.

    Parameters
    ----------
    edition_id : int
        The edition ID of the book.
    label : BookLabel
        The label to add.

    Returns
    -------
    bool
        True if the label was added successfully, False otherwise.

    Examples
    --------
    >>> service.add_book_label(10, BookLabel.FAVORITE)
    True
    """
    return run_sync(self._add_book_label(edition_id, label))

change_book_shelf(edition_id, bookshelf)

Changes the bookshelf of a book.

Parameters:

Name Type Description Default
edition_id int

The edition ID of the book.

required
bookshelf BookShelf

The new bookshelf for the book.

required

Returns:

Type Description
bool

True if the bookshelf was changed successfully, False otherwise.

Examples:

>>> service.change_book_shelf(10, BookShelf.BOOK)
True
Source code in pyskoob/profile.py
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
def change_book_shelf(self, edition_id: int, bookshelf: BookShelf) -> bool:
    """
    Changes the bookshelf of a book.

    Parameters
    ----------
    edition_id : int
        The edition ID of the book.
    bookshelf : BookShelf
        The new bookshelf for the book.

    Returns
    -------
    bool
        True if the bookshelf was changed successfully, False otherwise.

    Examples
    --------
    >>> service.change_book_shelf(10, BookShelf.BOOK)
    True
    """
    return run_sync(self._change_book_shelf(edition_id, bookshelf))

rate_book(edition_id, rating)

Rates a book.

Parameters:

Name Type Description Default
edition_id int

The edition ID of the book.

required
rating float

The rating to give to the book (from 0 to 5).

required

Returns:

Type Description
bool

True if the book was rated successfully.

Raises:

Type Description
ValueError

If the rating is not between 0 and 5.

ProfileError

If the service fails to persist the rating.

Examples:

>>> service.rate_book(10, 4.5)
True
Source code in pyskoob/profile.py
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
def rate_book(self, edition_id: int, rating: float) -> bool:
    """Rates a book.

    Parameters
    ----------
    edition_id : int
        The edition ID of the book.
    rating : float
        The rating to give to the book (from 0 to 5).

    Returns
    -------
    bool
        True if the book was rated successfully.

    Raises
    ------
    ValueError
        If the rating is not between 0 and 5.
    ProfileError
        If the service fails to persist the rating.

    Examples
    --------
    >>> service.rate_book(10, 4.5)
    True
    """
    return run_sync(self._rate_book(edition_id, rating))

remove_book_label(edition_id)

Removes a label from a book.

Parameters:

Name Type Description Default
edition_id int

The edition ID of the book.

required

Returns:

Type Description
bool

True if the label was removed successfully, False otherwise.

Examples:

>>> service.remove_book_label(10)
True
Source code in pyskoob/profile.py
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
def remove_book_label(self, edition_id: int) -> bool:
    """
    Removes a label from a book.

    Parameters
    ----------
    edition_id : int
        The edition ID of the book.

    Returns
    -------
    bool
        True if the label was removed successfully, False otherwise.

    Examples
    --------
    >>> service.remove_book_label(10)
    True
    """
    return run_sync(self._remove_book_label(edition_id))

remove_book_status(edition_id)

Removes the status of a book.

Parameters:

Name Type Description Default
edition_id int

The edition ID of the book.

required

Returns:

Type Description
bool

True if the status was removed successfully, False otherwise.

Examples:

>>> service.remove_book_status(10)
True
Source code in pyskoob/profile.py
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
def remove_book_status(self, edition_id: int) -> bool:
    """
    Removes the status of a book.

    Parameters
    ----------
    edition_id : int
        The edition ID of the book.

    Returns
    -------
    bool
        True if the status was removed successfully, False otherwise.

    Examples
    --------
    >>> service.remove_book_status(10)
    True
    """
    return run_sync(self._remove_book_status(edition_id))

update_book_status(edition_id, status)

Updates the status of a book.

Parameters:

Name Type Description Default
edition_id int

The edition ID of the book.

required
status BookStatus

The new status for the book.

required

Returns:

Type Description
bool

True if the status was updated successfully, False otherwise.

Examples:

>>> service.update_book_status(10, BookStatus.READ)
True
Source code in pyskoob/profile.py
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
def update_book_status(self, edition_id: int, status: BookStatus) -> bool:
    """
    Updates the status of a book.

    Parameters
    ----------
    edition_id : int
        The edition ID of the book.
    status : BookStatus
        The new status for the book.

    Returns
    -------
    bool
        True if the status was updated successfully, False otherwise.

    Examples
    --------
    >>> service.update_book_status(10, BookStatus.READ)
    True
    """
    return run_sync(self._update_book_status(edition_id, status))