Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/coders/adapty-onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class AdaptyOnboardingCoder extends Coder<
version: { key: 'response_created_at', required: false, type: 'number' },
onboardingBuilder: {
key: 'onboarding_builder',
required: false,
required: true,
type: 'object',
converter: new AdaptyOnboardingBuilderCoder(),
},
Expand Down
59 changes: 57 additions & 2 deletions src/types/error.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// import SDK type to link to methods in docs.
// import { AdaptyError } from '../sdk2/error';

export const ErrorCode = Object.freeze({
const ErrorCodeMapping = Object.freeze({
/**
* System StoreKit codes
*/
Expand Down Expand Up @@ -124,7 +124,62 @@ export const ErrorCode = Object.freeze({
3101: 'fetchTimeoutError',
9000: 'operationInterrupted',
});
export type ErrorCode = keyof typeof ErrorCode;

export const ErrorCode = ErrorCodeMapping;
export type ErrorCode = keyof typeof ErrorCodeMapping;

export const ErrorCodeName = Object.freeze({
unknown: 0,
clientInvalid: 1,
paymentInvalid: 3,
paymentNotAllowed: 4,
storeProductNotAvailable: 5,
cloudServicePermissionDenied: 6,
cloudServiceNetworkConnectionFailed: 7,
cloudServiceRevoked: 8,
privacyAcknowledgementRequired: 9,
unauthorizedRequestData: 10,
invalidOfferIdentifier: 11,
invalidSignature: 12,
missingOfferParams: 13,
invalidOfferPrice: 14,
adaptyNotInitialized: 20,
productNotFound: 22,
currentSubscriptionToUpdateNotFoundInHistory: 24,
billingServiceTimeout: 97,
featureNotSupported: 98,
billingServiceDisconnected: 99,
billingServiceUnavailable: 102,
billingUnavailable: 103,
developerError: 105,
billingError: 106,
itemAlreadyOwned: 107,
itemNotOwned: 108,
billingNetworkError: 112,
noProductIDsFound: 1000,
productRequestFailed: 1002,
cantMakePayments: 1003,
noPurchasesToRestore: 1004,
cantReadReceipt: 1005,
productPurchaseFailed: 1006,
refreshReceiptFailed: 1010,
receiveRestoredTransactionsFailed: 1011,
notActivated: 2002,
badRequest: 2003,
serverError: 2004,
networkFailed: 2005,
decodingFailed: 2006,
encodingFailed: 2009,
analyticsDisabled: 3000,
wrongParam: 3001,
activateOnceError: 3005,
profileWasChanged: 3006,
unsupportedData: 3007,
persistingDataError: 3100,
fetchTimeoutError: 3101,
operationInterrupted: 9000,
} as const);
export type ErrorCodeName = keyof typeof ErrorCodeName;

export function getErrorCode(
error: (typeof ErrorCode)[ErrorCode],
Expand Down
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export interface AdaptyOnboarding {
version?: number;
payloadData?: string;
requestLocale: string;
onboardingBuilder?: AdaptyOnboardingBuilder;
onboardingBuilder: AdaptyOnboardingBuilder;
}

export interface AdaptyPlacement {
Expand Down