All files / appsflyer-react-native-plugin/PurchaseConnector/models product_purchase.ts

100% Statements 20/20
100% Branches 0/0
100% Functions 4/4
100% Lines 19/19

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100                                  1x                               5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 1x     1x                                     1x                                                          
export type ProductPurchaseArgs = {
  kind: string;
  purchaseTimeMillis: string;
  purchaseState: number;
  consumptionState: number;
  developerPayload: string;
  orderId: string;
  purchaseType: number;
  acknowledgementState: number;
  purchaseToken: string;
  productId: string;
  quantity: number;
  obfuscatedExternalAccountId: string;
  obfuscatedExternalProfileId: string;
  regionCode: string;
};
 
export class ProductPurchase {
  kind: string;
  purchaseTimeMillis: string;
  purchaseState: number;
  consumptionState: number;
  developerPayload: string;
  orderId: string;
  purchaseType: number;
  acknowledgementState: number;
  purchaseToken: string;
  productId: string;
  quantity: number;
  obfuscatedExternalAccountId: string;
  obfuscatedExternalProfileId: string;
  regionCode: string;
 
  constructor(args: ProductPurchaseArgs) {
    this.kind = args.kind;
    this.purchaseTimeMillis = args.purchaseTimeMillis;
    this.purchaseState = args.purchaseState;
    this.consumptionState = args.consumptionState;
    this.developerPayload = args.developerPayload;
    this.orderId = args.orderId;
    this.purchaseType = args.purchaseType;
    this.acknowledgementState = args.acknowledgementState;
    this.purchaseToken = args.purchaseToken;
    this.productId = args.productId;
    this.quantity = args.quantity;
    this.obfuscatedExternalAccountId = args.obfuscatedExternalAccountId;
    this.obfuscatedExternalProfileId = args.obfuscatedExternalProfileId;
    this.regionCode = args.regionCode;
  }
 
  toJson(): Record<string, any> {
    return {
      kind: this.kind,
      purchaseTimeMillis: this.purchaseTimeMillis,
      purchaseState: this.purchaseState,
      consumptionState: this.consumptionState,
      developerPayload: this.developerPayload,
      orderId: this.orderId,
      purchaseType: this.purchaseType,
      acknowledgementState: this.acknowledgementState,
      purchaseToken: this.purchaseToken,
      productId: this.productId,
      quantity: this.quantity,
      obfuscatedExternalAccountId: this.obfuscatedExternalAccountId,
      obfuscatedExternalProfileId: this.obfuscatedExternalProfileId,
      regionCode: this.regionCode,
    };
  }
 
  static fromJson(json: any): ProductPurchase {
    return new ProductPurchase({
      kind: json.kind as string,
      purchaseTimeMillis: json.purchaseTimeMillis as string,
      purchaseState: json.purchaseState as number,
      consumptionState: json.consumptionState as number,
      developerPayload: json.developerPayload as string,
      orderId: json.orderId as string,
      purchaseType: json.purchaseType as number,
      acknowledgementState: json.acknowledgementState as number,
      purchaseToken: json.purchaseToken as string,
      productId: json.productId as string,
      quantity: json.quantity as number,
      obfuscatedExternalAccountId: json.obfuscatedExternalAccountId as string,
      obfuscatedExternalProfileId: json.obfuscatedExternalProfileId as string,
      regionCode: json.regionCode as string,
    });
  }
}
 
/**
 * // Usage:
 * // To convert to JSON:
 * const productPurchaseInstance = new ProductPurchase({ ...args });
 * const json = productPurchaseInstance.toJson();
 *
 * // To convert from JSON:
 * const json = {...json };
 * const productPurchaseInstance = ProductPurchase.fromJson(json);
 */