cogfy-messenger 0.1.2 → 0.1.3
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/dist/clients/broadcasts/broadcasts-client.d.ts +28 -0
- package/dist/clients/broadcasts/broadcasts-client.js +56 -0
- package/dist/clients/broadcasts/index.d.ts +1 -0
- package/dist/clients/broadcasts/index.js +17 -0
- package/dist/clients/broadcasts/types/broadcast-status.d.ts +1 -0
- package/dist/clients/broadcasts/types/broadcast-status.js +2 -0
- package/dist/clients/broadcasts/types/create-broadcast.d.ts +16 -0
- package/dist/clients/broadcasts/types/create-broadcast.js +2 -0
- package/dist/clients/broadcasts/types/get-broadcast.d.ts +6 -0
- package/dist/clients/broadcasts/types/get-broadcast.js +2 -0
- package/dist/clients/broadcasts/types/index.d.ts +5 -0
- package/dist/clients/broadcasts/types/index.js +21 -0
- package/dist/clients/broadcasts/types/list-broadcasts.d.ts +8 -0
- package/dist/clients/broadcasts/types/list-broadcasts.js +2 -0
- package/dist/clients/broadcasts/types/send-broadcast.d.ts +3 -0
- package/dist/clients/broadcasts/types/send-broadcast.js +2 -0
- package/dist/cogfy-messenger.d.ts +2 -0
- package/dist/cogfy-messenger.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BaseClient } from '../base-client';
|
|
2
|
+
import { CreateBroadcastCommand, CreateBroadcastResult, GetBroadcastResult, ListBroadcastsResult, SendBroadcastCommand } from './types';
|
|
3
|
+
export declare class BroadcastsClient extends BaseClient {
|
|
4
|
+
/**
|
|
5
|
+
* Calls the POST /broadcasts endpoint to create a new broadcast
|
|
6
|
+
* @param broadcast The broadcast data to create
|
|
7
|
+
* @returns The created broadcast
|
|
8
|
+
*/
|
|
9
|
+
create(broadcast: CreateBroadcastCommand): Promise<CreateBroadcastResult>;
|
|
10
|
+
/**
|
|
11
|
+
* Calls the GET /broadcasts/:id endpoint to retrieve a broadcast by ID
|
|
12
|
+
* @param id The ID of the broadcast to retrieve
|
|
13
|
+
* @returns The requested broadcast
|
|
14
|
+
*/
|
|
15
|
+
get(id: string): Promise<GetBroadcastResult>;
|
|
16
|
+
/**
|
|
17
|
+
* Calls the GET /broadcasts endpoint to retrieve all broadcasts
|
|
18
|
+
* @returns A list of all broadcasts
|
|
19
|
+
*/
|
|
20
|
+
list(): Promise<ListBroadcastsResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Calls the POST /broadcasts/:id/send endpoint to send a broadcast
|
|
23
|
+
* @param id The ID of the broadcast to send
|
|
24
|
+
* @param command The send broadcast command
|
|
25
|
+
* @returns A promise that resolves when the broadcast is sent
|
|
26
|
+
*/
|
|
27
|
+
send(id: string, command: SendBroadcastCommand): Promise<void>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.BroadcastsClient = void 0;
|
|
13
|
+
const base_client_1 = require("../base-client");
|
|
14
|
+
class BroadcastsClient extends base_client_1.BaseClient {
|
|
15
|
+
/**
|
|
16
|
+
* Calls the POST /broadcasts endpoint to create a new broadcast
|
|
17
|
+
* @param broadcast The broadcast data to create
|
|
18
|
+
* @returns The created broadcast
|
|
19
|
+
*/
|
|
20
|
+
create(broadcast) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
return (yield this.axios.post('/broadcasts', broadcast)).data;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Calls the GET /broadcasts/:id endpoint to retrieve a broadcast by ID
|
|
27
|
+
* @param id The ID of the broadcast to retrieve
|
|
28
|
+
* @returns The requested broadcast
|
|
29
|
+
*/
|
|
30
|
+
get(id) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
return (yield this.axios.get(`/broadcasts/${id}`)).data;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Calls the GET /broadcasts endpoint to retrieve all broadcasts
|
|
37
|
+
* @returns A list of all broadcasts
|
|
38
|
+
*/
|
|
39
|
+
list() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
return (yield this.axios.get('/broadcasts')).data;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Calls the POST /broadcasts/:id/send endpoint to send a broadcast
|
|
46
|
+
* @param id The ID of the broadcast to send
|
|
47
|
+
* @param command The send broadcast command
|
|
48
|
+
* @returns A promise that resolves when the broadcast is sent
|
|
49
|
+
*/
|
|
50
|
+
send(id, command) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
yield this.axios.post(`/broadcasts/${id}/send`, command);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.BroadcastsClient = BroadcastsClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './broadcasts-client';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./broadcasts-client"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type BroadcastStatus = 'draft' | 'failed' | 'pending' | 'sent';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type CreateBroadcastCommand = {
|
|
2
|
+
type: 'text';
|
|
3
|
+
title: string;
|
|
4
|
+
content: string;
|
|
5
|
+
phoneNumberId: string;
|
|
6
|
+
contactsQuery?: {
|
|
7
|
+
tags?: ({
|
|
8
|
+
id: string;
|
|
9
|
+
} | {
|
|
10
|
+
name: string;
|
|
11
|
+
})[];
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type CreateBroadcastResult = {
|
|
15
|
+
id: string;
|
|
16
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./broadcast-status"), exports);
|
|
18
|
+
__exportStar(require("./create-broadcast"), exports);
|
|
19
|
+
__exportStar(require("./get-broadcast"), exports);
|
|
20
|
+
__exportStar(require("./list-broadcasts"), exports);
|
|
21
|
+
__exportStar(require("./send-broadcast"), exports);
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ContactsClient } from './clients/contacts';
|
|
2
2
|
import { TagsClient } from './clients/tags';
|
|
3
3
|
import { ConversationsClient } from './clients/conversations';
|
|
4
|
+
import { BroadcastsClient } from './clients/broadcasts';
|
|
4
5
|
export type CogfyMessengerOptions = {
|
|
5
6
|
apiKey: string;
|
|
6
7
|
baseURL?: string;
|
|
7
8
|
};
|
|
8
9
|
export declare class CogfyMessenger {
|
|
10
|
+
broadcasts: BroadcastsClient;
|
|
9
11
|
contacts: ContactsClient;
|
|
10
12
|
conversations: ConversationsClient;
|
|
11
13
|
tags: TagsClient;
|
package/dist/cogfy-messenger.js
CHANGED
|
@@ -8,6 +8,7 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
8
8
|
const contacts_1 = require("./clients/contacts");
|
|
9
9
|
const tags_1 = require("./clients/tags");
|
|
10
10
|
const conversations_1 = require("./clients/conversations");
|
|
11
|
+
const broadcasts_1 = require("./clients/broadcasts");
|
|
11
12
|
const DEFAULT_BASE_URL = 'https://messenger-public-api.cogfy.com';
|
|
12
13
|
class CogfyMessenger {
|
|
13
14
|
constructor(options) {
|
|
@@ -19,6 +20,7 @@ class CogfyMessenger {
|
|
|
19
20
|
}
|
|
20
21
|
})
|
|
21
22
|
};
|
|
23
|
+
this.broadcasts = new broadcasts_1.BroadcastsClient(clientOptions);
|
|
22
24
|
this.contacts = new contacts_1.ContactsClient(clientOptions);
|
|
23
25
|
this.conversations = new conversations_1.ConversationsClient(clientOptions);
|
|
24
26
|
this.tags = new tags_1.TagsClient(clientOptions);
|