サブアカウントの再開
このコード・スニペットでは、停止したSubaccountを再び有効にする方法を説明します。
例
以下の変数が、便利な方法で必要な値に設定されていることを確認してください:
| キー | 説明 |
|---|---|
VONAGE_API_KEY | 親アカウントのAPIキー。 |
VONAGE_API_SECRET | 親アカウントのAPIシークレット。 |
SUBACCOUNT_KEY | 再アクティブ化するSubaccountのAPIキー。 |
Write the code
Add the following to reactivate-subaccount.sh:
curl -X "PATCH" "https://api.nexmo.com/accounts/$VONAGE_API_KEY/subaccounts/$SUBACCOUNT_KEY" -u $VONAGE_API_KEY:$VONAGE_API_SECRET \
-H "Content-Type: application/json" \
-d $'{"suspended":false}'Run your code
Save this file to your machine and run it:
Prerequisites
npm install @vonage/subaccountsCreate a file named reactivate-subaccount.js and add the following code:
const { SubAccounts } = require('@vonage/subaccounts');
const subAccountClient = new SubAccounts({
apiKey: VONAGE_API_KEY,
apiSecret: VONAGE_API_SECRET,
});Write the code
Add the following to reactivate-subaccount.js:
subAccountClient.updateSubAccount(
SUBACCOUNT_KEY,
{ suspended: false },
)
.then((subAccount) => console.log(subAccount))
.catch((error) => console.error(error));Run your code
Save this file to your machine and run it:
Prerequisites
Add the following to build.gradle:
Create a class named ReactivateSubaccount and add the following code to the main method:
Write the code
Add the following to the main method of the ReactivateSubaccount class:
Run your code
We can use the アプリケーション plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
Run the following gradle command to execute your application, replacing com.vonage.quickstart.kt.subaccounts with the package containing ReactivateSubaccount:
Prerequisites
Add the following to build.gradle:
Create a class named ReactivateSubaccount 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 ReactivateSubaccount class:
Account subaccount = client.getSubaccountsClient().updateSubaccount(
UpdateSubaccountRequest.builder(SUBACCOUNT_KEY).suspended(false).build()
);Run your code
We can use the アプリケーション plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
Run the following gradle command to execute your application, replacing com.vonage.quickstart.subaccounts with the package containing ReactivateSubaccount:
Prerequisites
Install-Package VonageCreate a file named EnableAccountRequest.cs and add the following code:
Add the following to EnableAccountRequest.cs:
Prerequisites
composer require vonage/clientCreate a file named reactivate-subaccount.php and add the following code:
Run your code
Save this file to your machine and run it:
Prerequisites
pip install vonage python-dotenvRun your code
Save this file to your machine and run it:
Prerequisites
gem install vonageCreate a file named reactivate-subaccount.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 reactivate-subaccount.rb:
client.subaccounts.update(
subaccount_key: SUBACCOUNT_KEY,
suspended: false
)Run your code
Save this file to your machine and run it:
試してみる
コードを実行すると、親アカウントの指定された一時停止中のSubaccountsが再有効化されます。