Skip to content

Commit

Permalink
Also fetch rating counts with app details (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
baltpeter authored Jun 25, 2024
1 parent bebf0f5 commit 52cf444
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
23 changes: 15 additions & 8 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ The result of a fetch app details request.

#### Defined in

[endpoints/app-details.ts:58](https://github.com/baltpeter/parse-play/blob/main/src/endpoints/app-details.ts#L58)
[endpoints/app-details.ts:59](https://github.com/baltpeter/parse-play/blob/main/src/endpoints/app-details.ts#L59)

___

Expand All @@ -123,7 +123,7 @@ The metadata for a single app. The available properties depend on which endpoint

#### Defined in

[common/data-format.ts:112](https://github.com/baltpeter/parse-play/blob/main/src/common/data-format.ts#L112)
[common/data-format.ts:127](https://github.com/baltpeter/parse-play/blob/main/src/common/data-format.ts#L127)

___

Expand Down Expand Up @@ -165,6 +165,13 @@ this, see [AppMetadata](README.md#appmetadata).
| `price` | `string` \| `undefined` | The app's price. Can be undefined for pre-release apps. |
| `privacy_policy_url` | `string` \| `undefined` | The URL to the app's privacy policy. |
| `rating` | `number` \| `undefined` | The app's review rating. |
| `rating_counts` | { `1`: `number` ; `2`: `number` ; `3`: `number` ; `4`: `number` ; `5`: `number` ; `total`: `number` } | The number of each rating the app has received. |
| `rating_counts.1` | `number` | The number of 1-star ratings. |
| `rating_counts.2` | `number` | The number of 2-star ratings. |
| `rating_counts.3` | `number` | The number of 3-star ratings. |
| `rating_counts.4` | `number` | The number of 4-star ratings. |
| `rating_counts.5` | `number` | The number of 5-star ratings. |
| `rating_counts.total` | `number` | The total number of ratings. |
| `released_on?` | `Date` | The date when the app was first published. |
| `requires_android?` | {} | The app's required version of Android. |
| `screenshot_urls` | `string`[] | URLs to screenshots of the app. |
Expand Down Expand Up @@ -195,7 +202,7 @@ A property that can be present in the metadata of an app.

#### Defined in

[common/data-format.ts:110](https://github.com/baltpeter/parse-play/blob/main/src/common/data-format.ts#L110)
[common/data-format.ts:125](https://github.com/baltpeter/parse-play/blob/main/src/common/data-format.ts#L125)

___

Expand All @@ -207,7 +214,7 @@ A property present when fetching app details.

#### Defined in

[endpoints/app-details.ts:56](https://github.com/baltpeter/parse-play/blob/main/src/endpoints/app-details.ts#L56)
[endpoints/app-details.ts:57](https://github.com/baltpeter/parse-play/blob/main/src/endpoints/app-details.ts#L57)

___

Expand Down Expand Up @@ -600,7 +607,7 @@ ___

### fetchAppDetailsMetadataProperties

`Const` **fetchAppDetailsMetadataProperties**: readonly [``"app_id"``, ``"name"``, ``"content_rating"``, ``"released_on"``, ``"downloads"``, ``"downloads_exact"``, ``"in_app_purchases"``, ``"offered_by"``, ``"rating"``, ``"price"``, ``"buy_url"``, ``"top_chart_placement"``, ``"developer"``, ``"developer_path"``, ``"developer_website_url"``, ``"developer_email"``, ``"developer_address"``, ``"description"``, ``"permissions"``, ``"screenshot_urls"``, ``"category"``, ``"icon_url"``, ``"cover_image_url"``, ``"privacy_policy_url"``, ``"trailer_url"``, ``"tags"``, ``"data_shared"``, ``"data_collected"``, ``"security_practices"``, ``"version"``, ``"requires_android"``, ``"updated_on"``]
`Const` **fetchAppDetailsMetadataProperties**: readonly [``"app_id"``, ``"name"``, ``"content_rating"``, ``"released_on"``, ``"downloads"``, ``"downloads_exact"``, ``"in_app_purchases"``, ``"offered_by"``, ``"rating"``, ``"rating_counts"``, ``"price"``, ``"buy_url"``, ``"top_chart_placement"``, ``"developer"``, ``"developer_path"``, ``"developer_website_url"``, ``"developer_email"``, ``"developer_address"``, ``"description"``, ``"permissions"``, ``"screenshot_urls"``, ``"category"``, ``"icon_url"``, ``"cover_image_url"``, ``"privacy_policy_url"``, ``"trailer_url"``, ``"tags"``, ``"data_shared"``, ``"data_collected"``, ``"security_practices"``, ``"version"``, ``"requires_android"``, ``"updated_on"``]

The properties present when fetching app details.

Expand Down Expand Up @@ -657,7 +664,7 @@ The app details.

#### Defined in

[endpoints/app-details.ts:243](https://github.com/baltpeter/parse-play/blob/main/src/endpoints/app-details.ts#L243)
[endpoints/app-details.ts:252](https://github.com/baltpeter/parse-play/blob/main/src/endpoints/app-details.ts#L252)

**fetchAppDetails**(`requests`, `options`): `Promise`<[`AppDetailsResult`](README.md#appdetailsresult)[]\>

Expand All @@ -681,7 +688,7 @@ An array of the app details, in the same order as the requests.

#### Defined in

[endpoints/app-details.ts:257](https://github.com/baltpeter/parse-play/blob/main/src/endpoints/app-details.ts#L257)
[endpoints/app-details.ts:266](https://github.com/baltpeter/parse-play/blob/main/src/endpoints/app-details.ts#L266)

___

Expand Down Expand Up @@ -821,7 +828,7 @@ Parse an app entry in a search or top chart response.

#### Defined in

[common/data-format.ts:139](https://github.com/baltpeter/parse-play/blob/main/src/common/data-format.ts#L139)
[common/data-format.ts:154](https://github.com/baltpeter/parse-play/blob/main/src/common/data-format.ts#L154)

___

Expand Down
15 changes: 15 additions & 0 deletions src/common/data-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ export type AppMetadataFull = {
name: string;
/** The app's review rating. */
rating: number | undefined;
/** The number of each rating the app has received. */
rating_counts: {
/** The number of 1-star ratings. */
1: number;
/** The number of 2-star ratings. */
2: number;
/** The number of 3-star ratings. */
3: number;
/** The number of 4-star ratings. */
4: number;
/** The number of 5-star ratings. */
5: number;
/** The total number of ratings. */
total: number;
};
/** The app's main category. */
category: string;
/** The app's price. Can be undefined for pre-release apps. */
Expand Down
9 changes: 9 additions & 0 deletions src/endpoints/app-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const fetchAppDetailsMetadataProperties = [
'in_app_purchases',
'offered_by',
'rating',
'rating_counts',
'price',
'buy_url',
'top_chart_placement',
Expand Down Expand Up @@ -186,6 +187,14 @@ export const parseAppDetailsPayload = (payload: any, options: AppDetailsOptions)
in_app_purchases: data[19]?.[0],
offered_by: data[37][0],
rating: data[51][0][1],
rating_counts: {
1: data[51][1][1][1],
2: data[51][1][2][1],
3: data[51][1][3][1],
4: data[51][1][4][1],
5: data[51][1][5][1],
total: data[51][2][1],
},
price: data[57][0][0][0][0]
? formatCurrency(data[57][0][0][0][0]?.[1][0][0] / 1e6, data[57][0][0][0][0]?.[1][0][1], options)
: undefined,
Expand Down

0 comments on commit 52cf444

Please sign in to comment.