From 2994e3973123120c5a387b35174bccb55cb90d70 Mon Sep 17 00:00:00 2001 From: Kamo Spertsyan Date: Fri, 30 Sep 2022 14:15:21 +0300 Subject: [PATCH] Entitlement source field added. (#41) * Entitlement source field added. * Moved tests to src folder * Test fixes * Ts fixes in tests * Fix source keys * Fix test --- .../internal/entitlements/EntitlementsService.test.ts | 11 ++++++++++- sdk/src/dto/Entitlement.ts | 9 +++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/sdk/src/__tests__/internal/entitlements/EntitlementsService.test.ts b/sdk/src/__tests__/internal/entitlements/EntitlementsService.test.ts index 978fb22..57a35e0 100644 --- a/sdk/src/__tests__/internal/entitlements/EntitlementsService.test.ts +++ b/sdk/src/__tests__/internal/entitlements/EntitlementsService.test.ts @@ -5,7 +5,14 @@ import { NetworkResponseError, NetworkResponseSuccess } from '../../../internal/network'; -import {Entitlement, PeriodType, QonversionError, QonversionErrorCode, RenewState} from '../../../index'; +import { + Entitlement, + EntitlementSource, + PeriodType, + QonversionError, + QonversionErrorCode, + RenewState +} from '../../../index'; import {HTTP_CODE_NOT_FOUND} from '../../../internal/network/constants'; import { EntitlementApi, @@ -24,6 +31,7 @@ const apiEntitlement: EntitlementApi = { started: 10, expires: 100, id: 'test entitlement', + source: 'stripe', product: { product_id: 'test product', subscription: { @@ -56,6 +64,7 @@ const expRes: Entitlement[] = [{ started: 10, expires: 100, id: 'test entitlement', + source: EntitlementSource.Stripe, product: { productId: 'test product', subscription: { diff --git a/sdk/src/dto/Entitlement.ts b/sdk/src/dto/Entitlement.ts index 4a1b286..f66e51c 100644 --- a/sdk/src/dto/Entitlement.ts +++ b/sdk/src/dto/Entitlement.ts @@ -3,6 +3,7 @@ export type Entitlement = { active: boolean; started: number; expires: number; + source: EntitlementSource; product?: Product; } @@ -27,3 +28,11 @@ export enum PeriodType { Trial = 'trial', Intro = 'intro', } + +export enum EntitlementSource { + Unknown = 'unknown', + AppStore = 'appStore', + PlayStore = 'playStore', + Stripe = 'stripe', + Manual = 'manual' +} \ No newline at end of file