-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/DELIVERY-70584/PurchaseConnectorRN' into develo…
…pment
- Loading branch information
Showing
64 changed files
with
153,559 additions
and
639 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class AppsFlyerConstants { | ||
static readonly RE_CONFIGURE_ERROR_MSG: string = "[PurchaseConnector] Re configure instance is not permitted. Returned the existing instance"; | ||
static readonly MISSING_CONFIGURATION_EXCEPTION_MSG: string = "Could not create an instance without configuration"; | ||
|
||
// Adding method constants | ||
static readonly SUBSCRIPTION_VALIDATION_SUCCESS: string = 'subscriptionValidationSuccess'; | ||
static readonly SUBSCRIPTION_VALIDATION_FAILURE: string = 'subscriptionValidationFailure'; | ||
static readonly IN_APP_PURCHASE_VALIDATION_SUCCESS: string = 'inAppPurchaseValidationSuccess'; | ||
static readonly IN_APP_PURCHASE_VALIDATION_FAILURE: string = 'inAppPurchaseValidationFailure'; | ||
static readonly DID_RECEIVE_PURCHASE_REVENUE_VALIDATION_INFO: string = | ||
"onDidReceivePurchaseRevenueValidationInfo"; | ||
|
||
// Adding key constants | ||
static readonly RESULT: string = "result"; | ||
static readonly ERROR: string = "error"; | ||
static readonly VALIDATION_INFO: string = "validationInfo"; | ||
static readonly CONFIGURE_KEY: string = "configure"; | ||
static readonly LOG_SUBS_KEY: string = "logSubscriptions"; | ||
static readonly LOG_IN_APP_KEY: string = "logInApps"; | ||
static readonly SANDBOX_KEY: string = "sandbox"; | ||
} | ||
|
||
export default AppsFlyerConstants; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { SubscriptionItemPriceChangeDetailsJson, SubscriptionItemPriceChangeDetails } from "./subscription_item_price_change_details"; | ||
|
||
export type AutoRenewingPlanJson = { | ||
autoRenewEnabled?: boolean; | ||
priceChangeDetails?: SubscriptionItemPriceChangeDetailsJson; | ||
}; | ||
|
||
export class AutoRenewingPlan { | ||
autoRenewEnabled?: boolean; | ||
priceChangeDetails?: SubscriptionItemPriceChangeDetails; | ||
|
||
constructor( | ||
autoRenewEnabled?: boolean, | ||
priceChangeDetails?: SubscriptionItemPriceChangeDetails | ||
) { | ||
this.autoRenewEnabled = autoRenewEnabled; | ||
this.priceChangeDetails = priceChangeDetails; | ||
} | ||
|
||
static fromJson(json: AutoRenewingPlanJson): AutoRenewingPlan { | ||
return new AutoRenewingPlan( | ||
json.autoRenewEnabled, | ||
json.priceChangeDetails && | ||
SubscriptionItemPriceChangeDetails.fromJson(json.priceChangeDetails) | ||
); | ||
} | ||
|
||
toJson(): AutoRenewingPlanJson { | ||
return { | ||
autoRenewEnabled: this.autoRenewEnabled, | ||
priceChangeDetails: this.priceChangeDetails?.toJson(), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
export class CanceledStateContext { | ||
developerInitiatedCancellation?: DeveloperInitiatedCancellation; | ||
replacementCancellation?: ReplacementCancellation; | ||
systemInitiatedCancellation?: SystemInitiatedCancellation; | ||
userInitiatedCancellation?: UserInitiatedCancellation; | ||
|
||
constructor( | ||
developerInitiatedCancellation?: DeveloperInitiatedCancellation, | ||
replacementCancellation?: ReplacementCancellation, | ||
systemInitiatedCancellation?: SystemInitiatedCancellation, | ||
userInitiatedCancellation?: UserInitiatedCancellation | ||
) { | ||
this.developerInitiatedCancellation = developerInitiatedCancellation; | ||
this.replacementCancellation = replacementCancellation; | ||
this.systemInitiatedCancellation = systemInitiatedCancellation; | ||
this.userInitiatedCancellation = userInitiatedCancellation; | ||
} | ||
|
||
static fromJson(json: any): CanceledStateContext { | ||
return new CanceledStateContext( | ||
json.developerInitiatedCancellation != null | ||
? DeveloperInitiatedCancellation.fromJson( | ||
json.developerInitiatedCancellation | ||
) | ||
: undefined, | ||
json.replacementCancellation != null | ||
? ReplacementCancellation.fromJson(json.replacementCancellation) | ||
: undefined, | ||
json.systemInitiatedCancellation != null | ||
? SystemInitiatedCancellation.fromJson(json.systemInitiatedCancellation) | ||
: undefined, | ||
json.userInitiatedCancellation != null | ||
? UserInitiatedCancellation.fromJson(json.userInitiatedCancellation) | ||
: undefined | ||
); | ||
} | ||
|
||
toJson(): Record<string, any> { | ||
return { | ||
developerInitiatedCancellation: | ||
this.developerInitiatedCancellation?.toJson(), | ||
replacementCancellation: this.replacementCancellation?.toJson(), | ||
systemInitiatedCancellation: this.systemInitiatedCancellation?.toJson(), | ||
userInitiatedCancellation: this.userInitiatedCancellation?.toJson(), | ||
}; | ||
} | ||
} | ||
|
||
/** | ||
* TODO: Need to check each state context further... | ||
*/ | ||
class DeveloperInitiatedCancellation { | ||
constructor() {} | ||
|
||
static fromJson(json: any): DeveloperInitiatedCancellation { | ||
// Here you would implement the conversion from JSON to DeveloperInitiatedCancellation instance | ||
return new DeveloperInitiatedCancellation(); | ||
} | ||
|
||
toJson(): Record<string, unknown> { | ||
// Here you would implement the conversion from DeveloperInitiatedCancellation instance to JSON | ||
return {}; | ||
} | ||
} | ||
|
||
class ReplacementCancellation { | ||
constructor() {} | ||
|
||
static fromJson(json: any): ReplacementCancellation { | ||
// Here you would implement the conversion from JSON to ReplacementCancellation instance | ||
return new ReplacementCancellation(); | ||
} | ||
|
||
toJson(): Record<string, unknown> { | ||
return {}; | ||
} | ||
} | ||
|
||
class SystemInitiatedCancellation { | ||
constructor() {} | ||
|
||
static fromJson(json: any): SystemInitiatedCancellation { | ||
// Here you would implement the conversion from JSON to SystemInitiatedCancellation instance | ||
return new SystemInitiatedCancellation(); | ||
} | ||
|
||
toJson(): Record<string, unknown> { | ||
// Here you would implement the conversion from SystemInitiatedCancellation instance to JSON | ||
return {}; | ||
} | ||
} | ||
|
||
class UserInitiatedCancellation { | ||
cancelSurveyResult?: CancelSurveyResult; // Made optional as per Dart's CancelSurveyResult? declaration | ||
cancelTime: string; | ||
|
||
constructor( | ||
cancelSurveyResult: CancelSurveyResult | undefined, | ||
cancelTime: string | ||
) { | ||
this.cancelSurveyResult = cancelSurveyResult; | ||
this.cancelTime = cancelTime; | ||
} | ||
|
||
static fromJson(json: any): UserInitiatedCancellation { | ||
return new UserInitiatedCancellation( | ||
json.cancelSurveyResult != null | ||
? CancelSurveyResult.fromJson(json.cancelSurveyResult) | ||
: undefined, | ||
json.cancelTime | ||
); | ||
} | ||
|
||
toJson(): Record<string, unknown> { | ||
return { | ||
cancelSurveyResult: this.cancelSurveyResult?.toJson(), | ||
cancelTime: this.cancelTime, | ||
}; | ||
} | ||
} | ||
|
||
class CancelSurveyResult { | ||
reason: string; | ||
reasonUserInput: string; | ||
|
||
constructor(reason: string, reasonUserInput: string) { | ||
this.reason = reason; | ||
this.reasonUserInput = reasonUserInput; | ||
} | ||
|
||
static fromJson(json: any): CancelSurveyResult { | ||
return new CancelSurveyResult(json.reason, json.reasonUserInput); | ||
} | ||
|
||
toJson(): Record<string, string> { | ||
return { | ||
reason: this.reason, | ||
reasonUserInput: this.reasonUserInput, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export type DeferredItemReplacementJson = { | ||
productId: string; | ||
}; | ||
|
||
export class DeferredItemReplacement { | ||
productId: string; | ||
|
||
constructor(productId: string) { | ||
this.productId = productId; | ||
} | ||
|
||
static fromJson(json: DeferredItemReplacementJson): DeferredItemReplacement { | ||
return new DeferredItemReplacement(json.productId); | ||
} | ||
|
||
toJson(): DeferredItemReplacementJson { | ||
return { | ||
productId: this.productId, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
export type ExternalAccountIdentifiersJson = { | ||
externalAccountId: string; | ||
obfuscatedExternalAccountId: string; | ||
obfuscatedExternalProfileId: string; | ||
}; | ||
|
||
export class ExternalAccountIdentifiers { | ||
externalAccountId: string; | ||
obfuscatedExternalAccountId: string; | ||
obfuscatedExternalProfileId: string; | ||
|
||
constructor( | ||
externalAccountId: string, | ||
obfuscatedExternalAccountId: string, | ||
obfuscatedExternalProfileId: string | ||
) { | ||
this.externalAccountId = externalAccountId; | ||
this.obfuscatedExternalAccountId = obfuscatedExternalAccountId; | ||
this.obfuscatedExternalProfileId = obfuscatedExternalProfileId; | ||
} | ||
|
||
static fromJson( | ||
json: ExternalAccountIdentifiersJson | ||
): ExternalAccountIdentifiers { | ||
return new ExternalAccountIdentifiers( | ||
json.externalAccountId, | ||
json.obfuscatedExternalAccountId, | ||
json.obfuscatedExternalProfileId | ||
); | ||
} | ||
|
||
toJson(): ExternalAccountIdentifiersJson { | ||
return { | ||
externalAccountId: this.externalAccountId, | ||
obfuscatedExternalAccountId: this.obfuscatedExternalAccountId, | ||
obfuscatedExternalProfileId: this.obfuscatedExternalProfileId, | ||
}; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
PurchaseConnector/models/in_app_purchase_validation_result.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ProductPurchase } from "./product_purchase"; | ||
import { ValidationFailureData } from "./validation_failure_data"; | ||
|
||
export default class InAppPurchaseValidationResult { | ||
success: boolean; | ||
productPurchase?: ProductPurchase; | ||
failureData?: ValidationFailureData; | ||
|
||
constructor( | ||
success: boolean, | ||
productPurchase?: ProductPurchase, | ||
failureData?: ValidationFailureData | ||
) { | ||
this.success = success; | ||
this.productPurchase = productPurchase; | ||
this.failureData = failureData; | ||
} | ||
|
||
static fromJson(json: any): InAppPurchaseValidationResult { | ||
return new InAppPurchaseValidationResult( | ||
json.success, | ||
json.productPurchase, | ||
json.failureData | ||
); | ||
} | ||
|
||
toJson(): any { | ||
return { | ||
success: this.success, | ||
productPurchase: this.productPurchase, | ||
failureData: this.failureData, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// TypeScript class for IOS Error | ||
export class IosError { | ||
localizedDescription: string; | ||
domain: string; | ||
code: number; | ||
|
||
constructor(localizedDescription: string, domain: string, code: number) { | ||
this.localizedDescription = localizedDescription; | ||
this.domain = domain; | ||
this.code = code; | ||
} | ||
|
||
// Converts the class instance to a JSON object | ||
toJson(): object { | ||
return { | ||
localizedDescription: this.localizedDescription, | ||
domain: this.domain, | ||
code: this.code, | ||
}; | ||
} | ||
|
||
// Creates an instance of the class from a JSON object | ||
static fromJson(json: any): IosError { | ||
return new IosError(json.localizedDescription, json.domain, json.code); | ||
} | ||
} | ||
|
||
/** | ||
* Usage example: | ||
* // Creating an instance of IosError | ||
* const iosError = new IosError('An error occurred.', 'com.example.domain', 100); | ||
* | ||
* // Display information about the IOS error | ||
* console.log(iosError.localizedDescription); // Outputs: An error occurred. | ||
* console.log(iosError.domain); // Outputs: com.example.domain | ||
* console.log(iosError.code); // Outputs: 100 | ||
* | ||
* // Serializing IosError instance to a JSON object | ||
* const iosErrorJson = iosError.toJson(); | ||
* console.log(iosErrorJson); // Outputs: { localizedDescription: 'An error occurred.', domain: 'com.example.domain', code: 100 } | ||
* | ||
* // Sample JSON objects | ||
* const iosErrorData = { | ||
* localizedDescription: 'A network error occurred.', | ||
* domain: 'com.example.network', | ||
* code: 404 | ||
* }; | ||
* | ||
* // Deserializing the parsed JSON into instance of IosError | ||
* const deserializedIosError = IosError.fromJson(iosErrorData); | ||
* console.log(deserializedIosError); | ||
*/ |
Oops, something went wrong.