diff --git a/README.md b/README.md index 15373273..5941f145 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ Results: size: 'Varies with device', androidVersion: 'VARY', androidVersionText: 'Varies with device', + androidMaxVersion: 'VARY', developer: 'Google LLC', developerId: '5700313618786177705', developerEmail: 'translate-android-support@google.com', @@ -96,6 +97,9 @@ Results: version: 'Varies with device', recentChanges: 'Improved offline translations with upgraded language downloads', comments: [], + preregister: false, + earlyAccessEnabled: false, + isAvailableInPlayPass: false, editorsChoice: true, features: [ { diff --git a/lib/app.js b/lib/app.js index 6eca8269..36ddb061 100644 --- a/lib/app.js +++ b/lib/app.js @@ -67,6 +67,12 @@ const MAPPINGS = { path: ['ds:5', 1, 2, 57, 0, 0, 0, 0, 1, 0, 0], fun: (val) => val / 1000000 || 0 }, + // If there is a discount, originalPrice if filled. + originalPrice: { + path: ['ds:5', 1, 2, 57, 0, 0, 0, 0, 1, 1, 0], + fun: (price) => price ? price / 1000000 : undefined + }, + discountEndDate: ['ds:5', 1, 2, 57, 0, 0, 0, 0, 14, 1], free: { path: ['ds:5', 1, 2, 57, 0, 0, 0, 0, 1, 0, 0], // considered free only if price is exactly zero @@ -94,6 +100,10 @@ const MAPPINGS = { path: ['ds:5', 1, 2, 140, 1, 1, 0, 0, 1], fun: (version) => version || 'Varies with device' }, + androidMaxVersion: { + path: ['ds:5', 1, 2, 140, 1, 1, 0, 1, 1], + fun: helper.normalizeAndroidVersion + }, developer: ['ds:5', 1, 2, 68, 0], developerId: { path: ['ds:5', 1, 2, 68, 1, 4, 2], @@ -156,6 +166,14 @@ const MAPPINGS = { isArray: true, fun: helper.extractComments }, + preregister: { + path: ['ds:5', 1, 2, 18, 0], + fun: (val) => val === 1 + }, + earlyAccessEnabled: { + path: ['ds:5', 1, 2, 18, 2], + fun: (val) => typeof val === 'string' + }, isAvailableInPlayPass: { path: ['ds:5', 1, 2, 62], fun: (field) => !!field diff --git a/test/lib.app.js b/test/lib.app.js index 0d4e3ff4..f9605d08 100644 --- a/test/lib.app.js +++ b/test/lib.app.js @@ -37,6 +37,7 @@ const validateAppDetails = (app) => { assert.isString(app.contentRating); assert.equal(app.androidVersion, '7.0'); + assert.equal(app.androidMaxVersion, 'VARY'); assert.isBoolean(app.available); assert.equal(app.priceText, 'Free'); @@ -44,7 +45,10 @@ const validateAppDetails = (app) => { assert.isTrue(app.free); assert.isTrue(app.offersIAP); assert.isString(app.IAPRange); - // assert(app.preregister === false); + assert.isFalse(app.preregister); + assert.isFalse(app.earlyAccessEnabled); + assert.isUndefined(app.originalPrice); + assert.isUndefined(app.discountEndDate); assert.equal(app.developer, 'Jam City, Inc.'); assert.equal(app.developerId, '5509190841173705883'); @@ -195,4 +199,12 @@ describe('App method', () => { assert.equal(app.available, false); }); }); + + it('should fetch android version limit set for some old apps', () => { + return gplay.app({ appId: 'air.com.zinkia.playset' }) + .then((app) => { + assert.equal(app.androidVersion, '4.2'); + assert.equal(app.androidMaxVersion, '7.1.1'); + }); + }); });