-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create getPlaceInfo.js * Update index.d.ts * Update jsDocs.ts * Update index.d.ts * Update getPlaceInfo.js * Update getPlaceInfo.js * Update index.d.ts * Update games.test.js * Update getPlaceInfo.js Fix Identation/Spacing * Update getPlaceInfo.js
- Loading branch information
1 parent
7bba8f8
commit 251913f
Showing
4 changed files
with
115 additions
and
0 deletions.
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,48 @@ | ||
// Includes | ||
const http = require('../util/http.js').func | ||
|
||
// Args | ||
exports.required = ['placeId'] | ||
exports.optional = ['jar'] | ||
|
||
// Docs | ||
/** | ||
* 🔓 Get the info for a universe. | ||
* @category Game | ||
* @alias getPlaceInfo | ||
* @param {number | Array<number>} universeId - The id(s) of the place(s). | ||
* @returns {Promise<PlaceInformation[]>} | ||
* @example const noblox = require("noblox.js") | ||
* const universeInfo = await noblox.getPlaceInfo([ 10905034443 ]) | ||
**/ | ||
|
||
function getPlaceInfo (placeIds, jar) { | ||
return new Promise((resolve, reject) => { | ||
if (typeof (placeIds) === 'number') placeIds = [placeIds] | ||
|
||
const httpOpt = { | ||
url: `//games.roblox.com/v1/games/multiget-place-details?placeIds=${placeIds.join(',')}`, | ||
options: { | ||
json: true, | ||
resolveWithFullResponse: true, | ||
jar: jar, | ||
method: 'GET' | ||
} | ||
} | ||
|
||
return http(httpOpt) | ||
.then(function ({ statusCode, body }) { | ||
if (statusCode === 200) { | ||
resolve(body) | ||
} else if (body && body.errors) { | ||
reject(new Error(`[${statusCode}] ${body.errors[0].message} | placeIds: ${placeIds.join(',')} ${body.errors.field ? ` | ${body.errors.field} is incorrect` : ''}`)) | ||
} else { | ||
reject(new Error(`An unknown error occurred with getPlaceInfo() | [${statusCode}] placeIds: ${placeIds.join(',')}`)) | ||
} | ||
}).catch(reject) | ||
}) | ||
} | ||
|
||
exports.func = function (args) { | ||
return getPlaceInfo(args.placeId, args.jar) | ||
} |
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