import { Payment, ResponseType } from '@jolibox/types'; import { BaseSDK } from './sdk'; export class PaymentSDK extends BaseSDK implements Payment { constructor() { super(); } async purchaseGem(params: { productId: string }) { const canIUseResult = this.canIUseIfThrow('payment.purchaseGem'); if (canIUseResult?.code === 'FAILURE') { return canIUseResult; } return await this.commands.executeCommand('PaymentSDK.purchaseGem', params); } async getGemProducts() { const canIUseResult = this.canIUseIfThrow('payment.getGemProducts'); if (canIUseResult?.code === 'FAILURE') { return canIUseResult; } return await this.commands.executeCommand('PaymentSDK.getGemProducts'); } async getSubscriptionPlans() { const canIUseResult = this.canIUseIfThrow('payment.getSubscriptionPlans'); if (canIUseResult?.code === 'FAILURE') { return canIUseResult; } return await this.commands.executeCommand('PaymentSDK.getSubscriptionPlans'); } async subscribe(params: { productId: string; appStoreProductId?: string }) { const canIUseResult = this.canIUseIfThrow('payment.subscribe'); if (canIUseResult?.code === 'FAILURE') { return canIUseResult; } return await this.commands.executeCommand('PaymentSDK.subscribe', { productId: params.productId, appStoreProductId: params.appStoreProductId }); } async subscribeSpin(params: { productId: string; appStoreProductId?: string }) { const canIUseResult = this.canIUseIfThrow('payment.subscribeSpin'); if (canIUseResult?.code === 'FAILURE') { return canIUseResult; } return await this.commands.executeCommand('PaymentSDK.subscribeSpin', { productId: params.productId, appStoreProductId: params.appStoreProductId }); } async flushSubInfoCache() { const canIUseResult = this.canIUseIfThrow('payment.flushSubInfoCache'); if (canIUseResult?.code === 'FAILURE') { return canIUseResult; } return await this.commands.executeCommand('PaymentSDK.flushSubInfoCache'); } }