Redact using an ID
In this code snippet you see how to redact a message using an ID
Example
Replace the following variables in the example code:
| Key | Description |
|---|---|
VONAGE_REDACT_ID | The ID of the data record that you'd like to redact |
VONAGE_REDACT_TYPE | The product that the ID belongs to e.g. |
Prerequisites
Add the following to build.gradle:
implementation 'com.vonage:server-sdk-kotlin:2.1.1'Create a class named RedactSms and add the following code to the main method:
val client = Vonage {
apiKey(VONAGE_API_KEY)
apiSecret(VONAGE_API_SECRET)
}Write the code
Add the following to the main method of the RedactSms class:
// Outbound
client.redact.redactSms(VONAGE_REDACT_ID)
// Inbound
client.redact.redactSms(VONAGE_REDACT_ID, Type.INBOUND)Run your code
We can use the application plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''Run the following gradle command to execute your application, replacing com.vonage.quickstart.kt.redact with the package containing RedactSms:
Prerequisites
Add the following to build.gradle:
implementation 'com.vonage:server-sdk:9.3.1'Create a class named RedactATransaction and add the following code to the main method:
VonageClient client = VonageClient.builder()
.apiKey(VONAGE_API_KEY)
.apiSecret(VONAGE_API_SECRET)
.build();Write the code
Add the following to the main method of the RedactATransaction class:
client.getRedactClient().redactTransaction(VONAGE_REDACT_ID, Product.SMS);Run your code
We can use the application plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''Run the following gradle command to execute your application, replacing com.vonage.quickstart.redact with the package containing RedactATransaction:
Prerequisites
Install-Package VonageCreate a file named RedactTransaction.cs and add the following code:
using Vonage;
using Vonage.Redaction;
using Vonage.Request;Add the following to RedactTransaction.cs:
var credentials = Credentials.FromApiKeyAndSecret(vonageApiKey, vonageApiSecret);Write the code
Add the following to RedactTransaction.cs:
var request = new RedactRequest() { Id = vonageRedactId, Type = vonageRedactType, Product = vonageRedactProduct };Prerequisites
composer require vonage/clientCreate a file named redact.php and add the following code:
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
$client = new \Vonage\Client($basic);Write the code
Add the following to redact.php:
// This request returns a 204 on success, and throws on error
$client->redact()->transaction(VONAGE_REDACT_ID, VONAGE_REDACT_TYPE);Run your code
Save this file to your machine and run it:
Prerequisites
gem install vonageCreate a file named redact.rb and add the following code:
client = Vonage::Client.new(
api_key: VONAGE_API_KEY,
api_secret: VONAGE_API_SECRET
)Write the code
Add the following to redact.rb:
client.redact.transaction(
id: VONAGE_REDACT_ID,
product: VONAGE_REDACT_TYPE
)Run your code
Save this file to your machine and run it: