Skip to content

Commit d44b9eb

Browse files
authoredAug 1, 2024
Remove checkDeveloperProductName reference from addDeveloperPoduct (redundant and deprecated) (#814)
* (fix): Remove checkDeveloperProductName reference from addDeveloperProduct (redundant and deprecated) * (fix): throw error on non-http 200 responses * (lint): remove trailing comma
1 parent 2bc2f3b commit d44b9eb

File tree

4 files changed

+29
-90
lines changed

4 files changed

+29
-90
lines changed
 

‎lib/games/addDeveloperProduct.js

+20-32
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const http = require('../util/http.js').func
22
const getGeneralToken = require('../util/getGeneralToken.js').func
3-
const checkProductName = require('./checkDeveloperProductName.js').func
43

54
exports.required = ['universeId', 'name', 'priceInRobux']
65
exports.optional = ['description', 'jar']
@@ -21,37 +20,26 @@ exports.optional = ['description', 'jar']
2120
**/
2221

2322
const nextFunction = (jar, token, universeId, name, priceInRobux, description) => {
24-
return checkProductName({
25-
universeId,
26-
productName: name
27-
}).then((res) => {
28-
if (res.Success && res.Message === 'Name available') {
29-
return http({
30-
url: '//apis.roblox.com/developer-products/v1/universes/' + universeId + '/developerproducts?name=' + name + '&description=' + description + '&priceInRobux=' + priceInRobux,
31-
options: {
32-
method: 'POST',
33-
jar,
34-
headers: {
35-
'X-CSRF-TOKEN': token
36-
},
37-
resolveWithFullResponse: true
38-
}
39-
}).then((res) => {
40-
console.log(res)
41-
if (res.statusCode === 200) {
42-
return {
43-
universeId,
44-
name,
45-
priceInRobux,
46-
description,
47-
productId: typeof res.body === 'object' ? res.body.id : JSON.parse(res.body).id
48-
}
49-
} else {
50-
throw new Error('Create product failed, ' + res.statusCode + ' ' + res.statusMessage + '')
51-
}
52-
})
53-
} else {
54-
throw new Error('Product with this name already exists')
23+
description = description || ''
24+
return http({
25+
url: '//apis.roblox.com/developer-products/v1/universes/' + universeId + '/developerproducts?name=' + name + '&description=' + description + '&priceInRobux=' + priceInRobux,
26+
options: {
27+
method: 'POST',
28+
jar,
29+
headers: {
30+
'X-CSRF-TOKEN': token
31+
},
32+
resolveWithFullResponse: true
33+
}
34+
}).then(function (res) {
35+
try {
36+
const json = JSON.parse(res.body)
37+
if (res.statusCode === 200) {
38+
return json
39+
}
40+
throw new Error(json)
41+
} catch (err) {
42+
throw new Error(res.body)
5543
}
5644
})
5745
}

‎lib/games/checkDeveloperProductName.js

-39
This file was deleted.

‎lib/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ noblox.removeFriend = require('./friends/removeFriend.js')
8585
noblox.sendFriendRequest = require('./friends/sendFriendRequest.js')
8686
noblox.unfollow = require('./friends/unfollow.js')
8787
noblox.addDeveloperProduct = require('./games/addDeveloperProduct.js')
88-
noblox.checkDeveloperProductName = require('./games/checkDeveloperProductName.js')
8988
noblox.configureGamePass = require('./games/configureGamePass.js')
9089
noblox.getDeveloperProducts = require('./games/getDeveloperProducts.js')
9190
noblox.getGameInstances = require('./games/getGameInstances.js')

‎typings/index.d.ts

+9-18
Original file line numberDiff line numberDiff line change
@@ -624,20 +624,18 @@ declare module "noblox.js" {
624624
}
625625

626626
interface DeveloperProductAddResult {
627-
universeId: number,
627+
id: number,
628628
name: string,
629-
priceInRobux: number,
630-
description?: string,
631-
productId: string
629+
Description: string, // API does not return camelCase
630+
shopId: number,
631+
iconImageAssetId: number | null
632632
}
633633

634-
interface CheckDeveloperProductNameResult {
635-
Success: boolean;
636-
/**
637-
* When success is true: "Name available"
638-
* When success is false, you can get: "Product name already exists"
639-
*/
640-
Message: string;
634+
interface DeveloperProductAddError {
635+
errorCode: string,
636+
errorMessage: string,
637+
field: string,
638+
hint: string | null
641639
}
642640

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

1835-
/**
1836-
* 🔐 Checks to see if the provided `produceName` is able to be used on `productId`.
1837-
*
1838-
* NOTE: You actually need a valid `productId` and `universeId` otherwise, the http request returns a `404 Not Found` response.
1839-
*/
1840-
function checkDeveloperProductName(universeId: number, productName: string, jar?: CookieJar, productId?: number): Promise<CheckDeveloperProductNameResult>;
1841-
18421833
/**
18431834
* 🔐 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.
18441835
* Returns a `GamePassResponse` with the changed attributes.

0 commit comments

Comments
 (0)