Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions examples/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rapida-nodejs",
"version": "1.0.10",
"version": "1.0.11",
"description": "Enable to interact with rapida platform",
"main": "dist/index.cjs",
"module": "dist/index.js",
Expand Down
71 changes: 3 additions & 68 deletions src/clients/call.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { WithAuthContext } from "@/rapida/clients";
import {
AssistantDefinition,
CreateBulkPhoneCallRequest,
CreateBulkPhoneCallResponse,
CreatePhoneCallRequest,
CreatePhoneCallResponse,
} from "@/rapida/clients/protos/talk-api_pb";
import { ConnectionConfig } from "@/rapida/connections/connection-config";
import { ServiceError } from "@grpc/grpc-js";
import * as google_protobuf_any_pb from "google-protobuf/google/protobuf/any_pb";

/**
*
Expand All @@ -23,37 +21,9 @@ import * as google_protobuf_any_pb from "google-protobuf/google/protobuf/any_pb"
*/
export function CreatePhoneCall(
clientCfg: ConnectionConfig,
assistant: AssistantDefinition,
toNumber: string,
fromNumber?: string,
args?: Map<string, google_protobuf_any_pb.Any>,
options?: Map<string, google_protobuf_any_pb.Any>,
metadata?: Map<string, google_protobuf_any_pb.Any>
request: CreatePhoneCallRequest
): Promise<CreatePhoneCallResponse> {
return new Promise((resolve, reject) => {
const request = new CreatePhoneCallRequest();
request.setAssistant(assistant);
request.setTonumber(toNumber);
if (fromNumber) {
request.setFromnumber(fromNumber);
}
if (args) {
args.forEach((value, key) => {
request.getArgsMap().set(key, value);
});
}

if (options) {
options.forEach((value, key) => {
request.getOptionsMap().set(key, value);
});
}

if (metadata) {
metadata.forEach((value, key) => {
request.getMetadataMap().set(key, value);
});
}
clientCfg.conversationClient.createPhoneCall(
request,
WithAuthContext(clientCfg.auth),
Expand All @@ -78,46 +48,11 @@ export function CreatePhoneCall(
*/
export function CreateBulkPhoneCall(
clientCfg: ConnectionConfig,
assistant: AssistantDefinition,
params: {
toNumber: string;
fromNumber?: string;
args?: Map<string, google_protobuf_any_pb.Any>;
options?: Map<string, google_protobuf_any_pb.Any>;
metadata?: Map<string, google_protobuf_any_pb.Any>;
}[]
request: CreateBulkPhoneCallRequest
): Promise<CreateBulkPhoneCallResponse> {
return new Promise((resolve, reject) => {
const _request = new CreateBulkPhoneCallRequest();
params.map((param) => {
const request = new CreatePhoneCallRequest();
request.setAssistant(assistant);
request.setTonumber(param.toNumber);
if (param.fromNumber) {
request.setFromnumber(param.fromNumber);
}
if (param.args) {
param.args.forEach((value, key) => {
request.getArgsMap().set(key, value);
});
}

if (param.options) {
param.options.forEach((value, key) => {
request.getOptionsMap().set(key, value);
});
}

if (param.metadata) {
param.metadata.forEach((value, key) => {
request.getMetadataMap().set(key, value);
});
}
_request.addPhonecalls(request);
});

clientCfg.conversationClient.createBulkPhoneCall(
_request,
request,
WithAuthContext(clientCfg.auth),
(err: ServiceError, response: CreateBulkPhoneCallResponse) => {
if (err) reject(err);
Expand Down