homey-api 3.4.35 → 3.5.1
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.
|
@@ -374,6 +374,36 @@
|
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
},
|
|
377
|
+
"verifyOneTimePurchase": {
|
|
378
|
+
"path": "/one-time-purchase/verify",
|
|
379
|
+
"method": "post",
|
|
380
|
+
"parameters": {
|
|
381
|
+
"homeyId": {
|
|
382
|
+
"type": "string",
|
|
383
|
+
"in": "body"
|
|
384
|
+
},
|
|
385
|
+
"token": {
|
|
386
|
+
"type": "string",
|
|
387
|
+
"in": "body"
|
|
388
|
+
},
|
|
389
|
+
"sku": {
|
|
390
|
+
"type": "string",
|
|
391
|
+
"in": "body"
|
|
392
|
+
},
|
|
393
|
+
"packageName": {
|
|
394
|
+
"type": "string",
|
|
395
|
+
"in": "body"
|
|
396
|
+
},
|
|
397
|
+
"receipt": {
|
|
398
|
+
"type": "string",
|
|
399
|
+
"in": "body"
|
|
400
|
+
},
|
|
401
|
+
"orderId": {
|
|
402
|
+
"type": "string",
|
|
403
|
+
"in": "body"
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
},
|
|
377
407
|
"getOffer": {
|
|
378
408
|
"path": "/offer/{offerId}",
|
|
379
409
|
"method": "get",
|
|
@@ -4049,6 +4049,20 @@ export class AthomStoreAPI {
|
|
|
4049
4049
|
secret: string;
|
|
4050
4050
|
}): Promise<any>;
|
|
4051
4051
|
|
|
4052
|
+
verifyOneTimePurchase(opts: {
|
|
4053
|
+
homeyId?: string;
|
|
4054
|
+
|
|
4055
|
+
token?: string;
|
|
4056
|
+
|
|
4057
|
+
sku?: string;
|
|
4058
|
+
|
|
4059
|
+
packageName?: string;
|
|
4060
|
+
|
|
4061
|
+
receipt?: string;
|
|
4062
|
+
|
|
4063
|
+
orderId?: string;
|
|
4064
|
+
}): Promise<any>;
|
|
4065
|
+
|
|
4052
4066
|
getOffer(opts: { offerId: string }): Promise<any>;
|
|
4053
4067
|
|
|
4054
4068
|
redeemReferAFriend(opts: {
|
|
@@ -4259,6 +4273,20 @@ export class AthomStoreAPI {
|
|
|
4259
4273
|
secret: string;
|
|
4260
4274
|
}): Promise<any>;
|
|
4261
4275
|
|
|
4276
|
+
verifyOneTimePurchase(opts: {
|
|
4277
|
+
homeyId?: string;
|
|
4278
|
+
|
|
4279
|
+
token?: string;
|
|
4280
|
+
|
|
4281
|
+
sku?: string;
|
|
4282
|
+
|
|
4283
|
+
packageName?: string;
|
|
4284
|
+
|
|
4285
|
+
receipt?: string;
|
|
4286
|
+
|
|
4287
|
+
orderId?: string;
|
|
4288
|
+
}): Promise<any>;
|
|
4289
|
+
|
|
4262
4290
|
getOffer(opts: { offerId: string }): Promise<any>;
|
|
4263
4291
|
|
|
4264
4292
|
redeemReferAFriend(opts: {
|
|
@@ -7273,6 +7301,20 @@ export class AthomStoreAPI {
|
|
|
7273
7301
|
secret: string;
|
|
7274
7302
|
}): Promise<any>;
|
|
7275
7303
|
|
|
7304
|
+
verifyOneTimePurchase(opts: {
|
|
7305
|
+
homeyId?: string;
|
|
7306
|
+
|
|
7307
|
+
token?: string;
|
|
7308
|
+
|
|
7309
|
+
sku?: string;
|
|
7310
|
+
|
|
7311
|
+
packageName?: string;
|
|
7312
|
+
|
|
7313
|
+
receipt?: string;
|
|
7314
|
+
|
|
7315
|
+
orderId?: string;
|
|
7316
|
+
}): Promise<any>;
|
|
7317
|
+
|
|
7276
7318
|
getOffer(opts: { offerId: string }): Promise<any>;
|
|
7277
7319
|
|
|
7278
7320
|
redeemReferAFriend(opts: {
|
|
@@ -7483,6 +7525,20 @@ export class AthomStoreAPI {
|
|
|
7483
7525
|
secret: string;
|
|
7484
7526
|
}): Promise<any>;
|
|
7485
7527
|
|
|
7528
|
+
verifyOneTimePurchase(opts: {
|
|
7529
|
+
homeyId?: string;
|
|
7530
|
+
|
|
7531
|
+
token?: string;
|
|
7532
|
+
|
|
7533
|
+
sku?: string;
|
|
7534
|
+
|
|
7535
|
+
packageName?: string;
|
|
7536
|
+
|
|
7537
|
+
receipt?: string;
|
|
7538
|
+
|
|
7539
|
+
orderId?: string;
|
|
7540
|
+
}): Promise<any>;
|
|
7541
|
+
|
|
7486
7542
|
getOffer(opts: { offerId: string }): Promise<any>;
|
|
7487
7543
|
|
|
7488
7544
|
redeemReferAFriend(opts: {
|
package/lib/AthomCloudAPI.js
CHANGED
|
@@ -543,6 +543,63 @@ for(const {@link HomeyAPIV2.ManagerDevices.Device device} of Object.values(devic
|
|
|
543
543
|
return this.__token;
|
|
544
544
|
}
|
|
545
545
|
|
|
546
|
+
async authenticateWithExtendedGrantType(grantType, grantParams) {
|
|
547
|
+
if (!grantParams) {
|
|
548
|
+
throw new Error('Missing Params');
|
|
549
|
+
}
|
|
550
|
+
if (!grantType) {
|
|
551
|
+
throw new Error('Missing Grant Type');
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
if (!this.__clientId) {
|
|
555
|
+
throw new Error('Missing Client ID');
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
if (!this.__clientSecret) {
|
|
559
|
+
throw new Error('Missing Client Secret');
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
const params = {
|
|
563
|
+
grant_type: grantType,
|
|
564
|
+
...grantParams,
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
const response = await Util.fetch(`${this.baseUrl}/oauth2/token`, {
|
|
568
|
+
body: Util.encodeUrlSearchParams(params),
|
|
569
|
+
method: 'post',
|
|
570
|
+
headers: {
|
|
571
|
+
Authorization: `Basic ${Util.base64(`${this.__clientId}:${this.__clientSecret}`)}`,
|
|
572
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
573
|
+
},
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
let responseBody;
|
|
577
|
+
try {
|
|
578
|
+
responseBody = await response.json();
|
|
579
|
+
} catch (err) {
|
|
580
|
+
this.__debug(`Invalid response from server (${response.status}): ${response.text()}`);
|
|
581
|
+
throw new APIError(`Invalid response from server: ${response.text()}`, response.status);
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
if (!response.ok) {
|
|
585
|
+
throw new APIError(responseBody.error_description || responseBody.error, response.status);
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
this.__token = new Token({
|
|
589
|
+
token_type: responseBody.token_type,
|
|
590
|
+
access_token: responseBody.access_token,
|
|
591
|
+
refresh_token: responseBody.refresh_token,
|
|
592
|
+
expires_in: responseBody.expires_in,
|
|
593
|
+
grant_type: grantType,
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
this.__setStore({
|
|
597
|
+
token: this.__token,
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
return this.__token;
|
|
601
|
+
}
|
|
602
|
+
|
|
546
603
|
async authenticateWithRefreshToken() {
|
|
547
604
|
if (!this.__refreshTokenPromise) {
|
|
548
605
|
this.__refreshTokenPromise = Promise.resolve().then(async () => {
|