app-store-ratings
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -1,2 +0,2 @@ | ||
import { IEntry, IFetchRatingsFilter, IProjectConfig } from "./types"; | ||
export declare const fetchRatings: (projectConfig: IProjectConfig, filter?: IFetchRatingsFilter | undefined) => Promise<IEntry[]>; | ||
import { IAppStoreRating, IProjectConfig } from "./types"; | ||
export declare const fetchRatings: (projectConfig: IProjectConfig) => Promise<IAppStoreRating[]>; |
@@ -48,9 +48,17 @@ "use strict"; | ||
}; | ||
var filterEntries = function (entries, filter) { | ||
if (!filter) { | ||
return entries; | ||
} | ||
return entries.filter(function (e) { return e.updated; }); | ||
}; | ||
exports.fetchRatings = function (projectConfig, filter) { return __awaiter(void 0, void 0, void 0, function () { | ||
var mapEntries = function (entry) { return ({ | ||
author: { | ||
name: entry.author[0].name[0], | ||
uri: entry.author[0].uri[0], | ||
}, | ||
content: entry.content[0]._, | ||
id: entry.id[0], | ||
rating: parseInt(entry['im:rating'][0], 10), | ||
title: entry.title[0], | ||
updatedAt: entry.updated[0], | ||
version: entry['im:version'][0], | ||
voteCount: parseInt(entry['im:voteCount'][0], 10), | ||
voteSum: parseInt(entry['im:voteSum'][0], 10), | ||
}); }; | ||
exports.fetchRatings = function (projectConfig) { return __awaiter(void 0, void 0, void 0, function () { | ||
var ratingsUrl, response, json, err_1; | ||
@@ -73,3 +81,6 @@ return __generator(this, function (_a) { | ||
json = _a.sent(); | ||
return [2 /*return*/, filterEntries(json.feed.entry, filter)]; | ||
if (!json.feed || !json.feed.entry) { | ||
return [2 /*return*/, []]; | ||
} | ||
return [2 /*return*/, json.feed.entry.map(mapEntries)]; | ||
case 4: | ||
@@ -76,0 +87,0 @@ err_1 = _a.sent(); |
@@ -1,71 +0,35 @@ | ||
export interface ILink { | ||
_rel: string; | ||
_type: string; | ||
_href: string; | ||
} | ||
export interface IAuthor { | ||
name: string; | ||
uri: string; | ||
} | ||
export interface IContent { | ||
_type: string; | ||
__text: string; | ||
} | ||
export interface IContentType { | ||
_term: string; | ||
_label: string; | ||
__prefix: string; | ||
} | ||
export interface IVoteSum { | ||
__prefix: string; | ||
__text: string; | ||
} | ||
export interface IVoteCount { | ||
__prefix: string; | ||
__text: string; | ||
} | ||
export interface IRating { | ||
__prefix: string; | ||
__text: string; | ||
} | ||
export interface IVersion { | ||
__prefix: string; | ||
__text: string; | ||
} | ||
export interface IAuthor2 { | ||
name: string; | ||
uri: string; | ||
} | ||
export interface ILink2 { | ||
_rel: string; | ||
_href: string; | ||
} | ||
export interface IEntry { | ||
updated: Date; | ||
id: string; | ||
title: string; | ||
content: IContent[]; | ||
contentType: IContentType; | ||
voteSum: IVoteSum; | ||
voteCount: IVoteCount; | ||
rating: IRating; | ||
version: IVersion; | ||
author: IAuthor2; | ||
link: ILink2; | ||
updated: string[]; | ||
id: string[]; | ||
title: string[]; | ||
content: Array<{ | ||
_: string; | ||
}>; | ||
'im:voteCount': string[]; | ||
'im:voteSum': string[]; | ||
'im:rating': string[]; | ||
'im:version': string[]; | ||
author: Array<{ | ||
name: string; | ||
uri: string; | ||
}>; | ||
} | ||
export interface IFeed { | ||
export interface IAppStoreRating { | ||
id: string; | ||
title: string; | ||
updated: Date; | ||
link: ILink[]; | ||
icon: string; | ||
author: IAuthor; | ||
rights: string; | ||
entry: IEntry[]; | ||
"_xmlns:im": string; | ||
_xmlns: string; | ||
"_xml:lang": string; | ||
updatedAt: string; | ||
content: string; | ||
rating: number; | ||
voteCount: number; | ||
voteSum: number; | ||
version: string; | ||
author: { | ||
name: string; | ||
uri: string; | ||
}; | ||
} | ||
export interface IAppStoreFeed { | ||
feed: IFeed; | ||
feed: { | ||
entry: IEntry[]; | ||
}; | ||
} | ||
@@ -76,4 +40,1 @@ export interface IProjectConfig { | ||
} | ||
export interface IFetchRatingsFilter { | ||
fromDate?: Date; | ||
} |
{ | ||
"name": "app-store-ratings", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Fetches data for app store ratings", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
7865
133