Conversación de actualización
En este fragmento de código aprenderás a actualizar una Conversación.
Ejemplo
Asegúrese de que las siguientes variables se ajustan a los valores requeridos utilizando cualquier método conveniente:
| Clave | Descripción |
|---|---|
CONVERSATION_ID | The ID of the Conversation. |
CONV_NEW_NAME | The new name. |
CONV_NEW_DISPLAY_NAME | The new display name. |
Requisitos previos
You will need to use an existing Application that contains Conversations in order to be able to update one. See the Create Conversation code snippet for information on how to create an Application and some sample Conversations.
Escriba el código
Añada lo siguiente a update-conversation.sh:
curl -X "PUT" "https://api.nexmo.com/v1/conversations/$CONV_ID" \
-H 'Authorization: Bearer '$JWT\
-H 'Content-Type: application/json' \
-d $'{
"name": "$CONV_NAME",
"display_name": "$CONV_DISPLAY_NAME"
}'Ejecute su código
Guarde este archivo en su máquina y ejecútelo:
Requisitos previos
You will need to use an existing Application that contains Conversations in order to be able to update one. See the Create Conversation code snippet for information on how to create an Application and some sample Conversations.
npm install @vonage/server-sdkCrea un archivo llamado update-conversation.js y añade el siguiente código:
Ejecute su código
Guarde este archivo en su máquina y ejecútelo:
Requisitos previos
You will need to use an existing Application that contains Conversations in order to be able to update one. See the Create Conversation code snippet for information on how to create an Application and some sample Conversations.
Añada lo siguiente a build.gradle:
implementation 'com.vonage:server-sdk:9.3.1'Crea un archivo llamado UpdateConversation y añade el siguiente código al método main:
VonageClient client = VonageClient.builder()
.applicationId(VONAGE_APPLICATION_ID)
.privateKeyPath(VONAGE_PRIVATE_KEY_PATH)
.build();Escriba el código
Añada lo siguiente al método main del archivo UpdateConversation:
var updated = client.getConversationsClient().updateConversation(
CONV_ID, Conversation.builder()
.name(CONV_NEW_NAME)
.displayName(CONV_NEW_DISPLAY_NAME)
.build()
);
System.out.println(updated);Ejecute su código
Podemos utilizar el plugin aplicación para Gradle para simplificar la ejecución de nuestra aplicación. Actualiza tu build.gradle con lo siguiente:
apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''Ejecute el siguiente comando gradle para ejecutar su aplicación, sustituyendo com.vonage.quickstart.conversation por el paquete que contiene UpdateConversation:
Requisitos previos
You will need to use an existing Application that contains Conversations in order to be able to update one. See the Create Conversation code snippet for information on how to create an Application and some sample Conversations.
Install-Package VonageCrea un archivo llamado UpdateConversation.cs y añade el siguiente código:
Añada lo siguiente a UpdateConversation.cs:
Requisitos previos
You will need to use an existing Application that contains Conversations in order to be able to update one. See the Create Conversation code snippet for information on how to create an Application and some sample Conversations.
composer require vonage/clientCrea un archivo llamado update-conversations.php y añade el siguiente código:
Ejecute su código
Guarde este archivo en su máquina y ejecútelo:
Pruébalo
Cuando ejecute el código actualizará la Conversación especificada con un nuevo nombre y nombre para mostrar.