Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

app-store-ratings

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

app-store-ratings - npm Package Compare versions

Comparing version 1.0.5 to 2.0.0

6

lib/index.d.ts

@@ -1,2 +0,6 @@

import { IAppStoreRating, IProjectConfig } from "./types";
import { IAppStoreRating, IProjectConfig } from './types';
/**
* An async function that takes in a projectConfig of type IProjectConfig object and returns a promise of an array of IAppStoreRating objects.
* @param {IProjectConfig} [projectConfig] - The project config.
*/
export declare const fetchRatings: (projectConfig: IProjectConfig) => Promise<IAppStoreRating[]>;

30

lib/index.js

@@ -39,11 +39,24 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchRatings = void 0;
var axios_1 = require("axios");
var xml2js_1 = require("xml2js");
/**
* If the string is not defined or the string's length is 0, return true, otherwise return false.
* @param {string} [str] - The string to check.
*/
var isEmptyString = function (str) { return !str || str.length === 0; };
/**
* Constructing the url to fetch the ratings from the App Store based on config.
* @param {IProjectConfig} [config] - The project config.
*/
var constructUrl = function (config) {
if (config.country) {
return "https://itunes.apple.com/" + config.country + "/rss/customerreviews/id=" + config.projectId + "/sortBy=mostRecent/xml";
return "https://itunes.apple.com/".concat(config.country, "/rss/customerreviews/id=").concat(config.projectId, "/sortBy=mostRecent/xml");
}
return "https://itunes.apple.com/rss/customerreviews/id=" + config.projectId + "/sortBy=mostRecent/xml";
return "https://itunes.apple.com/rss/customerreviews/id=".concat(config.projectId, "/sortBy=mostRecent/xml");
};
/**
* A function that takes in an IEntry object and returns an IAppStoreRating object.
* @param {IEntry} [entry] - The entry to map.
*/
var mapEntries = function (entry) { return ({

@@ -63,3 +76,7 @@ author: {

}); };
exports.fetchRatings = function (projectConfig) { return __awaiter(void 0, void 0, void 0, function () {
/**
* An async function that takes in a projectConfig of type IProjectConfig object and returns a promise of an array of IAppStoreRating objects.
* @param {IProjectConfig} [projectConfig] - The project config.
*/
var fetchRatings = function (projectConfig) { return __awaiter(void 0, void 0, void 0, function () {
var ratingsUrl, response, json, err_1;

@@ -70,3 +87,3 @@ return __generator(this, function (_a) {

if (isEmptyString(projectConfig.projectId)) {
throw new Error("projectId must be a non empty string");
throw new Error('projectId must be a non empty string');
}

@@ -80,3 +97,3 @@ ratingsUrl = constructUrl(projectConfig);

_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, xml2js_1.parseStringPromise(response.data)];
return [4 /*yield*/, (0, xml2js_1.parseStringPromise)(response.data)];
case 3:

@@ -90,3 +107,3 @@ json = _a.sent();

err_1 = _a.sent();
throw new Error(err_1);
throw err_1;
case 5: return [2 /*return*/];

@@ -96,1 +113,2 @@ }

}); };
exports.fetchRatings = fetchRatings;
{
"name": "app-store-ratings",
"version": "1.0.5",
"version": "2.0.0",
"description": "Fetches data for app store ratings",

@@ -9,4 +9,3 @@ "main": "lib/index.js",

"build": "rm -rf lib && tsc",
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
"lint": "tslint -p tsconfig.json",
"format": "prettier --write \"src/**/*.ts\"",
"test": "echo \"Error: no test specified\"",

@@ -17,3 +16,5 @@ "prepare": "yarn build",

"version": "yarn format && git add -A src",
"postversion": "git push && git push --tags"
"postversion": "git push && git push --tags",
"lint": "eslint 'src/**/**.ts'",
"lint:fix": "eslint --fix 'src/**/**.ts'"
},

@@ -37,8 +38,12 @@ "repository": {

"devDependencies": {
"@types/axios": "^0.14.0",
"@types/xml2js": "^0.4.5",
"prettier": "^1.19.1",
"tslint": "^5.20.1",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.7.3"
"@types/xml2js": "0.4.11",
"@typescript-eslint/eslint-plugin": "5.31.0",
"@typescript-eslint/parser": "5.31.0",
"eslint": "8.20.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-sort-export-all": "1.2.2",
"eslint-plugin-unused-imports": "2.0.0",
"prettier": "2.7.1",
"typescript": "4.8.4"
},

@@ -49,5 +54,5 @@ "files": [

"dependencies": {
"axios": "^0.19.0",
"xml2js": "^0.4.22"
"axios": "1.1.3",
"xml2js": "0.4.23"
}
}

@@ -5,12 +5,20 @@ # app-store-ratings

# Description
Simple wrapper that let's you fetch ratings for your IOS APP. Written in Typescript.
Simple wrapper that let you fetch ratings for your IOS APP. Written in `Typescript`.
# Why
There is no well documented API that returns JSON objects for the IOS App ratings. There is an endpoint that returns XML or JSON.
The API that returns XML contains more data than the one that returns JSON. Converting from XML to JSON on several
projects got a bit tedious. And voila the package was born.
projects got a bit tedious. And voilà the package was born.
# Installation
Simplest way to install app-store-ratings is to use npm, just ```npm install app-store-ratings``` which will download app-store-ratings and all dependencies.
## npm
```npm install app-store-ratings```
## yarn
```yarn add app-store-ratings```
# Usage

@@ -21,14 +29,34 @@ No extensive tutorials required. Learn by example.

## Classic promise
```typescript
import {fetchRatings} from 'app-store-ratings';
import { fetchRatings } from 'app-store-ratings';
fetchRatings({
projectId: 'XXX', // the IOS App projectId
country: 'YYY' // Optional country if your app is available across many stores
})
.then(ratings => console.log(ratings))
function getRatings() {
fetchRatings({
projectId: 'XXX', // the IOS App projectId
country: 'YYY' // Optional country if your app is available across many stores
})
.then(ratings => console.log(ratings));
}
```
## Async await
```typescript
import { fetchRatings } from 'app-store-ratings';
async function getRatings() {
const ratings = await fetchRatings({
projectId: 'XXX', // the IOS App projectId
country: 'YYY' // Optional country if your app is available across many stores
});
console.log(ratings);
}
```
# Entry type

@@ -35,0 +63,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc