From a5dcf5b5994927caa3bcb1d50d8ae0c9b66c8d1d Mon Sep 17 00:00:00 2001 From: Menushka Weeratunga Date: Fri, 23 Mar 2018 10:59:29 -0400 Subject: [PATCH] Move into single class and namspace to avoid name conflicts --- types/fbinstant/index.d.ts | 390 +++++++++++++++++++------------------ 1 file changed, 196 insertions(+), 194 deletions(-) diff --git a/types/fbinstant/index.d.ts b/types/fbinstant/index.d.ts index c2237c749c..9b337bbc5e 100644 --- a/types/fbinstant/index.d.ts +++ b/types/fbinstant/index.d.ts @@ -4,9 +4,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare class FBInstant { - player: Player; - context: Context; - payments: Payments; + player: FBInstant.Player; + context: FBInstant.Context; + payments: FBInstant.Payments; getLocale(): string; getPlatform(): string; @@ -18,204 +18,206 @@ declare class FBInstant { getEntryPointAsync(): Promise; setSessionData(sessionData: any): void; startGameAsync(): Promise; - shareAsync(payload: SharePayload): Promise; - updateAsync(payload: UpdatePayload): Promise; + shareAsync(payload: FBInstant.SharePayload): Promise; + updateAsync(payload: FBInstant.UpdatePayload): Promise; switchGameAsync(appID: string, data: string): Promise; canCreateShortcutAsync(): Promise; createShortcutAsync(): Promise; quit(): void; - logEvent(eventName: string, valueToSum?: number, parameter?: any): APIError; + logEvent(eventName: string, valueToSum?: number, parameter?: any): FBInstant.APIError; onPause(func: () => void): void; - getInterstitialAdAsync(placementID: string): Promise; - getRewardedVideoAsync(placementID: string): Promise; + getInterstitialAdAsync(placementID: string): Promise; + getRewardedVideoAsync(placementID: string): Promise; matchPlayerAsync(matchTag: string, switchContextWhenMatched?: boolean): Promise; checkCanPlayerMatchAsync(): Promise; - getLeaderboardAsync(name: string): Promise; + getLeaderboardAsync(name: string): Promise; } -declare class Player { - getID(): string; - getSignedPlayerInfoAsync(requestPayload: string): Promise; - canSubscribeBotAsync(): Promise; - subscribeBotAsync(): Promise; - getName(): string; - getPhoto(): string; - getDataAsync(keys: string[]): Promise; - setDataAsync(data: DataObject): Promise; - flushDataAsync(): Promise; - getStatsAsync(keys: string[]): Promise; - setStatsAsync(stats: StatsObject): Promise; - incrementStatsAsync(increments: IncrementObject): Promise; - getConnectedPlayersAsync(): Promise; +declare namespace FBInstant { + class Player { + getID(): string; + getSignedPlayerInfoAsync(requestPayload: string): Promise; + canSubscribeBotAsync(): Promise; + subscribeBotAsync(): Promise; + getName(): string; + getPhoto(): string; + getDataAsync(keys: string[]): Promise; + setDataAsync(data: DataObject): Promise; + flushDataAsync(): Promise; + getStatsAsync(keys: string[]): Promise; + setStatsAsync(stats: StatsObject): Promise; + incrementStatsAsync(increments: IncrementObject): Promise; + getConnectedPlayersAsync(): Promise; + } + + class Context { + getID(): string; + getType(): Type; + isSizeBetween(minSize: number, maxSize: number): ContextSizeResponse; + switchAsync(id: string): Promise; + chooseAsync(options: ContextOptions): Promise; + createAsync(playerID: string): Promise; + getPlayersAsync(): Promise; + } + + class Leaderboard { + getName(): string; + getContextID(): string; + getEntryCountAsync(): Promise; + setScoreAsync(score: number, extraData: string): Promise; + getPlayerEntryAsync(): Promise; + getEntriesAsync(count: number, offset: number): Promise; + } + + class LeaderboardEntry { + getScore(): number; + getFormattedScore(): string; + getTimestamp(): number; + getRank(): number; + getExtraData(): string; + getPlayer(): LeaderboardPlayer; + } + + class LeaderboardPlayer { + getName(): string; + getPhoto(): string; + getID(): string; + } + + class ConnectedPlayer { + getID(): string; + getName(): string; + getPhoto(): string; + } + + class SignedPlayerInfo { + getPlayerID(): string; + getSignature(): string; + } + + class ContextPlayer { + getID(): string; + getName(): string; + getPhoto(): string; + } + + class AdInstance { + getPlacementID(): string; + loadAsync(): Promise; + showAsync(): Promise; + } + + class Payments { + purchaseAsync(purchaseConfig: PurchaseConfig): Promise; + getPurchasesAsync(): Promise; + consumePurchaseAsync(purchaseToken: string): Promise; + onReady(callback: () => void): void; + } + + interface Product { + title: string; + productID: string; + description?: string; + imageURI?: string; + price: string; + priceCurrencyCode: string; + } + + interface ContextSizeResponse { + answer: boolean; + minSize?: number; + maxSize?: number; + } + + interface Purchase { + developerPayload?: string; + paymentID: string; + productID: string; + purchaseTime: string; + purchaseToken: string; + signedRequest: SignedPurchaseRequest; + } + + interface ContextOptions { + filters?: ContextFilter[]; + maxSize?: number; + minSize?: number; + } + + interface SharePayload { + intent?: Intent; + image?: string; + text?: string; + data?: any; + } + + interface APIError { + code: ErrorCodeType; + message: string; + } + + interface PurchaseConfig { + productID: string; + developerPayload?: string; + } + + interface UpdatePayload { + action?: UpdateAction; + template?: string; + cta?: (string | LocalizableContent); + image?: string; + text?: (string | LocalizableContent); + data?: any; + strategy?: string; + notification?: string; + } + + interface LeaderboardUpdatePayload { + action: UpdateAction; + name: string; + text?: string; + } + + interface LocalizableContent { + default: string; + localizations: LocalizationsDict; + } + + interface DataObject { [ key: string ]: string | number; } + + interface StatsObject { [ key: string ]: string | number; } + + interface IncrementObject { [ key: string ]: number; } + + type LocalizationsDict = any; + + type SignedPurchaseRequest = string; + + type ContextFilter = "NEW_CONTEXT_ONLY" | "INCLUDE_EXISTING_CHALLENGES" | "NEW_PLAYERS_ONLY"; + + type UpdateAction = "CUSTOM" | "LEADERBOARD"; + + type Platform = "IOS" | "ANDROID" | "WEB" | "MOBILE_WEB"; + + type Type = "POST" | "THREAD" | "GROUP" | "SOLO"; + + type Intent = "INVITE" | "REQUEST" | "CHALLENGE" | "SHARE"; + + type ErrorCodeType = "ADS_FREQUENT_LOAD" | + "ADS_NO_FILL" | + "ADS_NOT_LOADED" | + "ADS_TOO_MANY_INSTANCES" | + "ANALYTICS_POST_EXCEPTION" | + "CLIENT_REQUIRES_UPDATE" | + "CLIENT_UNSUPPORTED_OPERATION" | + "INVALID_OPERATION" | + "INVALID_PARAM" | + "LEADERBOARD_NOT_FOUND" | + "LEADERBOARD_WRONG_CONTEXT" | + "NETWORK_FAILURE" | + "PENDING_REQUEST" | + "RATE_LIMITED" | + "SAME_CONTEXT" | + "UNKNOWN" | + "USER_INPUT"; } - -declare class Context { - getID(): string; - getType(): Type; - isSizeBetween(minSize: number, maxSize: number): ContextSizeResponse; - switchAsync(id: string): Promise; - chooseAsync(options: ContextOptions): Promise; - createAsync(playerID: string): Promise; - getPlayersAsync(): Promise; -} - -declare class Leaderboard { - getName(): string; - getContextID(): string; - getEntryCountAsync(): Promise; - setScoreAsync(score: number, extraData: string): Promise; - getPlayerEntryAsync(): Promise; - getEntriesAsync(count: number, offset: number): Promise; -} - -declare class LeaderboardEntry { - getScore(): number; - getFormattedScore(): string; - getTimestamp(): number; - getRank(): number; - getExtraData(): string; - getPlayer(): LeaderboardPlayer; -} - -declare class LeaderboardPlayer { - getName(): string; - getPhoto(): string; - getID(): string; -} - -declare class ConnectedPlayer { - getID(): string; - getName(): string; - getPhoto(): string; -} - -declare class SignedPlayerInfo { - getPlayerID(): string; - getSignature(): string; -} - -declare class ContextPlayer { - getID(): string; - getName(): string; - getPhoto(): string; -} - -declare class AdInstance { - getPlacementID(): string; - loadAsync(): Promise; - showAsync(): Promise; -} - -declare class Payments { - purchaseAsync(purchaseConfig: PurchaseConfig): Promise; - getPurchasesAsync(): Promise; - consumePurchaseAsync(purchaseToken: string): Promise; - onReady(callback: () => void): void; -} - -declare interface Product { - title: string; - productID: string; - description?: string; - imageURI?: string; - price: string; - priceCurrencyCode: string; -} - -declare interface ContextSizeResponse { - answer: boolean; - minSize?: number; - maxSize?: number; -} - -declare interface Purchase { - developerPayload?: string; - paymentID: string; - productID: string; - purchaseTime: string; - purchaseToken: string; - signedRequest: SignedPurchaseRequest; -} - -declare interface ContextOptions { - filters?: ContextFilter[]; - maxSize?: number; - minSize?: number; -} - -declare interface SharePayload { - intent?: Intent; - image?: string; - text?: string; - data?: any; -} - -declare interface APIError { - code: ErrorCodeType; - message: string; -} - -declare interface PurchaseConfig { - productID: string; - developerPayload?: string; -} - -declare interface UpdatePayload { - action?: UpdateAction; - template?: string; - cta?: (string | LocalizableContent); - image?: string; - text?: (string | LocalizableContent); - data?: any; - strategy?: string; - notification?: string; -} - -declare interface LeaderboardUpdatePayload { - action: UpdateAction; - name: string; - text?: string; -} - -declare interface LocalizableContent { - default: string; - localizations: LocalizationsDict; -} - -declare interface DataObject { [ key: string ]: string | number; } - -declare interface StatsObject { [ key: string ]: string | number; } - -declare interface IncrementObject { [ key: string ]: number; } - -declare type LocalizationsDict = any; - -declare type SignedPurchaseRequest = string; - -declare type ContextFilter = "NEW_CONTEXT_ONLY" | "INCLUDE_EXISTING_CHALLENGES" | "NEW_PLAYERS_ONLY"; - -declare type UpdateAction = "CUSTOM" | "LEADERBOARD"; - -declare type Platform = "IOS" | "ANDROID" | "WEB" | "MOBILE_WEB"; - -declare type Type = "POST" | "THREAD" | "GROUP" | "SOLO"; - -declare type Intent = "INVITE" | "REQUEST" | "CHALLENGE" | "SHARE"; - -declare type ErrorCodeType = "ADS_FREQUENT_LOAD" | - "ADS_NO_FILL" | - "ADS_NOT_LOADED" | - "ADS_TOO_MANY_INSTANCES" | - "ANALYTICS_POST_EXCEPTION" | - "CLIENT_REQUIRES_UPDATE" | - "CLIENT_UNSUPPORTED_OPERATION" | - "INVALID_OPERATION" | - "INVALID_PARAM" | - "LEADERBOARD_NOT_FOUND" | - "LEADERBOARD_WRONG_CONTEXT" | - "NETWORK_FAILURE" | - "PENDING_REQUEST" | - "RATE_LIMITED" | - "SAME_CONTEXT" | - "UNKNOWN" | - "USER_INPUT";