-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create getGamePassProductInfo() * Add getGamePassProductInfo test * Add GamePassProductInfo and getGamePassProductInfo types * Add cache settings for GamePassProduct * Add GamePassProductInfo to jsdocs typings * Update gamepass product info url * Omit new ugc/collectible properties * Fix category * Make function types alphabetical * Add failure test case for getGamePassProductInfo * Typo moment * Fix test again --------- Co-authored-by: Wolftallemo <[email protected]> Co-authored-by: suufi <[email protected]> Co-authored-by: Josh <[email protected]>
- Loading branch information
1 parent
8314b1a
commit 254e01a
Showing
5 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Includes | ||
const http = require('../util/http.js').func | ||
const cache = require('../cache') | ||
|
||
// Args | ||
exports.required = ['gamepass'] | ||
|
||
// Docs | ||
/** | ||
* ✅ Get the info of an gamepass. | ||
* @category Asset | ||
* @param {number} gamePassId - The id of the asset. | ||
* @returns {Promise<GamePassProductInfo>} | ||
* @example const noblox = require("noblox.js") | ||
* const gamePassInfo = await noblox.getGamePassProductInfo(2919875) | ||
**/ | ||
|
||
// Define | ||
function getGamePassProductInfo (gamepass) { | ||
return new Promise((resolve, reject) => { | ||
const httpOpt = { | ||
url: `//apis.roblox.com/game-passes/v1/game-passes/${gamepass}/product-info`, | ||
options: { | ||
resolveWithFullResponse: true, | ||
method: 'GET' | ||
} | ||
} | ||
|
||
return http(httpOpt) | ||
.then(function (res) { | ||
const data = JSON.parse(res.body) | ||
|
||
if (res.statusCode === 200) { | ||
resolve(data) | ||
} else { | ||
const errors = data.errors.map((e) => e.message) | ||
|
||
reject(new Error(`${res.statusCode} ${errors.join(', ')}`)) | ||
} | ||
}) | ||
.catch(error => reject(error)) | ||
}) | ||
} | ||
|
||
exports.func = function (args) { | ||
const gamepass = args.gamepass | ||
|
||
return cache.wrap('GamePassProduct', gamepass, function () { | ||
return getGamePassProductInfo(gamepass) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters