Skip to content

Commit

Permalink
Add preregister, earlyAccessEnabled, androidMaxVersion, originalPrice…
Browse files Browse the repository at this point in the history
… and discountEndDate properties (#648)
  • Loading branch information
jbigman authored Aug 4, 2023
1 parent 1405a43 commit 0761984
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Results:
size: 'Varies with device',
androidVersion: 'VARY',
androidVersionText: 'Varies with device',
androidMaxVersion: 'VARY',
developer: 'Google LLC',
developerId: '5700313618786177705',
developerEmail: '[email protected]',
Expand Down Expand Up @@ -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: [
{
Expand Down
18 changes: 18 additions & 0 deletions lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion test/lib.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@ 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');
assert.equal(app.price, 0);
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');
Expand Down Expand Up @@ -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');
});
});
});

0 comments on commit 0761984

Please sign in to comment.