import BaseAPI from "./BaseAPI"; import Client from "../Client"; import { SubmitDeveloperExchangeOptions as BillingAPISubmitDeveloperExchangeOptions } from "./BillingAPI"; export type GetAssetResaleDataOptions = { assetId: number; } export type GetAssetResaleData = { assetStock: number; sales: number; numberRemaining: number; recentAveragePrice: number; originalPrice: number; priceDataPoints: { value: number; date: string; }[]; volumeDataPoints: { value: number; date: string; }[]; } export type GetAssetResellersOptions = { assetId: number; limit?: 10 | 25 | 50 | 100; cursor?: string; } export type GetAssetResellers = { previousPageCursor: string; nextPageCursor: string; data: { userAssetId: number; seller: { id: number; type: "User" | "Group"; name: string; }; price: number; serialNumber: number; }[]; } export type GetUserResellableAssetCopiesOptions = { userId: number; assetId: number; } export type GetUserResellableAssetCopies = { data: GetAssetResellers["data"]; } export type GetResaleTaxRate = { taxRate: number; minimumFee: number; } export type SetAssetCopiesOptions = { assetId: number; userAssetId: number; price: number; } export type SetAssetCopies = unknown export type GetDeveloperExchangeAbility = { canCashOut: boolean; meetsPremiumRequirement: boolean; hasVerifiedEmail: boolean; isUserBlackListed: boolean; meetsMinimumCashOutBalance: boolean; hasCashedOutThisMonth: boolean; lastImbursementStatusIsValid: boolean; } export type GetDeveloperExchangeHelp = unknown; export type GetDeveloperExchangeInfoOptions = { fromDevExPage: boolean; } export type GetDeveloperExchangeInfo = { hasCurrencyOperationError: boolean; currencyOperationErrorMessage: string; showOnlyExchangeRates: boolean; meetsMembershipRequirements: boolean; emailIsVerified: boolean; isImbursementBlacklistUser: boolean; canProceedToCashout: boolean; showProgressBar: boolean; percentRobux: number; minRobuxToCashOut: number; maxRobuxCanCashOut: number; lastImbursementStatus: string; lastImbursementSubmissionDate: string; conversionPercent: number; } export type SubmitDeveloperExchangeOptions = BillingAPISubmitDeveloperExchangeOptions; export type SubmitDeveloperExchange = { submitted: boolean; cashOutAbility: { canCashOut: boolean; meetsPremiumRequirement: boolean; hasVerifiedEmail: boolean; isUserBlcakListed: boolean; meetsMinimumCashOutBalance: boolean; hasCashedOutThisMonth: boolean; lastImbursementStatusIsValid: boolean; }; errors: unknown; } export type GetGroupCurrencyOptions = { groupId: number; } export type GetGroupCurrency = { robux: number; } export type GetSelfCurrencyOptions = { userId: number; } export type GetSelfCurrency = { robux: number; } export type GetGroupRevenueSummaryInTimeFrameOptions = { groupId: number; timeFrame: "Day" | "Week" | "Month" | "Year"; } export type GetGroupRevenueSummaryInTimeFrame = { recurringRobuxStipend: number; itemSaleRobux: number; purchasedRoblox: number; tradeSystemRobux: number; pendingRobux: number; groupPayoutRobux: number; } export type GetSelfRevenueSummaryInTimeFrameOptions = Omit & { userId: number; } export type GetSelfRevenueSummaryInTimeFrame = GetGroupRevenueSummaryInTimeFrame; export type GetGroupTransactionsOptions = { groupId: number; transactionType: "Sale" | "Purchase" | "AffiliateSale" | "DevEx" | "GroupPayout" | "AdImpressionPayout"; limit?: 10 | 25 | 50 | 100; cursor?: string; } export type GetGroupTransactions = { previousPageCursor: string; nextPageCursor: string; data: { created: string; isPending: boolean; agent: { id: number; type: "User" | "Group"; name: string; }; details: unknown; currency: { amount: number; type: "Robux" | string; }; }[]; } export type GetSelfTransactionsOptions = Omit & { userId: number; } export type GetSelfTransactions = GetGroupTransactions; export default class EconomyAPI extends BaseAPI { constructor (client: Client) { super({ client, baseUrl: "https://economy.roblox.com/" }); } getAssetResaleData (options: GetAssetResaleDataOptions): Promise { return this.request({ requiresAuth: false, request: { path: `v1/assets/${options.assetId}/resale-data` }, json: true }) .then(response => response.body); } getAssetResellers (options: GetAssetResellersOptions): Promise { return this.request({ requiresAuth: false, request: { path: `v1/assets/${options.assetId}/resellers`, qs: options }, json: true }) .then(response => response.body); } getUserResellableAssetCopies (options: GetUserResellableAssetCopiesOptions): Promise { return this.request({ requiresAuth: false, request: { path: `v1/assets/${options.assetId}/users/${options.userId}/resellable-copies` }, json: true }) .then(response => response.body); } getResaleTaxRate (): Promise { return this.request({ requiresAuth: false, request: { path: `v1/resale-tax-rate` }, json: true }) .then(response => response.body); } setAssetCopiesForSale (options: SetAssetCopiesOptions): Promise { return this.request({ requiresAuth: true, request: { path: `v1/assets/${options.assetId}/resellable-copies/${options.userAssetId}`, method: "PATCH", json: { price: options.price } }, json: true }) .then(response => response.body); } getDeveloperExchangeAbility (): Promise { return this.request({ requiresAuth: true, request: { path: `v1/developer-exchange/cashoutAbility` }, json: true }) .then(response => response.body); } getDeveloperExchangeHelp (): Promise { return this.request({ requiresAuth: true, request: { path: `v1/developer-exchange/help` }, json: true }) .then(response => response.body); } getDeveloperExchangeInfo (options: GetDeveloperExchangeInfoOptions): Promise { return this.request({ requiresAuth: true, request: { path: `v1/developer-exchange/info`, qs: options }, json: true }) .then(response => response.body); } submitDeveloperExchange (options: SubmitDeveloperExchangeOptions): Promise { return this.request({ requiresAuth: true, request: { path: `v1/developer-exchange/submit`, method: "POST", json: options }, json: true }) .then(response => response.body); } getGroupCurrency (options: GetGroupCurrencyOptions): Promise { return this.request({ requiresAuth: true, request: { path: `v1/groups/${options.groupId}/currency` }, json: true }) .then(response => response.body); } getSelfCurrency (options: GetSelfCurrencyOptions): Promise { return this.request({ requiresAuth: true, request: { path: `v1/users/${options.userId}/currency` }, json: true }) .then(response => response.body); } getGroupRevenueByTime (options: GetGroupRevenueSummaryInTimeFrameOptions): Promise { return this.request({ requiresAuth: false, request: { path: `v1/groups/${options.groupId}/revenue/summary/${options.timeFrame}` }, json: true }) .then(response => response.body); } getSelfRevenueSummaryByTIme (options: GetSelfRevenueSummaryInTimeFrameOptions): Promise { return this.request({ requiresAuth: false, request: { path: `v1/users/${options.userId}/revenue/summary/${options.timeFrame}` }, json: true }) .then(response => response.body); } getGroupTransactions (options: GetGroupTransactionsOptions): Promise { return this.request({ requiresAuth: false, request: { path: `v1/groups/${options.groupId}/transactions`, qs: options }, json: true }) .then(response => response.body); } getSelfTransactions (options: GetSelfTransactionsOptions): Promise { return this.request({ requiresAuth: true, request: { path: `v1/users/${options.userId}/transactions`, qs: options }, json: true }) .then(response => response.body); } }