AppStream.ReviewsClient¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
parent_instance |
r |
Class Details¶
- class AppStream.ReviewsClient(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
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:
- Return type:
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:
- Returns:
the overall rating percentage, or -1 if no rating was available.
- Return type:
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:
- Returns:
the fetched reviews, or
Noneon error.- Return type:
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:
- Raises:
- Returns:
the fetched reviews, or
Noneon error.- Return type:
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:
Get the ID of the client application which is fetching reviews.
- get_locale()¶
- Returns:
the current locale, in POSIX format.
- Return type:
Get the locale used for filtering reviews.
- get_server_url()¶
- Returns:
the reviews server URL.
- Return type:
Get the URL of the reviews server that we are communicating with.
- get_user_agent()¶
-
Get the user agent used for communication with the reviews server.
- get_user_hash()¶
-
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:
- Returns:
Trueon success.- Return type:
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)¶
-
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
Noneto restore the default client-ID.
- set_locale(locale)¶
-
Set the locale used for filtering reviews, so reviews in the given (or a compatible) language are preferred. Set it to
Noneto restore the default of using the current system locale.
- set_server_url(url)¶
-
Set the URL of the ODRS-compatible reviews server to communicate with. Set it to
Noneto restore the default server.
- set_user_agent(user_agent)¶
-
Set the user agent to use when communicating with the reviews server. Set it to
Noneto restore the default user agent.
- set_user_hash(user_hash)¶
-
Explicitly set the opaque hash value used to identify the current user to the reviews service. Set it to
Noneto 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:
- Returns:
Trueon success.- Return type:
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:
review (
AppStream.Review) – the review to vote on.vote (
AppStream.ReviewVoteKind) – the kind of vote to cast, e.g.AppStream.ReviewVoteKind.UP.
- Raises:
- Returns:
Trueon success.- Return type:
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.