import BaseAPI from "./BaseAPI"; import Client from "../Client"; import { UpdateUserPromotionChannelsOptions as AccountInformationUpdateUserPromotionChannelsOptions } from "./AccountInformationAPI"; export type GetSettingsGroups = { title: string; url: string; suffix: string; }[]; export type GetAppChatPrivacy = { appChatPrivacy: string; } export type UpdateAppChatPrivacyOptions = { appChatPrivacy: string; }; export type UpdateAppChatPrivacy = boolean; export type GetGameChatPrivacy = { gameChatPrivacy: string; } export type UpdateGameChatPrivacyOptions = { gameChatPrivacy: string; }; export type UpdateGameChatPrivacy = boolean; export type GetInventoryPrivacy = { inventoryPrivacy: string; } export type UpdateInventoryPrivacyOptions = { inventoryPrivacy: string; }; export type UpdateInventoryPrivacy = { inventoryPrivacy: string; tradePrivacy: string; privacySettingResponse: string; }; export type GetUserPrivacy = { phoneDiscovery: string; } export type UpdateUserPrivacyOptions = { phoneDiscovery: string; }; export type UpdateUserPrivacy = { phoneDiscovery: string; } export type GetUserPrivacySettingsInfo = { isPhoneDiscoveryEnabled: boolean; } export type GetUserPrivateMessagePrivacy = { privateMessagePrivacy: string; } export type UpdateUserPrivateMessagePrivacyOptions = { privateMessagePrivacy: string; }; export type UpdateUserPrivateMessagePrivacy = boolean; export type GetUserEmailStatus = { email: string; verified: boolean; } export type UpdateUserEmailOptions = { password: string; emailAddress: string; }; export type UpdateUserEmail = boolean; export type SendEmailVerification = boolean; export type GetWebsiteTheme = { themeType: string; } export type UpdateWebsiteThemeOptions = { themeType: string; }; export type UpdateWebsiteTheme = boolean; export type GetWebsiteThemes = { data: string[]; }; export type GetUserTradePrivacy = { tradePrivacy: string; }; export type UpdateUserTradePrivacyOptions = { tradePrivacy: string; }; export type UpdateUserTradePrivacy = { tradePrivacy: string; inventoryPrivacy: string; privacySettingResponse: string; }; export type GetUserTradeQualityFilter = { tradeValue: string; } export type UpdateUserTradeQualityFilterOptions = { tradeValue: string; }; export type UpdateUserTradeQualityFilter = boolean; export type UpdateTwoStepStatusOptions = { enabled: boolean; password: string; }; export type UpdateTwoStepStatus = { enabled: boolean; password: string; } export type GetContactUpsell = { upsellScreenType: string; } export type UpdateContactUpsellSuppressionOptions = { suppress: boolean; }; export type UpdateContactUpsellSuppression = boolean; export type GetIsXboxUsernameValidOptions = { authorization: string; signature: string; username: string; }; export type GetIsXboxUsernameValid = { isValid: boolean; errorMessage?: string; errorCode?: string; } export type UpdateUserPromotionChannelsOptions = AccountInformationUpdateUserPromotionChannelsOptions; export type UpdateUserPromotionChannels = boolean; export default class AccountSettingsAPI extends BaseAPI { constructor (client: Client) { super({ baseUrl: "https://accountsettings.roblox.com/", client }); } getSettingsGroups (): Promise { return this.request({ requiresAuth: false, request: { path: "v1/account/settings/settings-groups" }, json: true }) .then(response => response.body.map((val: any) => ({ title: val.Title, url: val.Url, suffix: val.Suffix }))); } getAppChatPrivacy (): Promise { return this.request({ requiresAuth: true, request: { path: "v1/app-chat-privacy" }, json: true }) .then(response => response.body); } updateAppChatPrivacy (options: UpdateAppChatPrivacyOptions): Promise { return this.request({ requiresAuth: true, request: { path: "v1/app-chat-privacy", method: "POST", json: options }, json: true }) .then(response => response.body); } getGameChatPrivacy (): Promise { return this.request({ requiresAuth: true, request: { path: "v1/game-chat-privacy" }, json: true }) .then(response => response.body); } updateGameChatPrivacy (options: UpdateGameChatPrivacyOptions): Promise { return this.request({ requiresAuth: true, request: { path: "v1/game-chat-privacy", method: "POST", json: options }, json: true }) .then(response => response.body); } getInventoryPrivacy (): Promise { return this.request({ requiresAuth: true, request: { path: "v1/inventory-privacy" }, json: true }) .then(response => response.body); } updateInventoryPrivacy (options: UpdateInventoryPrivacyOptions): Promise { return this.request({ requiresAuth: true, request: { path: "v1/inventory-privacy", method: "POST", json: options }, json: true }) .then(response => response.body); } getUserPrivacy (): Promise { return this.request({ requiresAuth: true, request: { path: "v1/privacy" }, json: true }) .then(response => response.body); } updateUserPrivacy (options: UpdateUserPrivacyOptions): Promise { return this.request({ requiresAuth: true, request: { path: "v1/privacy", method: "PATCH", json: options }, json: true }) .then(response => response.body); } getUserPrivacySettingsInfo (): Promise { return this.request({ requiresAuth: true, request: { path: "v1/privacy/info" }, json: true }) .then(response => response.body as GetUserPrivacySettingsInfo); } getUserPrivateMessagePrivacy (): Promise { return this.request({ requiresAuth: true, request: { path: "v1/private-message-privacy" }, json: true }) .then(response => response.body as GetUserPrivateMessagePrivacy); } updateUserPrivateMessagePrivacy (options: UpdateUserPrivateMessagePrivacyOptions): Promise { return this.request({ requiresAuth: true, request: { path: "v1/private-message-privacy", method: "POST", json: options }, json: true }) .then(() => true as UpdateUserPrivateMessagePrivacy); } getUserEmailStatus (): Promise { return this.request({ requiresAuth: true, request: { path: "v1/email" }, json: true }) .then(response => response.body as GetUserEmailStatus); } updateUserEmail (options: UpdateUserEmailOptions): Promise { return this.request({ requiresAuth: true, request: { path: "v1/email", method: "PATCH", json: options }, json: true }) .then(() => true); } sendEmailVerification (): Promise { return this.request({ requiresAuth: true, request: { path: "v1/email/verify", method: "POST" }, json: true }) .then(() => true); } getWebsiteTheme (): Promise { return this.request({ requiresAuth: true, request: { path: `v1/themes/User/${this.client.user!.id}` }, json: true }) .then(response => response.body as GetWebsiteTheme); } updateWebsiteTheme (options: UpdateWebsiteThemeOptions): Promise { return this.request({ requiresAuth: true, request: { path: `v1/themes/User/${this.client.user!.id}`, method: "PATCH", json: { themeType: options.themeType } }, json: true }) .then(() => true); } getWebsiteThemes (): Promise { return this.request({ requiresAuth: true, request: { path: "v1/themes/types" }, json: true }) .then(response => response.body as GetWebsiteThemes); } getUserTradePrivacy (): Promise { return this.request({ requiresAuth: true, request: { path: "v1/trade-privacy" }, json: true }) .then(response => response.body as GetUserTradePrivacy); } updateUserTradePrivacy (options: UpdateUserTradePrivacyOptions): Promise { return this.request({ requiresAuth: true, request: { path: "v1/trade-privacy", method: "POST", json: options }, json: true }) .then(response => response.body as UpdateUserTradePrivacy); } getUserTradeQualityFilter (): Promise { return this.request({ requiresAuth: true, request: { path: "v1/trade-value" }, json: true }) .then(response => response.body as GetUserTradeQualityFilter); } updateUserTradeQualityFilter (options: UpdateUserTradeQualityFilterOptions): Promise { return this.request({ requiresAuth: true, request: { path: "v1/trade-value", method: "POST", json: options }, json: true }) .then(() => true); } updateTwoStepStatus (options: UpdateTwoStepStatusOptions): Promise { return this.request({ requiresAuth: true, request: { path: "v1/email", method: "PATCH", json: options }, json: true }) .then(response => response.body as UpdateTwoStepStatus); } getContactUpsell (): Promise { return this.request({ requiresAuth: true, request: { path: "v1/user/screens/contact-upsell" }, json: true }) .then(response => response.body as GetContactUpsell); } updateContactUpsellSuppression (options: UpdateContactUpsellSuppressionOptions): Promise { return this.request({ requiresAuth: true, request: { method: "POST", path: "v1/user/screens/contact-upsell/suppress", json: options }, json: true }) .then(() => true as UpdateContactUpsellSuppression); } getIsXboxUsernameValid (options: GetIsXboxUsernameValidOptions): Promise { return this.request({ requiresAuth: true, request: { path: "v1/xbox/is-username-valid", qs: { Authorization: options.authorization, signature: options.signature, "request.username": options.username } }, json: true }) .then(response => response.body as GetIsXboxUsernameValid); } updateUserPromotionChannels (options: UpdateUserPromotionChannelsOptions): Promise { return this.request({ requiresAuth: true, request: { path: "v1/promotion-channels", method: "POST", json: options }, json: true }) .then(() => true); } }