feat(dongle): implement prime_type in devices endpoint

pull/4/head
Cameron Clough 2022-03-24 15:06:25 +00:00
parent 21daab109f
commit f9b98cc120
No known key found for this signature in database
GPG Key ID: BFB3B74B026ED43F
1 changed files with 16 additions and 2 deletions

View File

@ -90,9 +90,23 @@ router.get('/v1.1/devices/:dongleId/', runAsyncWrapper(async (req, res) => {
return res.status(401).send('Unauthorized.');
}
const PrimeType = {
None: 0,
Magenta: 1,
Lite: 2,
};
const isPaired = accountId !== 0;
const response = {
is_paired: (accountId !== 0),
prime: (accountId > 0),
is_paired: isPaired,
/*
* Whether the account is subscribed to prime. Removed in OP 0.8.13. Replaced by `prime_type`.
*/
prime: isPaired,
/*
* The type of prime subscription the account is subscribed to.
*/
prime_type: isPaired ? PrimeType.Lite : PrimeType.None,
};
logger.info(`HTTP.DEVICES for ${dongleId} returning: ${JSON.stringify(response)}`);