AppStream.ReviewsClient

g AppStream.ReviewsClient AppStream.ReviewsClient GObject.Object GObject.Object GObject.Object->AppStream.ReviewsClient

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

fetch_rating_for_id (component_id)

fetch_reviews (cpt, start, limit)

fetch_reviews_for_id (component_id, version, start, limit)

get_client_id ()

get_locale ()

get_server_url ()

get_user_agent ()

get_user_hash ()

remove_review (review)

set_client_id (client_id)

set_locale (locale)

set_server_url (url)

set_user_agent (user_agent)

set_user_hash (user_hash)

submit_review (component_id, review)

vote_review (review, vote)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class AppStream.ReviewsClient(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

AppStream.ReviewsClientClass

Fetch user reviews for software components.

This class is a client for the Open Desktop Ratings Service (ODRS) or a compatible service, and can retrieve user reviews and ratings for software components.

All operations do blocking network I/O and this class is not thread-safe: When calling it from worker threads, use one instance per thread or serialize access to a shared instance with your own locking.

classmethod new()
Returns:

an AppStream.ReviewsClient

Return type:

AppStream.ReviewsClient

Creates a new AppStream.ReviewsClient.

fetch_rating_for_id(component_id)
Parameters:

component_id (str) – the ID of the software component to fetch the rating for.

Raises:

GLib.Error

Returns:

the overall rating percentage, or -1 if no rating was available.

Return type:

int

Fetch the overall user rating for the given software component ID from the reviews server, as a percentage value (where 100% means a perfect five-star rating). This call does blocking network I/O.

fetch_reviews(cpt, start, limit)
Parameters:
  • cpt (AppStream.Component) – the component to fetch reviews for.

  • start (int) – index of the first review to fetch, for pagination.

  • limit (int) – maximum amount of reviews to fetch, or 0 for the default limit.

Raises:

GLib.Error

Returns:

the fetched reviews, or None on error.

Return type:

[AppStream.Review]

Fetch user reviews for the given software component from the reviews server. The reviews are sorted by their score (most helpful first), so subsequent pages can be requested by increasing start in steps of limit. This call does blocking network I/O.

fetch_reviews_for_id(component_id, version, start, limit)
Parameters:
  • component_id (str) – the ID of the software component to fetch reviews for.

  • version (str or None) – the version of the component, or None if unknown.

  • start (int) – index of the first review to fetch, for pagination.

  • limit (int) – maximum amount of reviews to fetch, or 0 for the default limit.

Raises:

GLib.Error

Returns:

the fetched reviews, or None on error.

Return type:

[AppStream.Review]

Fetch user reviews for the given software component ID from the reviews server. The reviews are sorted by their score (most helpful first), so subsequent pages can be requested by increasing start in steps of limit. This call does blocking network I/O.

get_client_id()
Returns:

the client-ID.

Return type:

str

Get the ID of the client application which is fetching reviews.

get_locale()
Returns:

the current locale, in POSIX format.

Return type:

str

Get the locale used for filtering reviews.

get_server_url()
Returns:

the reviews server URL.

Return type:

str

Get the URL of the reviews server that we are communicating with.

get_user_agent()
Returns:

the user agent string.

Return type:

str or None

Get the user agent used for communication with the reviews server.

get_user_hash()
Returns:

the user hash, or None if none could be generated.

Return type:

str

Get the (salted) hash value used to identify the current user to the reviews service, generating it if necessary. The hash is used so the user can only vote once on each application, and so their own reviews can be identified. It can not easily be traced back to an individual user.

remove_review(review)
Parameters:

review (AppStream.Review) – the review to remove.

Raises:

GLib.Error

Returns:

True on success.

Return type:

bool

Remove a review that the current user has written from the reviews server. The review must have been received from the server via a previous fetch operation, and the server will refuse to remove reviews that were not written by the current user. This call does blocking network I/O.

Added in version 1.1.4.

set_client_id(client_id)
Parameters:

client_id (str or None) – the new client-ID.

Set an ID for the client application which is fetching reviews. The ID is used when generating the user hash, so the same user gets a different identity for each client application they are submitting reviews from.

You should set this value early, before any user hash was generated. Set it to None to restore the default client-ID.

set_locale(locale)
Parameters:

locale (str or None) – the new locale, in POSIX format.

Set the locale used for filtering reviews, so reviews in the given (or a compatible) language are preferred. Set it to None to restore the default of using the current system locale.

set_server_url(url)
Parameters:

url (str or None) – the new reviews server URL.

Set the URL of the ODRS-compatible reviews server to communicate with. Set it to None to restore the default server.

set_user_agent(user_agent)
Parameters:

user_agent (str or None) – the new user agent string.

Set the user agent to use when communicating with the reviews server. Set it to None to restore the default user agent.

set_user_hash(user_hash)
Parameters:

user_hash (str or None) – the new user hash string.

Explicitly set the opaque hash value used to identify the current user to the reviews service. Set it to None to have a suitable hash generated automatically, which is the default behavior.

submit_review(component_id, review)
Parameters:
  • component_id (str) – the ID of the software component the review is for.

  • review (AppStream.Review) – the review to submit.

Raises:

GLib.Error

Returns:

True on success.

Return type:

bool

Submit a new user review for a software component to the reviews server. The review must have a rating, summary and description set. If it has no reviewer name set, a suitable one is chosen automatically based on the name of the current user.

On success, the review is updated with its server-assigned ID and is marked as written by the current user. This call does blocking network I/O.

Added in version 1.1.4.

vote_review(review, vote)
Parameters:
Raises:

GLib.Error

Returns:

True on success.

Return type:

bool

Cast a vote on a review that was previously received from the reviews server, to mark it as helpful or unhelpful, or to report it as abusive. On success, the review is marked as voted on by the current user. This call does blocking network I/O.

Added in version 1.1.4.