@24i/bigscreen-sdk 1.0.54-alpha.2818 → 1.0.54-alpha.2819
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/packages/driver-androidtv/src/DeviceAndroidTV.ts +1 -1
- package/packages/driver-base/src/DeviceBase.ts +1 -1
- package/packages/driver-base/src/__mocks__/DeviceBase.ts +1 -1
- package/packages/driver-browser/src/DeviceBrowser.ts +1 -1
- package/packages/driver-entone/src/DeviceEntone.ts +1 -1
- package/packages/driver-firetv/src/DeviceFireTV.ts +2 -1
- package/packages/driver-hbbtv/src/DeviceHbbTV.ts +1 -1
- package/packages/driver-kreatv/src/DeviceKreaTV.ts +1 -1
- package/packages/driver-saphi/src/DeviceSaphi.ts +1 -1
- package/packages/driver-smartcast/src/DeviceSmartCast.ts +25 -4
- package/packages/driver-smartcast/src/__mocks__/api.ts +16 -0
- package/packages/driver-smartcast/src/types.ts +27 -0
- package/packages/driver-tizen/src/DeviceTizen.ts +1 -1
- package/packages/driver-vidaa/src/DeviceVidaa.ts +1 -1
- package/packages/driver-webos/src/DeviceWebos.ts +1 -1
- package/packages/driver-xbox/src/DeviceXbox.ts +1 -1
package/package.json
CHANGED
|
@@ -248,7 +248,7 @@ export class DeviceAndroidTV extends DeviceBase {
|
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
251
|
-
async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
|
|
251
|
+
async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
|
|
252
252
|
// not supported
|
|
253
253
|
throw new Error('Not supported');
|
|
254
254
|
}
|
|
@@ -180,7 +180,7 @@ export abstract class DeviceBase<
|
|
|
180
180
|
|
|
181
181
|
abstract getMacAddress(): Promise<string>;
|
|
182
182
|
|
|
183
|
-
abstract purchaseProduct(sku: string): Promise<IAPSuccessPayload>;
|
|
183
|
+
abstract purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload>;
|
|
184
184
|
|
|
185
185
|
// MARK: Private functions
|
|
186
186
|
|
|
@@ -111,7 +111,7 @@ export class DeviceBase extends AbstractDeviceBase {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
114
|
-
async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
|
|
114
|
+
async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
|
|
115
115
|
// not supported
|
|
116
116
|
throw new Error('Not supported');
|
|
117
117
|
}
|
|
@@ -182,7 +182,7 @@ export class DeviceBrowser extends DeviceBase {
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
185
|
-
async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
|
|
185
|
+
async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
|
|
186
186
|
// not supported
|
|
187
187
|
throw new Error('Not supported');
|
|
188
188
|
}
|
|
@@ -248,7 +248,7 @@ export class DeviceEntone extends DeviceBase {
|
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
251
|
-
async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
|
|
251
|
+
async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
|
|
252
252
|
// not supported
|
|
253
253
|
throw new Error('Not supported');
|
|
254
254
|
}
|
|
@@ -69,7 +69,8 @@ export class DeviceFireTV extends DeviceAndroidTV {
|
|
|
69
69
|
document.removeEventListener('iapError', this.onIAPError(resolve, reject));
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
73
|
+
async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
|
|
73
74
|
return new Promise((resolve, reject) => {
|
|
74
75
|
document.addEventListener('iapSuccess', this.onIAPSuccess(resolve, reject));
|
|
75
76
|
document.addEventListener('iapError', this.onIAPError(resolve, reject));
|
|
@@ -325,7 +325,7 @@ export class DeviceHbbTV extends DeviceBase {
|
|
|
325
325
|
}
|
|
326
326
|
|
|
327
327
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
328
|
-
async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
|
|
328
|
+
async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
|
|
329
329
|
// not supported
|
|
330
330
|
throw new Error('Not supported');
|
|
331
331
|
}
|
|
@@ -283,7 +283,7 @@ export class DeviceKreaTV extends DeviceBase {
|
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
286
|
-
async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
|
|
286
|
+
async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
|
|
287
287
|
// not supported
|
|
288
288
|
throw new Error('Not supported');
|
|
289
289
|
}
|
|
@@ -156,7 +156,7 @@ export class DeviceSaphi extends DeviceBase {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
159
|
-
async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
|
|
159
|
+
async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
|
|
160
160
|
// not supported
|
|
161
161
|
throw new Error('Not supported');
|
|
162
162
|
}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
} from '@24i/bigscreen-sdk/driver-base';
|
|
5
5
|
import { runAsync } from '@24i/bigscreen-sdk/utils/timers';
|
|
6
6
|
import { ipify } from '@24i/bigscreen-sdk/ipify';
|
|
7
|
+
import { VendorType } from '@24i/smartapps-datalayer/api';
|
|
7
8
|
import { getKeyMap } from './keymap';
|
|
8
9
|
import {
|
|
9
10
|
ISmartCastApi,
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
DEFAULT_TTS_TIMEOUT,
|
|
12
13
|
DevicePlaybackQuality,
|
|
13
14
|
DeviceLanguage,
|
|
15
|
+
PurchaseData,
|
|
14
16
|
} from './types';
|
|
15
17
|
|
|
16
18
|
declare const window: Window & { VIZIO: ISmartCastApi };
|
|
@@ -344,9 +346,28 @@ export class DeviceSmartCast extends DeviceBase {
|
|
|
344
346
|
return '';
|
|
345
347
|
}
|
|
346
348
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
349
|
+
registerPartner(callback: (challenge: string) => Promise<string>, appKeyId: string) {
|
|
350
|
+
this.API!.Account.registerPartner(callback, appKeyId);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
async checkAndLinkTv() {
|
|
354
|
+
const isLinked = await this.API!.Account.getLinkStatus();
|
|
355
|
+
if (!isLinked) await this.API!.Account.startTVLink();
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
|
|
359
|
+
await this.checkAndLinkTv();
|
|
360
|
+
await this.API!.Account.getPlans({ includeBundlePlans: true });
|
|
361
|
+
const purchaseResult = await this.API!.Account.startSVODPurchase(
|
|
362
|
+
sku, serviceId ?? '',
|
|
363
|
+
);
|
|
364
|
+
const data: PurchaseData = {
|
|
365
|
+
customerId: purchaseResult.data.customerId,
|
|
366
|
+
partnerAccountId: purchaseResult.data.partnerAccountId,
|
|
367
|
+
planCode: purchaseResult.data.planCode,
|
|
368
|
+
addOnCodes: purchaseResult.data.addOnCodes,
|
|
369
|
+
subscriptionId: purchaseResult.data.subscriptionId,
|
|
370
|
+
};
|
|
371
|
+
return { platform: VendorType.VIZIO, receiptPayload: data };
|
|
351
372
|
}
|
|
352
373
|
}
|
|
@@ -50,4 +50,20 @@ export const SmartCastMockApi: ISmartCastApi = {
|
|
|
50
50
|
console.log(text);
|
|
51
51
|
},
|
|
52
52
|
},
|
|
53
|
+
|
|
54
|
+
Account: {
|
|
55
|
+
startSVODPurchase: async () => ({
|
|
56
|
+
id: 'id',
|
|
57
|
+
data: {
|
|
58
|
+
customerId: 'customerId',
|
|
59
|
+
partnerAccountId: 'partnerAccountId',
|
|
60
|
+
planCode: 'planCode',
|
|
61
|
+
subscriptionId: 'subscriptionId',
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
registerPartner: jest.fn(),
|
|
65
|
+
getLinkStatus: async () => true,
|
|
66
|
+
startTVLink: async () => ({}),
|
|
67
|
+
getPlans: async () => ({ id: 'id', data: [] }),
|
|
68
|
+
},
|
|
53
69
|
};
|
|
@@ -39,6 +39,22 @@ export type ISmartCastApi = {
|
|
|
39
39
|
*/
|
|
40
40
|
setDeviceLanguageHandler: (callback: (deviceLanguage: DeviceLanguage) => void) => void;
|
|
41
41
|
|
|
42
|
+
Account: {
|
|
43
|
+
startSVODPurchase: (
|
|
44
|
+
planCode: string,
|
|
45
|
+
partnerAccountId: string,
|
|
46
|
+
couponCode?: string,
|
|
47
|
+
addOnCodes?: string[],
|
|
48
|
+
noFreeTrial?: boolean,
|
|
49
|
+
) => Promise<{ id: string, data: PurchaseData }>
|
|
50
|
+
registerPartner: (callback:(challenge: string) => Promise<string>, keyId: string) => void
|
|
51
|
+
getLinkStatus: () => Promise<boolean>
|
|
52
|
+
startTVLink: () => Promise<object>
|
|
53
|
+
getPlans: (options: { includeBundlePlans?: boolean }) => Promise<{
|
|
54
|
+
id: string, data: object[]
|
|
55
|
+
}>
|
|
56
|
+
}
|
|
57
|
+
|
|
42
58
|
/**
|
|
43
59
|
* Device model.
|
|
44
60
|
*/
|
|
@@ -52,6 +68,17 @@ export type ISmartCastApi = {
|
|
|
52
68
|
play: (text: string) => void,
|
|
53
69
|
};
|
|
54
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* Data type when purchase successfull.
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
export type PurchaseData = {
|
|
76
|
+
customerId: string,
|
|
77
|
+
partnerAccountId: string,
|
|
78
|
+
planCode: string,
|
|
79
|
+
addOnCodes?: string[],
|
|
80
|
+
subscriptionId: string
|
|
81
|
+
};
|
|
55
82
|
|
|
56
83
|
/**
|
|
57
84
|
* Identifier For Advertising (IFA) and Limited Tracking parameter object
|
|
@@ -322,7 +322,7 @@ export class DeviceTizen extends DeviceBase {
|
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
325
|
-
async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
|
|
325
|
+
async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
|
|
326
326
|
// not supported
|
|
327
327
|
throw new Error('Not supported');
|
|
328
328
|
}
|
|
@@ -153,7 +153,7 @@ export class DeviceVidaa extends DeviceBase {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
156
|
-
async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
|
|
156
|
+
async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
|
|
157
157
|
// not supported
|
|
158
158
|
throw new Error('Not supported');
|
|
159
159
|
}
|
|
@@ -346,7 +346,7 @@ export class DeviceWebos extends DeviceBase {
|
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
349
|
-
async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
|
|
349
|
+
async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
|
|
350
350
|
// not supported
|
|
351
351
|
throw new Error('Not supported');
|
|
352
352
|
}
|
|
@@ -246,7 +246,7 @@ export class DeviceXbox extends DeviceBase {
|
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
249
|
-
async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
|
|
249
|
+
async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
|
|
250
250
|
// not supported
|
|
251
251
|
throw new Error('Not supported');
|
|
252
252
|
}
|