@digipair/skill-nuki 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- package/index.cjs.d.ts +1 -0
- package/index.cjs.js +47 -0
- package/index.d.ts +1 -0
- package/index.esm.js +42 -0
- package/libs/skill-nuki/src/index.d.ts +1 -0
- package/libs/skill-nuki/src/lib/skill-nuki.d.ts +3 -0
- package/package.json +7 -0
- package/schema.json +88 -0
package/index.cjs.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./src/index";
|
package/index.cjs.js
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
function _extends() {
|
6
|
+
_extends = Object.assign || function assign(target) {
|
7
|
+
for(var i = 1; i < arguments.length; i++){
|
8
|
+
var source = arguments[i];
|
9
|
+
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
10
|
+
}
|
11
|
+
return target;
|
12
|
+
};
|
13
|
+
return _extends.apply(this, arguments);
|
14
|
+
}
|
15
|
+
|
16
|
+
let NukiService = class NukiService {
|
17
|
+
async call(url, method, data = null, headers = {}) {
|
18
|
+
const response = await fetch(`${this.API_ENDPOINT}${url}`, {
|
19
|
+
method,
|
20
|
+
headers: _extends({
|
21
|
+
Authorization: 'Bearer ' + this.NUKI_API_KEY
|
22
|
+
}, headers),
|
23
|
+
body: data
|
24
|
+
});
|
25
|
+
if (!response.ok) throw new Error('[SKILL-NUKI] REQUEST FAILED: ' + response.status);
|
26
|
+
return await response.json();
|
27
|
+
}
|
28
|
+
async unlock(params, _pinsSettingsList, _context) {
|
29
|
+
const { id } = params;
|
30
|
+
return await this.call(`/${id}/action/unlock`, 'POST');
|
31
|
+
}
|
32
|
+
async lock(params, _pinsSettingsList, _context) {
|
33
|
+
const { id } = params;
|
34
|
+
return await this.call(`/${id}/action/lock`, 'POST');
|
35
|
+
}
|
36
|
+
constructor(context, params){
|
37
|
+
var _context_private_NUKI_API_KEY, _ref;
|
38
|
+
this.NUKI_API_KEY = (_ref = (_context_private_NUKI_API_KEY = context.private.NUKI_API_KEY) != null ? _context_private_NUKI_API_KEY : params == null ? void 0 : params.NUKI_API_KEY) != null ? _ref : process.env['NUKI_API_KEY'];
|
39
|
+
var _context_private_NUKI_API_ENDPOINT, _ref1, _ref2;
|
40
|
+
this.API_ENDPOINT = (_ref2 = (_ref1 = (_context_private_NUKI_API_ENDPOINT = context.private.NUKI_API_ENDPOINT) != null ? _context_private_NUKI_API_ENDPOINT : params == null ? void 0 : params.NUKI_API_ENDPOINT) != null ? _ref1 : process.env['NUKI_API_ENDPOINT']) != null ? _ref2 : 'https://api.nuki.io/smartlock';
|
41
|
+
}
|
42
|
+
};
|
43
|
+
const lock = (params, pinsSettingsList, context)=>new NukiService(context, params).lock(params, pinsSettingsList, context);
|
44
|
+
const unlock = (params, pinsSettingsList, context)=>new NukiService(context, params).unlock(params, pinsSettingsList, context);
|
45
|
+
|
46
|
+
exports.lock = lock;
|
47
|
+
exports.unlock = unlock;
|
package/index.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './libs/skill-vespa/src/index';
|
package/index.esm.js
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
function _extends() {
|
2
|
+
_extends = Object.assign || function assign(target) {
|
3
|
+
for(var i = 1; i < arguments.length; i++){
|
4
|
+
var source = arguments[i];
|
5
|
+
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
6
|
+
}
|
7
|
+
return target;
|
8
|
+
};
|
9
|
+
return _extends.apply(this, arguments);
|
10
|
+
}
|
11
|
+
|
12
|
+
let NukiService = class NukiService {
|
13
|
+
async call(url, method, data = null, headers = {}) {
|
14
|
+
const response = await fetch(`${this.API_ENDPOINT}${url}`, {
|
15
|
+
method,
|
16
|
+
headers: _extends({
|
17
|
+
Authorization: 'Bearer ' + this.NUKI_API_KEY
|
18
|
+
}, headers),
|
19
|
+
body: data
|
20
|
+
});
|
21
|
+
if (!response.ok) throw new Error('[SKILL-NUKI] REQUEST FAILED: ' + response.status);
|
22
|
+
return await response.json();
|
23
|
+
}
|
24
|
+
async unlock(params, _pinsSettingsList, _context) {
|
25
|
+
const { id } = params;
|
26
|
+
return await this.call(`/${id}/action/unlock`, 'POST');
|
27
|
+
}
|
28
|
+
async lock(params, _pinsSettingsList, _context) {
|
29
|
+
const { id } = params;
|
30
|
+
return await this.call(`/${id}/action/lock`, 'POST');
|
31
|
+
}
|
32
|
+
constructor(context, params){
|
33
|
+
var _context_private_NUKI_API_KEY, _ref;
|
34
|
+
this.NUKI_API_KEY = (_ref = (_context_private_NUKI_API_KEY = context.private.NUKI_API_KEY) != null ? _context_private_NUKI_API_KEY : params == null ? void 0 : params.NUKI_API_KEY) != null ? _ref : process.env['NUKI_API_KEY'];
|
35
|
+
var _context_private_NUKI_API_ENDPOINT, _ref1, _ref2;
|
36
|
+
this.API_ENDPOINT = (_ref2 = (_ref1 = (_context_private_NUKI_API_ENDPOINT = context.private.NUKI_API_ENDPOINT) != null ? _context_private_NUKI_API_ENDPOINT : params == null ? void 0 : params.NUKI_API_ENDPOINT) != null ? _ref1 : process.env['NUKI_API_ENDPOINT']) != null ? _ref2 : 'https://api.nuki.io/smartlock';
|
37
|
+
}
|
38
|
+
};
|
39
|
+
const lock = (params, pinsSettingsList, context)=>new NukiService(context, params).lock(params, pinsSettingsList, context);
|
40
|
+
const unlock = (params, pinsSettingsList, context)=>new NukiService(context, params).unlock(params, pinsSettingsList, context);
|
41
|
+
|
42
|
+
export { lock, unlock };
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './lib/skill-nuki';
|
package/package.json
ADDED
package/schema.json
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
{
|
2
|
+
"openapi": "3.0.0",
|
3
|
+
"info": {
|
4
|
+
"title": "@digipair/skill-nuki",
|
5
|
+
"summary": "Gestion d'une serrure Nuki",
|
6
|
+
"description": "Cette compétence permet de gérer une serrure Nuki",
|
7
|
+
"version": "0.1.0",
|
8
|
+
"x-icon": "🔐"
|
9
|
+
},
|
10
|
+
"paths": {
|
11
|
+
"/unlock": {
|
12
|
+
"post": {
|
13
|
+
"tags": ["service"],
|
14
|
+
"summary": "Ouvre une serrure Nuki",
|
15
|
+
"parameters": [
|
16
|
+
{
|
17
|
+
"name": "id",
|
18
|
+
"summary": "Identifiant de la serrure",
|
19
|
+
"required": true,
|
20
|
+
"description": "Identifiant de la serrure Nuki",
|
21
|
+
"schema": {
|
22
|
+
"type": "string"
|
23
|
+
}
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"name": "NUKI_API_KEY",
|
27
|
+
"summary": "Clé d'API",
|
28
|
+
"required": false,
|
29
|
+
"description": "Clé d'API Nuki",
|
30
|
+
"schema": {
|
31
|
+
"type": "string"
|
32
|
+
}
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"name": "NUKI_API_ENDPOINT",
|
36
|
+
"summary": "Endpoint de l'API",
|
37
|
+
"required": false,
|
38
|
+
"description": "Endpoint de l'API Nuki",
|
39
|
+
"schema": {
|
40
|
+
"type": "string"
|
41
|
+
}
|
42
|
+
}
|
43
|
+
],
|
44
|
+
"x-events": []
|
45
|
+
}
|
46
|
+
},
|
47
|
+
"/lock": {
|
48
|
+
"post": {
|
49
|
+
"tags": ["service"],
|
50
|
+
"summary": "Ferme une serrure Nuki",
|
51
|
+
"parameters": [
|
52
|
+
{
|
53
|
+
"name": "id",
|
54
|
+
"summary": "Identifiant de la serrure",
|
55
|
+
"required": true,
|
56
|
+
"description": "Identifiant de la serrure Nuki",
|
57
|
+
"schema": {
|
58
|
+
"type": "string"
|
59
|
+
}
|
60
|
+
},
|
61
|
+
{
|
62
|
+
"name": "NUKI_API_KEY",
|
63
|
+
"summary": "Clé d'API",
|
64
|
+
"required": false,
|
65
|
+
"description": "Clé d'API Nuki",
|
66
|
+
"schema": {
|
67
|
+
"type": "string"
|
68
|
+
}
|
69
|
+
},
|
70
|
+
{
|
71
|
+
"name": "NUKI_API_ENDPOINT",
|
72
|
+
"summary": "Endpoint de l'API",
|
73
|
+
"required": false,
|
74
|
+
"description": "Endpoint de l'API Nuki",
|
75
|
+
"schema": {
|
76
|
+
"type": "string"
|
77
|
+
}
|
78
|
+
}
|
79
|
+
],
|
80
|
+
"x-events": []
|
81
|
+
}
|
82
|
+
}
|
83
|
+
},
|
84
|
+
"components": {
|
85
|
+
"schemas": {}
|
86
|
+
},
|
87
|
+
"x-scene-blocks": {}
|
88
|
+
}
|