diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 07f2ceb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,42 +0,0 @@ -import { - InitiateAssistantTalk, - ConnectionConfig, - AssistantDefinition, - StringToAny, -} from "../src"; -async function main() { - try { - // Example 3: Single Message Talk - - // assistant=(2195393855983976448, "latest"), - // source=RapidaSource.TWILIO_CALL, - // arguments={ - // "name": StringValue("Prashant"), - // }, - // params={ - // "to_phone": StringValue("+13342928005"), - // } - - const params = new Map(); - params.set("to_phone", StringToAny("+13342928005")); - const ast = new AssistantDefinition(); - ast.setAssistantid("2195393855983976448"); - ast.setVersion("latest"); - const talkClient = InitiateAssistantTalk( - new ConnectionConfig( - ConnectionConfig.WithSDK({ - apiKey: - "05064a056f0a60f309ff1d5cc66cb6bb5ecd1d79238e048b2594b51bfb9d4610", - userId: "prashant", - }) - ).withLocal(), - ast, - new Map() - ); - console.dir(talkClient); - } catch (err) { - console.error("Error:", err); - } -} - -main(); diff --git a/package.json b/package.json index 47a3459..cb2583c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/clients/call.ts b/src/clients/call.ts index 4f2f255..385b52a 100644 --- a/src/clients/call.ts +++ b/src/clients/call.ts @@ -1,6 +1,5 @@ import { WithAuthContext } from "@/rapida/clients"; import { - AssistantDefinition, CreateBulkPhoneCallRequest, CreateBulkPhoneCallResponse, CreatePhoneCallRequest, @@ -8,7 +7,6 @@ import { } 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"; /** * @@ -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, - options?: Map, - metadata?: Map + request: CreatePhoneCallRequest ): Promise { 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), @@ -78,46 +48,11 @@ export function CreatePhoneCall( */ export function CreateBulkPhoneCall( clientCfg: ConnectionConfig, - assistant: AssistantDefinition, - params: { - toNumber: string; - fromNumber?: string; - args?: Map; - options?: Map; - metadata?: Map; - }[] + request: CreateBulkPhoneCallRequest ): Promise { 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);