Skip to content

Commit

Permalink
Remove checkDeveloperProductName reference from addDeveloperPoduct (r…
Browse files Browse the repository at this point in the history
…edundant and deprecated) (#814)

* (fix): Remove checkDeveloperProductName reference from addDeveloperProduct (redundant and deprecated)

* (fix): throw error on non-http 200 responses

* (lint): remove trailing comma
  • Loading branch information
alanbixby authored Aug 1, 2024
1 parent 2bc2f3b commit d44b9eb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 90 deletions.
52 changes: 20 additions & 32 deletions lib/games/addDeveloperProduct.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const http = require('../util/http.js').func
const getGeneralToken = require('../util/getGeneralToken.js').func
const checkProductName = require('./checkDeveloperProductName.js').func

exports.required = ['universeId', 'name', 'priceInRobux']
exports.optional = ['description', 'jar']
Expand All @@ -21,37 +20,26 @@ exports.optional = ['description', 'jar']
**/

const nextFunction = (jar, token, universeId, name, priceInRobux, description) => {
return checkProductName({
universeId,
productName: name
}).then((res) => {
if (res.Success && res.Message === 'Name available') {
return http({
url: '//apis.roblox.com/developer-products/v1/universes/' + universeId + '/developerproducts?name=' + name + '&description=' + description + '&priceInRobux=' + priceInRobux,
options: {
method: 'POST',
jar,
headers: {
'X-CSRF-TOKEN': token
},
resolveWithFullResponse: true
}
}).then((res) => {
console.log(res)
if (res.statusCode === 200) {
return {
universeId,
name,
priceInRobux,
description,
productId: typeof res.body === 'object' ? res.body.id : JSON.parse(res.body).id
}
} else {
throw new Error('Create product failed, ' + res.statusCode + ' ' + res.statusMessage + '')
}
})
} else {
throw new Error('Product with this name already exists')
description = description || ''
return http({
url: '//apis.roblox.com/developer-products/v1/universes/' + universeId + '/developerproducts?name=' + name + '&description=' + description + '&priceInRobux=' + priceInRobux,
options: {
method: 'POST',
jar,
headers: {
'X-CSRF-TOKEN': token
},
resolveWithFullResponse: true
}
}).then(function (res) {
try {
const json = JSON.parse(res.body)
if (res.statusCode === 200) {
return json
}
throw new Error(json)
} catch (err) {
throw new Error(res.body)
}
})
}
Expand Down
39 changes: 0 additions & 39 deletions lib/games/checkDeveloperProductName.js

This file was deleted.

1 change: 0 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ noblox.removeFriend = require('./friends/removeFriend.js')
noblox.sendFriendRequest = require('./friends/sendFriendRequest.js')
noblox.unfollow = require('./friends/unfollow.js')
noblox.addDeveloperProduct = require('./games/addDeveloperProduct.js')
noblox.checkDeveloperProductName = require('./games/checkDeveloperProductName.js')
noblox.configureGamePass = require('./games/configureGamePass.js')
noblox.getDeveloperProducts = require('./games/getDeveloperProducts.js')
noblox.getGameInstances = require('./games/getGameInstances.js')
Expand Down
27 changes: 9 additions & 18 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,20 +624,18 @@ declare module "noblox.js" {
}

interface DeveloperProductAddResult {
universeId: number,
id: number,
name: string,
priceInRobux: number,
description?: string,
productId: string
Description: string, // API does not return camelCase
shopId: number,
iconImageAssetId: number | null
}

interface CheckDeveloperProductNameResult {
Success: boolean;
/**
* When success is true: "Name available"
* When success is false, you can get: "Product name already exists"
*/
Message: string;
interface DeveloperProductAddError {
errorCode: string,
errorMessage: string,
field: string,
hint: string | null
}

interface GamePassData {
Expand Down Expand Up @@ -1832,13 +1830,6 @@ declare module "noblox.js" {
*/
function addDeveloperProduct(universeId: number, name: string, priceInRobux: number, description?: string, jar?: CookieJar): Promise<DeveloperProductAddResult>;

/**
* 🔐 Checks to see if the provided `produceName` is able to be used on `productId`.
*
* NOTE: You actually need a valid `productId` and `universeId` otherwise, the http request returns a `404 Not Found` response.
*/
function checkDeveloperProductName(universeId: number, productName: string, jar?: CookieJar, productId?: number): Promise<CheckDeveloperProductNameResult>;

/**
* 🔐 Configures a game pass with the id `gamePassId` to have a `name`, `description`, `price` in Robux, and `icon` image. If `name` is an empty string, only `price` is changed. Setting `price` to false, 0, or a negative value will place the game pass off-sale.
* Returns a `GamePassResponse` with the changed attributes.
Expand Down

0 comments on commit d44b9eb

Please sign in to comment.