@digipair/skill-pushbullet 0.13.0

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/index.cjs.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src/index";
package/index.cjs.js ADDED
@@ -0,0 +1,53 @@
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 PushbulletService = class PushbulletService {
17
+ async call(url, method, data = null, headers = {}) {
18
+ const response = await fetch(`${this.API_ENDPOINT}${url}`, {
19
+ method,
20
+ headers: _extends({
21
+ 'Access-Token': this.PUSHBULLET_ACCESS_TOKEN
22
+ }, headers),
23
+ body: data
24
+ });
25
+ if (!response.ok) throw new Error('[SKILL-PUSHBULLET] REQUEST FAILED: ' + response.status);
26
+ return await response.json();
27
+ }
28
+ async sendSms(params, _pinsSettingsList, _context) {
29
+ const { message, phoneNumber } = params;
30
+ return await this.call('/texts', 'POST', JSON.stringify({
31
+ data: {
32
+ addresses: [
33
+ phoneNumber
34
+ ],
35
+ message,
36
+ target_device_iden: this.TARGET_DEVICE_ID
37
+ }
38
+ }), {
39
+ 'Content-Type': 'application/json'
40
+ });
41
+ }
42
+ constructor(context, params){
43
+ var _context_private_PUSHBULLET_ACCESS_TOKEN, _ref;
44
+ this.PUSHBULLET_ACCESS_TOKEN = (_ref = (_context_private_PUSHBULLET_ACCESS_TOKEN = context.private.PUSHBULLET_ACCESS_TOKEN) != null ? _context_private_PUSHBULLET_ACCESS_TOKEN : params == null ? void 0 : params.PUSHBULLET_ACCESS_TOKEN) != null ? _ref : process.env['PUSHBULLET_ACCESS_TOKEN'];
45
+ var _context_private_PUSHBULLET_TARGET_DEVICE_ID, _ref1;
46
+ this.TARGET_DEVICE_ID = (_ref1 = (_context_private_PUSHBULLET_TARGET_DEVICE_ID = context.private.PUSHBULLET_TARGET_DEVICE_ID) != null ? _context_private_PUSHBULLET_TARGET_DEVICE_ID : params == null ? void 0 : params.PUSHBULLET_TARGET_DEVICE_ID) != null ? _ref1 : process.env['PUSHBULLET_TARGET_DEVICE_ID'];
47
+ var _context_private_PUSHBULLET_API_ENDPOINT, _ref2, _ref3;
48
+ this.API_ENDPOINT = (_ref3 = (_ref2 = (_context_private_PUSHBULLET_API_ENDPOINT = context.private.PUSHBULLET_API_ENDPOINT) != null ? _context_private_PUSHBULLET_API_ENDPOINT : params == null ? void 0 : params.PUSHBULLET_API_ENDPOINT) != null ? _ref2 : process.env['PUSHBULLET_API_ENDPOINT']) != null ? _ref3 : 'https://api.pushbullet.com/v2';
49
+ }
50
+ };
51
+ const sendSms = (params, pinsSettingsList, context)=>new PushbulletService(context, params).sendSms(params, pinsSettingsList, context);
52
+
53
+ exports.sendSms = sendSms;
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './libs/skill-nuki/src/index';
package/index.esm.js ADDED
@@ -0,0 +1,49 @@
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 PushbulletService = class PushbulletService {
13
+ async call(url, method, data = null, headers = {}) {
14
+ const response = await fetch(`${this.API_ENDPOINT}${url}`, {
15
+ method,
16
+ headers: _extends({
17
+ 'Access-Token': this.PUSHBULLET_ACCESS_TOKEN
18
+ }, headers),
19
+ body: data
20
+ });
21
+ if (!response.ok) throw new Error('[SKILL-PUSHBULLET] REQUEST FAILED: ' + response.status);
22
+ return await response.json();
23
+ }
24
+ async sendSms(params, _pinsSettingsList, _context) {
25
+ const { message, phoneNumber } = params;
26
+ return await this.call('/texts', 'POST', JSON.stringify({
27
+ data: {
28
+ addresses: [
29
+ phoneNumber
30
+ ],
31
+ message,
32
+ target_device_iden: this.TARGET_DEVICE_ID
33
+ }
34
+ }), {
35
+ 'Content-Type': 'application/json'
36
+ });
37
+ }
38
+ constructor(context, params){
39
+ var _context_private_PUSHBULLET_ACCESS_TOKEN, _ref;
40
+ this.PUSHBULLET_ACCESS_TOKEN = (_ref = (_context_private_PUSHBULLET_ACCESS_TOKEN = context.private.PUSHBULLET_ACCESS_TOKEN) != null ? _context_private_PUSHBULLET_ACCESS_TOKEN : params == null ? void 0 : params.PUSHBULLET_ACCESS_TOKEN) != null ? _ref : process.env['PUSHBULLET_ACCESS_TOKEN'];
41
+ var _context_private_PUSHBULLET_TARGET_DEVICE_ID, _ref1;
42
+ this.TARGET_DEVICE_ID = (_ref1 = (_context_private_PUSHBULLET_TARGET_DEVICE_ID = context.private.PUSHBULLET_TARGET_DEVICE_ID) != null ? _context_private_PUSHBULLET_TARGET_DEVICE_ID : params == null ? void 0 : params.PUSHBULLET_TARGET_DEVICE_ID) != null ? _ref1 : process.env['PUSHBULLET_TARGET_DEVICE_ID'];
43
+ var _context_private_PUSHBULLET_API_ENDPOINT, _ref2, _ref3;
44
+ this.API_ENDPOINT = (_ref3 = (_ref2 = (_context_private_PUSHBULLET_API_ENDPOINT = context.private.PUSHBULLET_API_ENDPOINT) != null ? _context_private_PUSHBULLET_API_ENDPOINT : params == null ? void 0 : params.PUSHBULLET_API_ENDPOINT) != null ? _ref2 : process.env['PUSHBULLET_API_ENDPOINT']) != null ? _ref3 : 'https://api.pushbullet.com/v2';
45
+ }
46
+ };
47
+ const sendSms = (params, pinsSettingsList, context)=>new PushbulletService(context, params).sendSms(params, pinsSettingsList, context);
48
+
49
+ export { sendSms };
@@ -0,0 +1 @@
1
+ export * from './lib/skill-pushbullet';
@@ -0,0 +1,2 @@
1
+ import { PinsSettings } from '@digipair/engine';
2
+ export declare const sendSms: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
package/package.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "@digipair/skill-pushbullet",
3
+ "version": "0.13.0",
4
+ "dependencies": {},
5
+ "main": "./index.cjs.js",
6
+ "module": "./index.esm.js"
7
+ }
package/schema.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "openapi": "3.0.0",
3
+ "info": {
4
+ "title": "@digipair/skill-nuki",
5
+ "summary": "Gestion du service Pushbullet",
6
+ "description": "Cette compétence permet d'utiliser le service Pushbullet",
7
+ "version": "0.1.0",
8
+ "x-icon": "📲"
9
+ },
10
+ "paths": {
11
+ "/sendSms": {
12
+ "post": {
13
+ "tags": ["service"],
14
+ "summary": "Envoie un SMS via Pushbullet",
15
+ "parameters": [
16
+ {
17
+ "name": "message",
18
+ "summary": "Message",
19
+ "required": true,
20
+ "description": "Message Ă  envoyer",
21
+ "schema": {
22
+ "type": "string"
23
+ }
24
+ },
25
+ {
26
+ "name": "phoneNumber",
27
+ "summary": "Numéro de téléphone",
28
+ "required": true,
29
+ "description": "Numéro de téléphone du destinataire",
30
+ "schema": {
31
+ "type": "string"
32
+ }
33
+ },
34
+ {
35
+ "name": "PUSHBULLET_ACCESS_TOKEN",
36
+ "summary": "Clé d'API",
37
+ "required": false,
38
+ "description": "Clé d'API Pushbullet",
39
+ "schema": {
40
+ "type": "string"
41
+ }
42
+ },
43
+ {
44
+ "name": "PUSHBULLET_TARGET_DEVICE_ID",
45
+ "summary": "Identifiant du périphérique",
46
+ "required": false,
47
+ "description": "Identifiant du périphérique Pushbullet",
48
+ "schema": {
49
+ "type": "string"
50
+ }
51
+ },
52
+ {
53
+ "name": "PUSHBULLET_API_ENDPOINT",
54
+ "summary": "Endpoint de l'API",
55
+ "required": false,
56
+ "description": "Endpoint de l'API Pushbullet",
57
+ "schema": {
58
+ "type": "string"
59
+ }
60
+ }
61
+ ],
62
+ "x-events": []
63
+ }
64
+ }
65
+ },
66
+ "components": {
67
+ "schemas": {}
68
+ },
69
+ "x-scene-blocks": {}
70
+ }