From 498a147b26ef627d1991739ef43c8be7f4a4d97f Mon Sep 17 00:00:00 2001 From: DX-Bandwidth Date: Mon, 23 May 2022 18:48:16 +0000 Subject: [PATCH 01/17] Add Code Snippets to Spec Files --- site/specs/multi-factor-auth.yml | 1133 ++++++++++++++++++++++++++++++ 1 file changed, 1133 insertions(+) create mode 100644 site/specs/multi-factor-auth.yml diff --git a/site/specs/multi-factor-auth.yml b/site/specs/multi-factor-auth.yml new file mode 100644 index 000000000..4cf20a572 --- /dev/null +++ b/site/specs/multi-factor-auth.yml @@ -0,0 +1,1133 @@ +openapi: 3.0.3 +info: + title: MultiFactorAuth + description: |- + Bandwidth's Two-Factor Authentication service + ## Base Path + https://mfa.bandwidth.com/api/v1 + contact: + name: Bandwidth Edge Services + email: edge-services@bandwidth.com + url: https://support.bandwidth.com + version: 3.0.1 +servers: + - url: https://mfa.bandwidth.com/api/v1 +paths: + /accounts/{accountId}/code/voice: + post: + tags: + - MFA + summary: Voice Authentication + description: >- + Multi-Factor authentication with Bandwidth Voice services. Allows for a + user to send an MFA code via a phone call. + operationId: voiceTwoFactor + parameters: + - $ref: '#/components/parameters/accountId' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/TwoFactorCodeRequestSchema' + required: true + responses: + '200': + description: successful operation + headers: {} + content: + application/json: + schema: + $ref: '#/components/schemas/TwoFactorVoiceResponse' + '400': + $ref: '#/components/responses/badRequestError' + '401': + $ref: '#/components/responses/unauthorizedError' + '403': + $ref: '#/components/responses/forbiddenError' + '500': + $ref: '#/components/responses/internalServerError' + x-codeSamples: + - lang: cURL + source: | + curl 'https://mfa.bandwidth.com/api/v1/accounts/12345/code/voice' \ + -X POST \ + -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \ + -H 'Content-Type: application/json' \ + -d '{ + "to": "+15553334444", + "from": "+15554443333", + "applicationId": "1234-asdf", + "scope": "scope", + "message": "Your temporary {NAME} {SCOPE} code is {CODE}", + "digits": 5 + }' + - lang: C# + source: | + using System; + using System.Threading.Tasks; + using Bandwidth.Standard; + using Bandwidth.Standard.Exceptions; + using Bandwidth.Standard.MultiFactorAuth.Models; + + class Program + { + static async Task Main(string[] args) + { + var username = "api-username"; + var password = "api-pasword"; + var accountId = "12345"; + var applicationId = "1234-qwer"; + var to = "+15553334444"; + var from = "+15554443333"; + var scope = "sample"; + var digits = 6; + var message = "Your temporary {NAME} {SCOPE} code is {CODE}"; + + var client = new BandwidthClient.Builder() + .MultiFactorAuthBasicAuthCredentials(username, password) + .Build(); + + var request = new TwoFactorCodeRequestSchema + { + ApplicationId = applicationId, + To = to, + From = from, + Scope = scope, + Digits = digits, + Message = message + }; + + try + { + var response = await client.MultiFactorAuth.MFAController.CreateVoiceTwoFactorAsync(accountId, request); + Console.WriteLine(response.Data); + } + catch (ApiException e) + { + Console.WriteLine(e.Message); + } + } + } + - lang: Java + source: > + import com.bandwidth.BandwidthClient; + + import com.bandwidth.http.response.ApiResponse; + + import + com.bandwidth.multifactorauth.models.TwoFactorCodeRequestSchema; + + import com.bandwidth.multifactorauth.models.TwoFactorVoiceResponse; + + + import java.util.concurrent.CompletableFuture; + + import java.util.concurrent.ExecutionException; + + + public class Sample { + public static final String USERNAME = "api-username"; + public static final String PASSWORD = "api-password"; + public static final String ACCOUNT_ID = "12345"; + public static final String APPLICATION_ID = "1234-qwer"; + + public static void main(String[] args) { + BandwidthClient client = new BandwidthClient.Builder() + .multiFactorAuthBasicAuthCredentials(USERNAME, PASSWORD) + .build(); + + String to = "+15553334444"; + String from = "+15554443333"; + String scope = "sample"; + int digits = 6; + String message = "Your temporary {NAME} {SCOPE} code is {CODE}"; + + TwoFactorCodeRequestSchema request = new TwoFactorCodeRequestSchema(); + request.setApplicationId(APPLICATION_ID); + request.setTo(to); + request.setFrom(from); + request.setScope(scope); + request.setDigits(digits); + request.setMessage(message); + + try { + CompletableFuture> completableFuture = client.getMultiFactorAuthClient().getMFAController().createVoiceTwoFactorAsync(ACCOUNT_ID, request); + System.out.println(completableFuture.get().getResult()); + } catch (InterruptedException | ExecutionException e) { + System.out.println(e.getMessage()); + } + } + } + - lang: Node.js + source: | + import { Client, MFAController } from '@bandwidth/mfa'; + + const BW_USERNAME = "api-username"; + const BW_PASSWORD = "api-password"; + const BW_ACCOUNT_ID = "12345"; + const BW_VOICE_APPLICATION_ID = "1234-qwer"; + const fromNumber = "+15554443333"; + const toNumber = "+15553334444"; + + const client = new Client({ + basicAuthUserName: BW_USERNAME, + basicAuthPassword: BW_PASSWORD + }); + + const controller = new MFAController(client); + + const payload = { + applicationId: BW_VOICE_APPLICATION_ID, + from: fromNumber, + to: toNumber, + scope: 'scope', + digits: 5, + message: "Your temporary {NAME} {SCOPE} code is {CODE}" + } + + const voiceTwoFactor = async function() { + try { + const response = await controller.voiceTwoFactor(BW_ACCOUNT_ID, payload); + console.log(JSON.stringify(response, null, 2)); + } catch (error) { + console.error(error); + }}; + + voiceTwoFactor(); + - lang: PHP + source: > + $BW_USERNAME, + 'multiFactorAuthBasicAuthPassword' => $BW_PASSWORD, + ) + ); + + $client = new BandwidthLib\BandwidthClient($config); + + + $mfaClient = $client->getMultiFactorAuth()->getMFA(); + + + $body = new + BandwidthLib\MultiFactorAuth\Models\TwoFactorCodeRequestSchema(); + + $body->from = $BW_MFA_NUMBER; + + $body->to = $USER_NUMBER; + + $body->applicationId = $BW_MFA_VOICE_APPLICATION_ID; + + $body->scope = "scope"; + + $body->digits = 6; + + $body->message = "Your temporary {NAME} {SCOPE} code is {CODE}"; + + + try { + $mfaClient->createVoiceTwoFactor($BW_ACCOUNT_ID, $body); + } catch (BandwidthLib\APIException $e) { + print_r($e->getResponseCode()); + } + - lang: Python + source: > + from bandwidth.bandwidth_client import BandwidthClient + + from bandwidth.multifactorauth.models.two_factor_code_request_schema + import TwoFactorCodeRequestSchema + + from bandwidth.exceptions.api_exception import APIException + + + import os + + + BW_USERNAME = "api-username" + + BW_PASSWORD = "api-password" + + BW_ACCOUNT_ID = "12345" + + BW_MFA_VOICE_APPLICATION_ID = "1234-qwer" + + BW_MFA_NUMBER = "+15554443333" + + USER_NUMBER = "+15553334444" + + + bandwidth_client = BandwidthClient( + multi_factor_auth_basic_auth_user_name=BW_USERNAME, + multi_factor_auth_basic_auth_password=BW_PASSWORD + ) + + auth_client = bandwidth_client.multi_factor_auth_client.mfa + + + body = TwoFactorCodeRequestSchema( + mfrom = BW_MFA_NUMBER, + to = USER_NUMBER, + application_id = BW_MFA_VOICE_APPLICATION_ID, + scope = "scope", + digits = 6, + message = "Your temporary {NAME} {SCOPE} code is {CODE}" + ) + + + try: + auth_client.create_voice_two_factor(BW_ACCOUNT_ID, body) + except APIException as e: + print(e.response_code) + - lang: Ruby + source: | + require 'bandwidth' + + include Bandwidth + include Bandwidth::MultiFactorAuth + + bandwidth_client = Bandwidth::Client.new( + multi_factor_auth_basic_auth_user_name: "api-username", + multi_factor_auth_basic_auth_password: "api-password" + ) + auth_client = bandwidth_client.multi_factor_auth_client.mfa + + body = TwoFactorCodeRequestSchema.new + body.application_id = "1234-qwer" + body.to = "+15553334444" + body.from = "+15554443333" + body.digits = 6 + body.scope = "scope" + body.message = "Your temporary {NAME} {SCOPE} code is {CODE}" + begin + result = auth_client.create_voice_two_factor("12345", body) + puts 'callId: ' + result.data.call_id + rescue APIException => e + puts e.response_code + end + /accounts/{accountId}/code/messaging: + post: + tags: + - MFA + summary: Messaging Authentication + description: >- + Multi-Factor authentication with Bandwidth Messaging services. Allows a + user to send an MFA code via a text message (SMS). + operationId: messagingTwoFactor + parameters: + - $ref: '#/components/parameters/accountId' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/TwoFactorCodeRequestSchema' + required: true + responses: + '200': + description: successful operation + headers: {} + content: + application/json: + schema: + $ref: '#/components/schemas/TwoFactorMessagingResponse' + '400': + $ref: '#/components/responses/badRequestError' + '401': + $ref: '#/components/responses/unauthorizedError' + '403': + $ref: '#/components/responses/forbiddenError' + '500': + $ref: '#/components/responses/internalServerError' + x-codeSamples: + - lang: cURL + source: > + curl + 'https://mfa.bandwidth.com/api/v1/accounts/12345/code/messaging' \ + -X POST \ + -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \ + -H 'Content-Type: application/json' \ + -d '{ + "to": "+15553334444", + "from": "+15554443333", + "applicationId": "1234-asdf", + "scope": "scope", + "message": "Your temporary {NAME} {SCOPE} code is {CODE}", + "digits": 6 + }' + - lang: C# + source: | + using System; + using System.Threading.Tasks; + using Bandwidth.Standard; + using Bandwidth.Standard.Exceptions; + using Bandwidth.Standard.MultiFactorAuth.Models; + + class Program + { + static async Task Main(string[] args) + { + var username = "api-username"; + var password = "api-pasword"; + var accountId = "12345"; + var applicationId = "1234-asdf"; + var to = "+15553334444"; + var from = "+15554443333"; + var scope = "sample"; + var digits = 6; + var message = "Your temporary {NAME} {SCOPE} code is {CODE}"; + + var client = new BandwidthClient.Builder() + .MultiFactorAuthBasicAuthCredentials(username, password) + .Build(); + + var request = new TwoFactorCodeRequestSchema + { + ApplicationId = applicationId, + To = to, + From = from, + Scope = scope, + Digits = digits, + Message = message + }; + + try + { + var response = await client.MultiFactorAuth.MFAController.CreateMessagingTwoFactorAsync(accountId, request); + Console.WriteLine(response.Data); + } + catch (ApiException e) + { + Console.WriteLine(e.Message); + } + } + } + - lang: Java + source: > + import com.bandwidth.BandwidthClient; + + import com.bandwidth.http.response.ApiResponse; + + import + com.bandwidth.multifactorauth.models.TwoFactorCodeRequestSchema; + + import + com.bandwidth.multifactorauth.models.TwoFactorMessagingResponse; + + + import java.util.concurrent.CompletableFuture; + + import java.util.concurrent.ExecutionException; + + + public class Sample { + public static final String USERNAME = "api-username"; + public static final String PASSWORD = "api-password"; + public static final String ACCOUNT_ID = "12345"; + public static final String APPLICATION_ID = "1234-asdf"; + + public static void main(String[] args) { + BandwidthClient client = new BandwidthClient.Builder() + .multiFactorAuthBasicAuthCredentials(USERNAME, PASSWORD) + .build(); + + String to = "+15553334444"; + String from = "+15554443333"; + String scope = "sample"; + int digits = 6; + String message = "Your temporary {NAME} {SCOPE} code is {CODE}"; + + TwoFactorCodeRequestSchema request = new TwoFactorCodeRequestSchema(); + request.setApplicationId(APPLICATION_ID); + request.setTo(to); + request.setFrom(from); + request.setScope(scope); + request.setDigits(digits); + request.setMessage(message); + + try { + CompletableFuture> completableFuture = client.getMultiFactorAuthClient().getMFAController().createMessagingTwoFactorAsync(ACCOUNT_ID, request); + System.out.println(completableFuture.get().getResult()); + } catch (InterruptedException | ExecutionException e) { + System.out.println(e.getMessage()); + } + } + } + - lang: Node.js + source: | + import { Client, MFAController } from '@bandwidth/mfa'; + + const BW_USERNAME = "api-username"; + const BW_PASSWORD = "api-password"; + const BW_ACCOUNT_ID = "12345"; + const BW_MESSAGING_APPLICATION_ID = "1234-asdf"; + const fromNumber = "+15554443333"; + const toNumber = "+15553334444"; + + const client = new Client({ + basicAuthUserName: BW_USERNAME, + basicAuthPassword: BW_PASSWORD + }); + + const controller = new MFAController(client); + + const payload = { + applicationId: BW_MESSAGING_APPLICATION_ID, + from: fromNumber, + to: toNumber, + scope: 'scope', + digits: 6, + message: "Your temporary {NAME} {SCOPE} code is {CODE}" + } + + const msgTwoFactor = async function() { + try { + const response = await controller.messagingTwoFactor(BW_ACCOUNT_ID, payload); + console.log(JSON.stringify(response, null, 2)); + } catch (error) { + console.error(error); + }}; + + msgTwoFactor(); + - lang: PHP + source: > + $BW_USERNAME, + 'multiFactorAuthBasicAuthPassword' => $BW_PASSWORD, + ) + ); + + $client = new BandwidthLib\BandwidthClient($config); + + + $mfaClient = $client->getMultiFactorAuth()->getMFA(); + + + $body = new + BandwidthLib\MultiFactorAuth\Models\TwoFactorCodeRequestSchema(); + + $body->from = $BW_MFA_NUMBER; + + $body->to = $USER_NUMBER; + + $body->applicationId = $BW_MFA_MESSAGING_APPLICATION_ID; + + $body->scope = "scope"; + + $body->digits = 6; + + $body->message = "Your temporary {NAME} {SCOPE} code is {CODE}"; + + + try { + $mfaClient->createMessagingTwoFactor($BW_ACCOUNT_ID, $body); + } catch (BandwidthLib\APIException $e) { + print_r($e->getResponseCode()); + } + - lang: Python + source: > + from bandwidth.bandwidth_client import BandwidthClient + + from bandwidth.multifactorauth.models.two_factor_code_request_schema + import TwoFactorCodeRequestSchema + + from bandwidth.exceptions.api_exception import APIException + + + import os + + + BW_USERNAME = "api-username" + + BW_PASSWORD = "api-password" + + BW_ACCOUNT_ID = "12345" + + BW_MFA_MESSAGING_APPLICATION_ID = "1234-asdf" + + BW_MFA_NUMBER = "+15554443333" + + USER_NUMBER = "+15553334444" + + + bandwidth_client = BandwidthClient( + multi_factor_auth_basic_auth_user_name=BW_USERNAME, + multi_factor_auth_basic_auth_password=BW_PASSWORD + ) + + auth_client = bandwidth_client.multi_factor_auth_client.mfa + + + body = TwoFactorCodeRequestSchema( + mfrom = BW_MFA_NUMBER, + to = USER_NUMBER, + application_id = BW_MFA_MESSAGING_APPLICATION_ID, + scope = "scope", + digits = 6, + message = "Your temporary {NAME} {SCOPE} code is {CODE}" + ) + + try: + auth_client.create_messaging_two_factor(BW_ACCOUNT_ID, body) + except APIException as e: + print(e.response_code) + - lang: Ruby + source: | + require 'bandwidth' + + include Bandwidth + include Bandwidth::MultiFactorAuth + + bandwidth_client = Bandwidth::Client.new( + multi_factor_auth_basic_auth_user_name: "api-username", + multi_factor_auth_basic_auth_password: "api-password" + ) + auth_client = bandwidth_client.multi_factor_auth_client.mfa + + body = TwoFactorCodeRequestSchema.new + body.application_id = "1234-asdf" + body.to = "+15553334444" + body.from = "+15554443333" + body.digits = 6 + body.scope = "scope" + body.message = "Your temporary {NAME} {SCOPE} code is {CODE}" + begin + result = auth_client.create_messaging_two_factor("12345", body) + puts 'messageId: ' + result.data.message_id + rescue APIException => e + puts e.response_code + end + /accounts/{accountId}/code/verify: + post: + tags: + - MFA + summary: Verify Authentication Code + description: Allows a user to verify an MFA code. + operationId: verifyTwoFactor + parameters: + - $ref: '#/components/parameters/accountId' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/TwoFactorVerifyRequestSchema' + required: true + responses: + '200': + description: successful operation + headers: {} + content: + application/json: + schema: + $ref: '#/components/schemas/TwoFactorVerifyCodeResponse' + '400': + $ref: '#/components/responses/badRequestError' + '401': + $ref: '#/components/responses/unauthorizedError' + '403': + $ref: '#/components/responses/forbiddenError' + '429': + $ref: '#/components/responses/tooManyRequestsError' + '500': + $ref: '#/components/responses/internalServerError' + x-codeSamples: + - lang: cURL + source: | + curl 'https://mfa.bandwidth.com/api/v1/accounts/12345/code/verify' \ + -X POST \ + -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \ + -H 'Content-Type: application/json' \ + -d '{ + "to": "+15553334444", + "applicationId": "1234-asdf", + "scope": "scope", + "expirationTimeInMinutes": 3, + "code": "123456" + }' + - lang: C# + source: | + using System; + using System.Threading.Tasks; + using Bandwidth.Standard; + using Bandwidth.Standard.Exceptions; + using Bandwidth.Standard.MultiFactorAuth.Models; + + class Program + { + static async Task Main(string[] args) + { + var username = "api-username"; + var password = "api-pasword"; + var accountId = "12345"; + var applicationId = "1234-asdf"; + var to = "+15553334444"; + var scope = "sample"; + var code = "159193"; + var expirationTimeInMinutes = 3; + + var client = new BandwidthClient.Builder() + .MultiFactorAuthBasicAuthCredentials(username, password) + .Build(); + + var request = new TwoFactorVerifyRequestSchema + { + ApplicationId = applicationId, + To = to, + Scope = scope, + Code = code, + ExpirationTimeInMinutes = expirationTimeInMinutes + }; + + try + { + var response = await client.MultiFactorAuth.MFAController.CreateVerifyTwoFactorAsync(accountId, request); + Console.WriteLine(response.Data); + } + catch (ApiException e) + { + Console.WriteLine(e.Message); + } + } + } + - lang: Java + source: > + import com.bandwidth.BandwidthClient; + + import com.bandwidth.http.response.ApiResponse; + + import + com.bandwidth.multifactorauth.models.TwoFactorVerifyCodeResponse; + + import + com.bandwidth.multifactorauth.models.TwoFactorVerifyRequestSchema; + + + import java.util.concurrent.CompletableFuture; + + import java.util.concurrent.ExecutionException; + + + public class Sample { + public static final String USERNAME = "api-username"; + public static final String PASSWORD = "api-password"; + public static final String ACCOUNT_ID = "12345"; + public static final String APPLICATION_ID = "1234-qwer"; + + public static void main(String[] args) { + BandwidthClient client = new BandwidthClient.Builder() + .multiFactorAuthBasicAuthCredentials(USERNAME, PASSWORD) + .build(); + + String to = "+15553334444"; + String scope = "sample"; + String code = "159193"; + int expirationTimeInMinutes = 3; + + TwoFactorVerifyRequestSchema request = new TwoFactorVerifyRequestSchema(); + request.setApplicationId(APPLICATION_ID); + request.setTo(to); + request.setScope(scope); + request.setCode(code); + request.setExpirationTimeInMinutes(expirationTimeInMinutes); + + try { + CompletableFuture> completableFuture = client.getMultiFactorAuthClient().getMFAController().createVerifyTwoFactorAsync(ACCOUNT_ID, request); + System.out.println(completableFuture.get().getResult()); + } catch (InterruptedException | ExecutionException e) { + System.out.println(e.getMessage()); + } + } + } + - lang: Node.js + source: | + import { Client, MFAController } from '@bandwidth/mfa'; + + const BW_USERNAME = "api-username"; + const BW_PASSWORD = "api-password"; + const BW_ACCOUNT_ID = "12345"; + const BW_MESSAGING_APPLICATION_ID = "1234-qwer"; + const toNumber = "+15553334444"; + + const client = new Client({ + basicAuthUserName: BW_USERNAME, + basicAuthPassword: BW_PASSWORD + }); + + const controller = new MFAController(client); + + const payload = { + applicationId: BW_MESSAGING_APPLICATION_ID, + to: toNumber, + code: "12345", + scope: "scope", + expirationTimeInMinutes: 3, + code: "123456" + } + + const verifyTwoFactor = async function() { + try { + const response = await controller.verifyTwoFactor(BW_ACCOUNT_ID, payload); + console.log(JSON.stringify(response, null, 2)); + } catch (error) { + console.error(error); + }}; + + verifyTwoFactor(); + - lang: PHP + source: > + $BW_USERNAME, + 'multiFactorAuthBasicAuthPassword' => $BW_PASSWORD, + ) + ); + + $client = new BandwidthLib\BandwidthClient($config); + + + $mfaClient = $client->getMultiFactorAuth()->getMFA(); + + + $body = new + BandwidthLib\MultiFactorAuth\Models\TwoFactorVerifyRequestSchema(); + + $body->from = $BW_MFA_NUMBER; + + $body->to = $USER_NUMBER; + + $body->applicationId = $BW_MFA_MESSAGING_APPLICATION_ID; + + //$body->applicationId = 1234-qwer; + + $body->scope = "scope"; + + $body->code = "123456"; //This is the user's input to validate + + $body->digits = 6; + + $body->expirationTimeInMinutes = 3; + + + try { + $response = $mfaClient->createVerifyTwoFactor($BW_ACCOUNT_ID, $body); + print_r($response->getResult()->valid); + } catch (BandwidthLib\APIException $e) { + print_r($e->getResponseCode()); + } + - lang: Python + source: > + from bandwidth.bandwidth_client import BandwidthClient + + from + bandwidth.multifactorauth.models.two_factor_verify_request_schema + import TwoFactorVerifyRequestSchema + + from bandwidth.exceptions.api_exception import APIException + + + import os + + + BW_USERNAME = "api-username" + + BW_PASSWORD = "api-password" + + BW_ACCOUNT_ID = "12345" + + BW_MFA_VOICE_APPLICATION_ID = "1234-qwer" + + #BW_MFA_MESSAGING_APPLICATION_ID = "1234-asdf" + + #Both voice and messaging application IDs can be used. The verify + request + + #must have the same ID as the code request. + + USER_NUMBER = "+15553334444" + + + bandwidth_client = BandwidthClient( + multi_factor_auth_basic_auth_user_name=BW_USERNAME, + multi_factor_auth_basic_auth_password=BW_PASSWORD + ) + + auth_client = bandwidth_client.multi_factor_auth_client.mfa + + + body = TwoFactorVerifyRequestSchema( + to = USER_NUMBER, + application_id = BW_MFA_VOICE_APPLICATION_ID, + #application_id = MFA_MESSAGING_APPLICATION_ID, + scope = "scope", + code = "123456", #This is the user's input to validate + expiration_time_in_minutes = 3 + ) + + + try: + response = auth_client.create_verify_two_factor(BW_ACCOUNT_ID, body) + print(response.body.valid) + except APIException as e: + print(e.response_code) + - lang: Ruby + source: | + require 'bandwidth' + + include Bandwidth + include Bandwidth::MultiFactorAuth + + bandwidth_client = Bandwidth::Client.new( + multi_factor_auth_basic_auth_user_name: "api-username", + multi_factor_auth_basic_auth_password: "api-password" + ) + auth_client = bandwidth_client.multi_factor_auth_client.mfa + + body = TwoFactorVerifyRequestSchema.new + body.application_id = "1234-qwer" + body.to = "+15553334444" + body.scope = "scope" + body.code = "123456" + body.expiration_time_in_minutes = 3 + begin + result = auth_client.create_verify_two_factor("12345", body) + puts 'valid?: ' + result.data.valid + rescue APIException => e + puts e.response_code + end +components: + schemas: + TwoFactorCodeRequestSchema: + type: object + properties: + to: + type: string + description: The phone number to send the 2fa code to. + example: 19195551234 + from: + type: string + description: The application phone number, the sender of the 2fa code. + example: 19195554321 + applicationId: + type: string + description: The application unique ID, obtained from Bandwidth. + example: 66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1 + scope: + type: string + description: >- + An optional field to denote what scope or action the 2fa code is + addressing. If not supplied, defaults to "2FA". + example: 2FA + message: + type: string + description: >- + The message format of the 2fa code. There are three values that the + system will replace "{CODE}", "{NAME}", "{SCOPE}". The "{SCOPE}" + and "{NAME} value template are optional, while "{CODE}" must be + supplied. As the name would suggest, code will be replace with the + actual 2fa code. Name is replaced with the application name, + configured during provisioning of 2fa. The scope value is the same + value sent during the call and partitioned by the server. + example: 'Your code is: {CODE}' + digits: + type: number + description: >- + The number of digits for your 2fa code. The valid number ranges + from 2 to 8, inclusively. + example: 6 + required: + - to + - from + - applicationId + - message + - digits + requestError: + type: object + properties: + error: + type: string + description: A message describing the error with your request. + requestId: + type: string + description: The associated requestId from AWS. + unauthorizedRequest: + type: object + properties: + message: + type: string + description: Unauthorized + example: Unauthorized + forbiddenRequest: + type: object + properties: + message: + type: string + description: >- + The message containing the reason behind the request being + forbidden. + example: Missing Authentication Token + TwoFactorVoiceResponse: + type: object + properties: + callId: + type: string + TwoFactorMessagingResponse: + type: object + properties: + messageId: + type: string + TwoFactorVerifyRequestSchema: + type: object + properties: + to: + type: string + description: The phone number to send the 2fa code to. + example: 19195551234 + applicationId: + type: string + description: The application unique ID, obtained from Bandwidth. + example: 66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1 + scope: + type: string + description: >- + An optional field to denote what scope or action the 2fa code is + addressing. If not supplied, defaults to "2FA". + example: 2FA + expirationTimeInMinutes: + type: number + description: >- + The time period, in minutes, to validate the 2fa code. By setting + this to 3 minutes, it will mean any code generated within the last 3 + minutes are still valid. The valid range for expiration time is + between 0 and 15 minutes, exclusively and inclusively, respectively. + example: 3 + code: + type: string + description: The generated 2fa code to check if valid + example: 123456 + required: + - to + - applicationId + - expirationTimeInMinutes + - code + TwoFactorVerifyCodeResponse: + type: object + properties: + valid: + type: boolean + responses: + badRequestError: + description: Bad Request + headers: {} + content: + application/json: + schema: + $ref: '#/components/schemas/requestError' + unauthorizedError: + description: Unauthorized + headers: {} + content: + application/json: + schema: + $ref: '#/components/schemas/unauthorizedRequest' + forbiddenError: + description: Forbidden + headers: {} + content: + application/json: + schema: + $ref: '#/components/schemas/forbiddenRequest' + tooManyRequestsError: + description: Too Many Requests + headers: {} + content: + application/json: + schema: + $ref: '#/components/schemas/requestError' + internalServerError: + description: Internal Server Error + headers: {} + content: + application/json: + schema: + $ref: '#/components/schemas/requestError' + parameters: + accountId: + name: accountId + description: Bandwidth Account ID with Voice service enabled + in: path + required: true + style: simple + explode: false + schema: + type: string + securitySchemes: + httpBasic: + type: http + scheme: basic +security: + - httpBasic: [] +tags: + - name: MFA From ec7764a112fa1d6d4723d4ae4df63718630744c5 Mon Sep 17 00:00:00 2001 From: DX-Bandwidth Date: Mon, 23 May 2022 18:55:18 +0000 Subject: [PATCH 02/17] Add Code Snippets to Spec Files --- site/specs/multi-factor-auth.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/site/specs/multi-factor-auth.yml b/site/specs/multi-factor-auth.yml index 4cf20a572..e527e50d2 100644 --- a/site/specs/multi-factor-auth.yml +++ b/site/specs/multi-factor-auth.yml @@ -965,11 +965,11 @@ components: to: type: string description: The phone number to send the 2fa code to. - example: 19195551234 + example: '+19195551234' from: type: string description: The application phone number, the sender of the 2fa code. - example: 19195554321 + example: '+19195554321' applicationId: type: string description: The application unique ID, obtained from Bandwidth. @@ -1044,7 +1044,7 @@ components: to: type: string description: The phone number to send the 2fa code to. - example: 19195551234 + example: '+19195551234' applicationId: type: string description: The application unique ID, obtained from Bandwidth. @@ -1066,7 +1066,7 @@ components: code: type: string description: The generated 2fa code to check if valid - example: 123456 + example: '123456' required: - to - applicationId From 5c59da2809fb103aca4c51aff94f70ff68f22779 Mon Sep 17 00:00:00 2001 From: Cameron Koegel Date: Mon, 23 May 2022 15:01:42 -0400 Subject: [PATCH 03/17] DX-2566 Clean Up MFA Spec --- site/docusaurus.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/docusaurus.config.js b/site/docusaurus.config.js index 46b7199fb..be5231476 100644 --- a/site/docusaurus.config.js +++ b/site/docusaurus.config.js @@ -7,7 +7,7 @@ const phoneNumberLookupSpec = fs.readFileSync('./specs/phoneNumberLookup.json', const voiceSpec = fs.readFileSync('./specs/voice.json', 'utf-8'); const messagingSpec = fs.readFileSync('./specs/messaging.json', 'utf-8'); const webRtcSpec = fs.readFileSync('./specs/webRtc.json', 'utf-8'); -const multiFactorAuthSpec = fs.readFileSync('./specs/multiFactorAuth.json', 'utf-8'); +const multiFactorAuthSpec = fs.readFileSync('./specs/multi-factor-auth.yml', 'utf-8'); const dashSpec = fs.readFileSync('./specs/dash.json', 'utf-8'); const dashNotificationsSpec = fs.readFileSync('./specs/dashNotifications.json', 'utf-8'); const messagingInternationalSpec = fs.readFileSync('./specs/messagingInternational.json', 'utf-8'); From f78a327e33f98c6c4a5143f96603dbc6a3f878fd Mon Sep 17 00:00:00 2001 From: Cameron Koegel Date: Mon, 23 May 2022 15:05:49 -0400 Subject: [PATCH 04/17] YAML.parse --- site/docusaurus.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/docusaurus.config.js b/site/docusaurus.config.js index be5231476..9cecdd310 100644 --- a/site/docusaurus.config.js +++ b/site/docusaurus.config.js @@ -150,7 +150,7 @@ module.exports = { messagingSpec: JSON.parse(messagingSpec), messagingInternationalSpec: JSON.parse(messagingInternationalSpec), webRTCSpec: JSON.parse(webRtcSpec), - multiFactorAuthSpec: JSON.parse(multiFactorAuthSpec), + multiFactorAuthSpec: YAML.parse(multiFactorAuthSpec), dashSpec: JSON.parse(dashSpec), dashNotificationsSpec: JSON.parse(dashNotificationsSpec), globalSpec: YAML.parse(globalSpec), From a5911fda784b0a6569fd1e757dfb5721d50592a1 Mon Sep 17 00:00:00 2001 From: DX-Bandwidth Date: Mon, 23 May 2022 19:15:23 +0000 Subject: [PATCH 05/17] Add Code Snippets to Spec Files --- site/specs/multi-factor-auth.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/site/specs/multi-factor-auth.yml b/site/specs/multi-factor-auth.yml index e527e50d2..8d601c03c 100644 --- a/site/specs/multi-factor-auth.yml +++ b/site/specs/multi-factor-auth.yml @@ -32,7 +32,7 @@ paths: required: true responses: '200': - description: successful operation + description: OK headers: {} content: application/json: @@ -342,7 +342,7 @@ paths: required: true responses: '200': - description: successful operation + description: OK headers: {} content: application/json: @@ -651,7 +651,7 @@ paths: required: true responses: '200': - description: successful operation + description: OK headers: {} content: application/json: @@ -990,7 +990,7 @@ components: actual 2fa code. Name is replaced with the application name, configured during provisioning of 2fa. The scope value is the same value sent during the call and partitioned by the server. - example: 'Your code is: {CODE}' + example: Your temporary {NAME} {SCOPE} code is {CODE} digits: type: number description: >- From 474db6d2558cc8c811bf3014da95d3fde6156642 Mon Sep 17 00:00:00 2001 From: DX-Bandwidth Date: Tue, 31 May 2022 14:37:27 +0000 Subject: [PATCH 06/17] Add Code Snippets to Spec Files --- site/specs/multi-factor-auth.yml | 937 ++----------------------------- 1 file changed, 44 insertions(+), 893 deletions(-) diff --git a/site/specs/multi-factor-auth.yml b/site/specs/multi-factor-auth.yml index 8d601c03c..626fe1b46 100644 --- a/site/specs/multi-factor-auth.yml +++ b/site/specs/multi-factor-auth.yml @@ -17,18 +17,16 @@ paths: post: tags: - MFA - summary: Voice Authentication - description: >- - Multi-Factor authentication with Bandwidth Voice services. Allows for a - user to send an MFA code via a phone call. - operationId: voiceTwoFactor + summary: Voice Authentication Code + description: Send an MFA Code via a phone call. + operationId: generateVoiceCode parameters: - $ref: '#/components/parameters/accountId' requestBody: content: application/json: schema: - $ref: '#/components/schemas/TwoFactorCodeRequestSchema' + $ref: '#/components/schemas/codeRequestSchema' required: true responses: '200': @@ -37,7 +35,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/TwoFactorVoiceResponse' + $ref: '#/components/schemas/voiceCodeResponse' '400': $ref: '#/components/responses/badRequestError' '401': @@ -46,299 +44,20 @@ paths: $ref: '#/components/responses/forbiddenError' '500': $ref: '#/components/responses/internalServerError' - x-codeSamples: - - lang: cURL - source: | - curl 'https://mfa.bandwidth.com/api/v1/accounts/12345/code/voice' \ - -X POST \ - -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \ - -H 'Content-Type: application/json' \ - -d '{ - "to": "+15553334444", - "from": "+15554443333", - "applicationId": "1234-asdf", - "scope": "scope", - "message": "Your temporary {NAME} {SCOPE} code is {CODE}", - "digits": 5 - }' - - lang: C# - source: | - using System; - using System.Threading.Tasks; - using Bandwidth.Standard; - using Bandwidth.Standard.Exceptions; - using Bandwidth.Standard.MultiFactorAuth.Models; - - class Program - { - static async Task Main(string[] args) - { - var username = "api-username"; - var password = "api-pasword"; - var accountId = "12345"; - var applicationId = "1234-qwer"; - var to = "+15553334444"; - var from = "+15554443333"; - var scope = "sample"; - var digits = 6; - var message = "Your temporary {NAME} {SCOPE} code is {CODE}"; - - var client = new BandwidthClient.Builder() - .MultiFactorAuthBasicAuthCredentials(username, password) - .Build(); - - var request = new TwoFactorCodeRequestSchema - { - ApplicationId = applicationId, - To = to, - From = from, - Scope = scope, - Digits = digits, - Message = message - }; - - try - { - var response = await client.MultiFactorAuth.MFAController.CreateVoiceTwoFactorAsync(accountId, request); - Console.WriteLine(response.Data); - } - catch (ApiException e) - { - Console.WriteLine(e.Message); - } - } - } - - lang: Java - source: > - import com.bandwidth.BandwidthClient; - - import com.bandwidth.http.response.ApiResponse; - - import - com.bandwidth.multifactorauth.models.TwoFactorCodeRequestSchema; - - import com.bandwidth.multifactorauth.models.TwoFactorVoiceResponse; - - - import java.util.concurrent.CompletableFuture; - - import java.util.concurrent.ExecutionException; - - - public class Sample { - public static final String USERNAME = "api-username"; - public static final String PASSWORD = "api-password"; - public static final String ACCOUNT_ID = "12345"; - public static final String APPLICATION_ID = "1234-qwer"; - - public static void main(String[] args) { - BandwidthClient client = new BandwidthClient.Builder() - .multiFactorAuthBasicAuthCredentials(USERNAME, PASSWORD) - .build(); - - String to = "+15553334444"; - String from = "+15554443333"; - String scope = "sample"; - int digits = 6; - String message = "Your temporary {NAME} {SCOPE} code is {CODE}"; - - TwoFactorCodeRequestSchema request = new TwoFactorCodeRequestSchema(); - request.setApplicationId(APPLICATION_ID); - request.setTo(to); - request.setFrom(from); - request.setScope(scope); - request.setDigits(digits); - request.setMessage(message); - - try { - CompletableFuture> completableFuture = client.getMultiFactorAuthClient().getMFAController().createVoiceTwoFactorAsync(ACCOUNT_ID, request); - System.out.println(completableFuture.get().getResult()); - } catch (InterruptedException | ExecutionException e) { - System.out.println(e.getMessage()); - } - } - } - - lang: Node.js - source: | - import { Client, MFAController } from '@bandwidth/mfa'; - - const BW_USERNAME = "api-username"; - const BW_PASSWORD = "api-password"; - const BW_ACCOUNT_ID = "12345"; - const BW_VOICE_APPLICATION_ID = "1234-qwer"; - const fromNumber = "+15554443333"; - const toNumber = "+15553334444"; - - const client = new Client({ - basicAuthUserName: BW_USERNAME, - basicAuthPassword: BW_PASSWORD - }); - - const controller = new MFAController(client); - - const payload = { - applicationId: BW_VOICE_APPLICATION_ID, - from: fromNumber, - to: toNumber, - scope: 'scope', - digits: 5, - message: "Your temporary {NAME} {SCOPE} code is {CODE}" - } - - const voiceTwoFactor = async function() { - try { - const response = await controller.voiceTwoFactor(BW_ACCOUNT_ID, payload); - console.log(JSON.stringify(response, null, 2)); - } catch (error) { - console.error(error); - }}; - - voiceTwoFactor(); - - lang: PHP - source: > - $BW_USERNAME, - 'multiFactorAuthBasicAuthPassword' => $BW_PASSWORD, - ) - ); - - $client = new BandwidthLib\BandwidthClient($config); - - - $mfaClient = $client->getMultiFactorAuth()->getMFA(); - - - $body = new - BandwidthLib\MultiFactorAuth\Models\TwoFactorCodeRequestSchema(); - - $body->from = $BW_MFA_NUMBER; - - $body->to = $USER_NUMBER; - - $body->applicationId = $BW_MFA_VOICE_APPLICATION_ID; - - $body->scope = "scope"; - - $body->digits = 6; - - $body->message = "Your temporary {NAME} {SCOPE} code is {CODE}"; - - - try { - $mfaClient->createVoiceTwoFactor($BW_ACCOUNT_ID, $body); - } catch (BandwidthLib\APIException $e) { - print_r($e->getResponseCode()); - } - - lang: Python - source: > - from bandwidth.bandwidth_client import BandwidthClient - - from bandwidth.multifactorauth.models.two_factor_code_request_schema - import TwoFactorCodeRequestSchema - - from bandwidth.exceptions.api_exception import APIException - - - import os - - - BW_USERNAME = "api-username" - - BW_PASSWORD = "api-password" - - BW_ACCOUNT_ID = "12345" - - BW_MFA_VOICE_APPLICATION_ID = "1234-qwer" - - BW_MFA_NUMBER = "+15554443333" - - USER_NUMBER = "+15553334444" - - - bandwidth_client = BandwidthClient( - multi_factor_auth_basic_auth_user_name=BW_USERNAME, - multi_factor_auth_basic_auth_password=BW_PASSWORD - ) - - auth_client = bandwidth_client.multi_factor_auth_client.mfa - - - body = TwoFactorCodeRequestSchema( - mfrom = BW_MFA_NUMBER, - to = USER_NUMBER, - application_id = BW_MFA_VOICE_APPLICATION_ID, - scope = "scope", - digits = 6, - message = "Your temporary {NAME} {SCOPE} code is {CODE}" - ) - - - try: - auth_client.create_voice_two_factor(BW_ACCOUNT_ID, body) - except APIException as e: - print(e.response_code) - - lang: Ruby - source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::MultiFactorAuth - - bandwidth_client = Bandwidth::Client.new( - multi_factor_auth_basic_auth_user_name: "api-username", - multi_factor_auth_basic_auth_password: "api-password" - ) - auth_client = bandwidth_client.multi_factor_auth_client.mfa - - body = TwoFactorCodeRequestSchema.new - body.application_id = "1234-qwer" - body.to = "+15553334444" - body.from = "+15554443333" - body.digits = 6 - body.scope = "scope" - body.message = "Your temporary {NAME} {SCOPE} code is {CODE}" - begin - result = auth_client.create_voice_two_factor("12345", body) - puts 'callId: ' + result.data.call_id - rescue APIException => e - puts e.response_code - end /accounts/{accountId}/code/messaging: post: tags: - MFA - summary: Messaging Authentication - description: >- - Multi-Factor authentication with Bandwidth Messaging services. Allows a - user to send an MFA code via a text message (SMS). - operationId: messagingTwoFactor + summary: Messaging Authentication Code + description: Send an MFA code via text message (SMS). + operationId: generateMessagingCode parameters: - $ref: '#/components/parameters/accountId' requestBody: content: application/json: schema: - $ref: '#/components/schemas/TwoFactorCodeRequestSchema' + $ref: '#/components/schemas/codeRequestSchema' required: true responses: '200': @@ -347,7 +66,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/TwoFactorMessagingResponse' + $ref: '#/components/schemas/messagingCodeResponse' '400': $ref: '#/components/responses/badRequestError' '401': @@ -356,298 +75,20 @@ paths: $ref: '#/components/responses/forbiddenError' '500': $ref: '#/components/responses/internalServerError' - x-codeSamples: - - lang: cURL - source: > - curl - 'https://mfa.bandwidth.com/api/v1/accounts/12345/code/messaging' \ - -X POST \ - -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \ - -H 'Content-Type: application/json' \ - -d '{ - "to": "+15553334444", - "from": "+15554443333", - "applicationId": "1234-asdf", - "scope": "scope", - "message": "Your temporary {NAME} {SCOPE} code is {CODE}", - "digits": 6 - }' - - lang: C# - source: | - using System; - using System.Threading.Tasks; - using Bandwidth.Standard; - using Bandwidth.Standard.Exceptions; - using Bandwidth.Standard.MultiFactorAuth.Models; - - class Program - { - static async Task Main(string[] args) - { - var username = "api-username"; - var password = "api-pasword"; - var accountId = "12345"; - var applicationId = "1234-asdf"; - var to = "+15553334444"; - var from = "+15554443333"; - var scope = "sample"; - var digits = 6; - var message = "Your temporary {NAME} {SCOPE} code is {CODE}"; - - var client = new BandwidthClient.Builder() - .MultiFactorAuthBasicAuthCredentials(username, password) - .Build(); - - var request = new TwoFactorCodeRequestSchema - { - ApplicationId = applicationId, - To = to, - From = from, - Scope = scope, - Digits = digits, - Message = message - }; - - try - { - var response = await client.MultiFactorAuth.MFAController.CreateMessagingTwoFactorAsync(accountId, request); - Console.WriteLine(response.Data); - } - catch (ApiException e) - { - Console.WriteLine(e.Message); - } - } - } - - lang: Java - source: > - import com.bandwidth.BandwidthClient; - - import com.bandwidth.http.response.ApiResponse; - - import - com.bandwidth.multifactorauth.models.TwoFactorCodeRequestSchema; - - import - com.bandwidth.multifactorauth.models.TwoFactorMessagingResponse; - - - import java.util.concurrent.CompletableFuture; - - import java.util.concurrent.ExecutionException; - - - public class Sample { - public static final String USERNAME = "api-username"; - public static final String PASSWORD = "api-password"; - public static final String ACCOUNT_ID = "12345"; - public static final String APPLICATION_ID = "1234-asdf"; - - public static void main(String[] args) { - BandwidthClient client = new BandwidthClient.Builder() - .multiFactorAuthBasicAuthCredentials(USERNAME, PASSWORD) - .build(); - - String to = "+15553334444"; - String from = "+15554443333"; - String scope = "sample"; - int digits = 6; - String message = "Your temporary {NAME} {SCOPE} code is {CODE}"; - - TwoFactorCodeRequestSchema request = new TwoFactorCodeRequestSchema(); - request.setApplicationId(APPLICATION_ID); - request.setTo(to); - request.setFrom(from); - request.setScope(scope); - request.setDigits(digits); - request.setMessage(message); - - try { - CompletableFuture> completableFuture = client.getMultiFactorAuthClient().getMFAController().createMessagingTwoFactorAsync(ACCOUNT_ID, request); - System.out.println(completableFuture.get().getResult()); - } catch (InterruptedException | ExecutionException e) { - System.out.println(e.getMessage()); - } - } - } - - lang: Node.js - source: | - import { Client, MFAController } from '@bandwidth/mfa'; - - const BW_USERNAME = "api-username"; - const BW_PASSWORD = "api-password"; - const BW_ACCOUNT_ID = "12345"; - const BW_MESSAGING_APPLICATION_ID = "1234-asdf"; - const fromNumber = "+15554443333"; - const toNumber = "+15553334444"; - - const client = new Client({ - basicAuthUserName: BW_USERNAME, - basicAuthPassword: BW_PASSWORD - }); - - const controller = new MFAController(client); - - const payload = { - applicationId: BW_MESSAGING_APPLICATION_ID, - from: fromNumber, - to: toNumber, - scope: 'scope', - digits: 6, - message: "Your temporary {NAME} {SCOPE} code is {CODE}" - } - - const msgTwoFactor = async function() { - try { - const response = await controller.messagingTwoFactor(BW_ACCOUNT_ID, payload); - console.log(JSON.stringify(response, null, 2)); - } catch (error) { - console.error(error); - }}; - - msgTwoFactor(); - - lang: PHP - source: > - $BW_USERNAME, - 'multiFactorAuthBasicAuthPassword' => $BW_PASSWORD, - ) - ); - - $client = new BandwidthLib\BandwidthClient($config); - - - $mfaClient = $client->getMultiFactorAuth()->getMFA(); - - - $body = new - BandwidthLib\MultiFactorAuth\Models\TwoFactorCodeRequestSchema(); - - $body->from = $BW_MFA_NUMBER; - - $body->to = $USER_NUMBER; - - $body->applicationId = $BW_MFA_MESSAGING_APPLICATION_ID; - - $body->scope = "scope"; - - $body->digits = 6; - - $body->message = "Your temporary {NAME} {SCOPE} code is {CODE}"; - - - try { - $mfaClient->createMessagingTwoFactor($BW_ACCOUNT_ID, $body); - } catch (BandwidthLib\APIException $e) { - print_r($e->getResponseCode()); - } - - lang: Python - source: > - from bandwidth.bandwidth_client import BandwidthClient - - from bandwidth.multifactorauth.models.two_factor_code_request_schema - import TwoFactorCodeRequestSchema - - from bandwidth.exceptions.api_exception import APIException - - - import os - - - BW_USERNAME = "api-username" - - BW_PASSWORD = "api-password" - - BW_ACCOUNT_ID = "12345" - - BW_MFA_MESSAGING_APPLICATION_ID = "1234-asdf" - - BW_MFA_NUMBER = "+15554443333" - - USER_NUMBER = "+15553334444" - - - bandwidth_client = BandwidthClient( - multi_factor_auth_basic_auth_user_name=BW_USERNAME, - multi_factor_auth_basic_auth_password=BW_PASSWORD - ) - - auth_client = bandwidth_client.multi_factor_auth_client.mfa - - - body = TwoFactorCodeRequestSchema( - mfrom = BW_MFA_NUMBER, - to = USER_NUMBER, - application_id = BW_MFA_MESSAGING_APPLICATION_ID, - scope = "scope", - digits = 6, - message = "Your temporary {NAME} {SCOPE} code is {CODE}" - ) - - try: - auth_client.create_messaging_two_factor(BW_ACCOUNT_ID, body) - except APIException as e: - print(e.response_code) - - lang: Ruby - source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::MultiFactorAuth - - bandwidth_client = Bandwidth::Client.new( - multi_factor_auth_basic_auth_user_name: "api-username", - multi_factor_auth_basic_auth_password: "api-password" - ) - auth_client = bandwidth_client.multi_factor_auth_client.mfa - - body = TwoFactorCodeRequestSchema.new - body.application_id = "1234-asdf" - body.to = "+15553334444" - body.from = "+15554443333" - body.digits = 6 - body.scope = "scope" - body.message = "Your temporary {NAME} {SCOPE} code is {CODE}" - begin - result = auth_client.create_messaging_two_factor("12345", body) - puts 'messageId: ' + result.data.message_id - rescue APIException => e - puts e.response_code - end /accounts/{accountId}/code/verify: post: tags: - MFA summary: Verify Authentication Code - description: Allows a user to verify an MFA code. - operationId: verifyTwoFactor + description: Verify a previously sent MFA code. + operationId: verifyCode parameters: - $ref: '#/components/parameters/accountId' requestBody: content: application/json: schema: - $ref: '#/components/schemas/TwoFactorVerifyRequestSchema' + $ref: '#/components/schemas/verifyRequestSchema' required: true responses: '200': @@ -656,7 +97,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/TwoFactorVerifyCodeResponse' + $ref: '#/components/schemas/verifyCodeResponse' '400': $ref: '#/components/responses/badRequestError' '401': @@ -667,299 +108,9 @@ paths: $ref: '#/components/responses/tooManyRequestsError' '500': $ref: '#/components/responses/internalServerError' - x-codeSamples: - - lang: cURL - source: | - curl 'https://mfa.bandwidth.com/api/v1/accounts/12345/code/verify' \ - -X POST \ - -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \ - -H 'Content-Type: application/json' \ - -d '{ - "to": "+15553334444", - "applicationId": "1234-asdf", - "scope": "scope", - "expirationTimeInMinutes": 3, - "code": "123456" - }' - - lang: C# - source: | - using System; - using System.Threading.Tasks; - using Bandwidth.Standard; - using Bandwidth.Standard.Exceptions; - using Bandwidth.Standard.MultiFactorAuth.Models; - - class Program - { - static async Task Main(string[] args) - { - var username = "api-username"; - var password = "api-pasword"; - var accountId = "12345"; - var applicationId = "1234-asdf"; - var to = "+15553334444"; - var scope = "sample"; - var code = "159193"; - var expirationTimeInMinutes = 3; - - var client = new BandwidthClient.Builder() - .MultiFactorAuthBasicAuthCredentials(username, password) - .Build(); - - var request = new TwoFactorVerifyRequestSchema - { - ApplicationId = applicationId, - To = to, - Scope = scope, - Code = code, - ExpirationTimeInMinutes = expirationTimeInMinutes - }; - - try - { - var response = await client.MultiFactorAuth.MFAController.CreateVerifyTwoFactorAsync(accountId, request); - Console.WriteLine(response.Data); - } - catch (ApiException e) - { - Console.WriteLine(e.Message); - } - } - } - - lang: Java - source: > - import com.bandwidth.BandwidthClient; - - import com.bandwidth.http.response.ApiResponse; - - import - com.bandwidth.multifactorauth.models.TwoFactorVerifyCodeResponse; - - import - com.bandwidth.multifactorauth.models.TwoFactorVerifyRequestSchema; - - - import java.util.concurrent.CompletableFuture; - - import java.util.concurrent.ExecutionException; - - - public class Sample { - public static final String USERNAME = "api-username"; - public static final String PASSWORD = "api-password"; - public static final String ACCOUNT_ID = "12345"; - public static final String APPLICATION_ID = "1234-qwer"; - - public static void main(String[] args) { - BandwidthClient client = new BandwidthClient.Builder() - .multiFactorAuthBasicAuthCredentials(USERNAME, PASSWORD) - .build(); - - String to = "+15553334444"; - String scope = "sample"; - String code = "159193"; - int expirationTimeInMinutes = 3; - - TwoFactorVerifyRequestSchema request = new TwoFactorVerifyRequestSchema(); - request.setApplicationId(APPLICATION_ID); - request.setTo(to); - request.setScope(scope); - request.setCode(code); - request.setExpirationTimeInMinutes(expirationTimeInMinutes); - - try { - CompletableFuture> completableFuture = client.getMultiFactorAuthClient().getMFAController().createVerifyTwoFactorAsync(ACCOUNT_ID, request); - System.out.println(completableFuture.get().getResult()); - } catch (InterruptedException | ExecutionException e) { - System.out.println(e.getMessage()); - } - } - } - - lang: Node.js - source: | - import { Client, MFAController } from '@bandwidth/mfa'; - - const BW_USERNAME = "api-username"; - const BW_PASSWORD = "api-password"; - const BW_ACCOUNT_ID = "12345"; - const BW_MESSAGING_APPLICATION_ID = "1234-qwer"; - const toNumber = "+15553334444"; - - const client = new Client({ - basicAuthUserName: BW_USERNAME, - basicAuthPassword: BW_PASSWORD - }); - - const controller = new MFAController(client); - - const payload = { - applicationId: BW_MESSAGING_APPLICATION_ID, - to: toNumber, - code: "12345", - scope: "scope", - expirationTimeInMinutes: 3, - code: "123456" - } - - const verifyTwoFactor = async function() { - try { - const response = await controller.verifyTwoFactor(BW_ACCOUNT_ID, payload); - console.log(JSON.stringify(response, null, 2)); - } catch (error) { - console.error(error); - }}; - - verifyTwoFactor(); - - lang: PHP - source: > - $BW_USERNAME, - 'multiFactorAuthBasicAuthPassword' => $BW_PASSWORD, - ) - ); - - $client = new BandwidthLib\BandwidthClient($config); - - - $mfaClient = $client->getMultiFactorAuth()->getMFA(); - - - $body = new - BandwidthLib\MultiFactorAuth\Models\TwoFactorVerifyRequestSchema(); - - $body->from = $BW_MFA_NUMBER; - - $body->to = $USER_NUMBER; - - $body->applicationId = $BW_MFA_MESSAGING_APPLICATION_ID; - - //$body->applicationId = 1234-qwer; - - $body->scope = "scope"; - - $body->code = "123456"; //This is the user's input to validate - - $body->digits = 6; - - $body->expirationTimeInMinutes = 3; - - - try { - $response = $mfaClient->createVerifyTwoFactor($BW_ACCOUNT_ID, $body); - print_r($response->getResult()->valid); - } catch (BandwidthLib\APIException $e) { - print_r($e->getResponseCode()); - } - - lang: Python - source: > - from bandwidth.bandwidth_client import BandwidthClient - - from - bandwidth.multifactorauth.models.two_factor_verify_request_schema - import TwoFactorVerifyRequestSchema - - from bandwidth.exceptions.api_exception import APIException - - - import os - - - BW_USERNAME = "api-username" - - BW_PASSWORD = "api-password" - - BW_ACCOUNT_ID = "12345" - - BW_MFA_VOICE_APPLICATION_ID = "1234-qwer" - - #BW_MFA_MESSAGING_APPLICATION_ID = "1234-asdf" - - #Both voice and messaging application IDs can be used. The verify - request - - #must have the same ID as the code request. - - USER_NUMBER = "+15553334444" - - - bandwidth_client = BandwidthClient( - multi_factor_auth_basic_auth_user_name=BW_USERNAME, - multi_factor_auth_basic_auth_password=BW_PASSWORD - ) - - auth_client = bandwidth_client.multi_factor_auth_client.mfa - - - body = TwoFactorVerifyRequestSchema( - to = USER_NUMBER, - application_id = BW_MFA_VOICE_APPLICATION_ID, - #application_id = MFA_MESSAGING_APPLICATION_ID, - scope = "scope", - code = "123456", #This is the user's input to validate - expiration_time_in_minutes = 3 - ) - - - try: - response = auth_client.create_verify_two_factor(BW_ACCOUNT_ID, body) - print(response.body.valid) - except APIException as e: - print(e.response_code) - - lang: Ruby - source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::MultiFactorAuth - - bandwidth_client = Bandwidth::Client.new( - multi_factor_auth_basic_auth_user_name: "api-username", - multi_factor_auth_basic_auth_password: "api-password" - ) - auth_client = bandwidth_client.multi_factor_auth_client.mfa - - body = TwoFactorVerifyRequestSchema.new - body.application_id = "1234-qwer" - body.to = "+15553334444" - body.scope = "scope" - body.code = "123456" - body.expiration_time_in_minutes = 3 - begin - result = auth_client.create_verify_two_factor("12345", body) - puts 'valid?: ' + result.data.valid - rescue APIException => e - puts e.response_code - end components: schemas: - TwoFactorCodeRequestSchema: + codeRequestSchema: type: object properties: to: @@ -1003,42 +154,17 @@ components: - applicationId - message - digits - requestError: - type: object - properties: - error: - type: string - description: A message describing the error with your request. - requestId: - type: string - description: The associated requestId from AWS. - unauthorizedRequest: - type: object - properties: - message: - type: string - description: Unauthorized - example: Unauthorized - forbiddenRequest: - type: object - properties: - message: - type: string - description: >- - The message containing the reason behind the request being - forbidden. - example: Missing Authentication Token - TwoFactorVoiceResponse: + voiceCodeResponse: type: object properties: callId: type: string - TwoFactorMessagingResponse: + messagingCodeResponse: type: object properties: messageId: type: string - TwoFactorVerifyRequestSchema: + verifyRequestSchema: type: object properties: to: @@ -1072,11 +198,36 @@ components: - applicationId - expirationTimeInMinutes - code - TwoFactorVerifyCodeResponse: + verifyCodeResponse: type: object properties: valid: type: boolean + requestError: + type: object + properties: + error: + type: string + description: A message describing the error with your request. + requestId: + type: string + description: The associated requestId from AWS. + unauthorizedRequest: + type: object + properties: + message: + type: string + description: Unauthorized + example: Unauthorized + forbiddenRequest: + type: object + properties: + message: + type: string + description: >- + The message containing the reason behind the request being + forbidden. + example: Missing Authentication Token responses: badRequestError: description: Bad Request From d8637eecd15ea529d0926554ef681b5b7ef14ec9 Mon Sep 17 00:00:00 2001 From: DX-Bandwidth Date: Fri, 10 Jun 2022 21:00:22 +0000 Subject: [PATCH 07/17] Add Code Snippets to Spec Files --- site/specs/multi-factor-auth.yml | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/site/specs/multi-factor-auth.yml b/site/specs/multi-factor-auth.yml index 626fe1b46..e591dd760 100644 --- a/site/specs/multi-factor-auth.yml +++ b/site/specs/multi-factor-auth.yml @@ -116,20 +116,26 @@ components: to: type: string description: The phone number to send the 2fa code to. + pattern: ^\+[1-9]\d{1,14}$ example: '+19195551234' from: type: string description: The application phone number, the sender of the 2fa code. + pattern: ^\+[1-9]\d{1,14}$ + maxLength: 32 example: '+19195554321' applicationId: type: string description: The application unique ID, obtained from Bandwidth. + maxLength: 50 example: 66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1 scope: type: string description: >- An optional field to denote what scope or action the 2fa code is addressing. If not supplied, defaults to "2FA". + maxLength: 25 + default: 2FA example: 2FA message: type: string @@ -141,12 +147,15 @@ components: actual 2fa code. Name is replaced with the application name, configured during provisioning of 2fa. The scope value is the same value sent during the call and partitioned by the server. + maxLength: 2048 example: Your temporary {NAME} {SCOPE} code is {CODE} digits: - type: number + type: integer description: >- The number of digits for your 2fa code. The valid number ranges from 2 to 8, inclusively. + minimum: 4 + maximum: 8 example: 6 required: - to @@ -203,7 +212,7 @@ components: properties: valid: type: boolean - requestError: + mfaRequestError: type: object properties: error: @@ -212,14 +221,14 @@ components: requestId: type: string description: The associated requestId from AWS. - unauthorizedRequest: + mfaUnauthorizedRequestError: type: object properties: message: type: string description: Unauthorized example: Unauthorized - forbiddenRequest: + mfaForbiddenRequestError: type: object properties: message: @@ -235,35 +244,35 @@ components: content: application/json: schema: - $ref: '#/components/schemas/requestError' + $ref: '#/components/schemas/mfaRequestError' unauthorizedError: description: Unauthorized headers: {} content: application/json: schema: - $ref: '#/components/schemas/unauthorizedRequest' + $ref: '#/components/schemas/mfaUnauthorizedRequestError' forbiddenError: description: Forbidden headers: {} content: application/json: schema: - $ref: '#/components/schemas/forbiddenRequest' + $ref: '#/components/schemas/mfaForbiddenRequestError' tooManyRequestsError: description: Too Many Requests headers: {} content: application/json: schema: - $ref: '#/components/schemas/requestError' + $ref: '#/components/schemas/mfaRequestError' internalServerError: description: Internal Server Error headers: {} content: application/json: schema: - $ref: '#/components/schemas/requestError' + $ref: '#/components/schemas/mfaRequestError' parameters: accountId: name: accountId From 6a8be7bc469616930609073dc6f6e26ab139ae28 Mon Sep 17 00:00:00 2001 From: DX-Bandwidth Date: Mon, 13 Jun 2022 16:15:34 +0000 Subject: [PATCH 08/17] Add Code Snippets to Spec Files --- site/specs/multi-factor-auth.yml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/site/specs/multi-factor-auth.yml b/site/specs/multi-factor-auth.yml index e591dd760..6cbc3a59d 100644 --- a/site/specs/multi-factor-auth.yml +++ b/site/specs/multi-factor-auth.yml @@ -31,7 +31,6 @@ paths: responses: '200': description: OK - headers: {} content: application/json: schema: @@ -62,7 +61,6 @@ paths: responses: '200': description: OK - headers: {} content: application/json: schema: @@ -93,7 +91,6 @@ paths: responses: '200': description: OK - headers: {} content: application/json: schema: @@ -135,7 +132,6 @@ components: An optional field to denote what scope or action the 2fa code is addressing. If not supplied, defaults to "2FA". maxLength: 25 - default: 2FA example: 2FA message: type: string @@ -168,22 +164,23 @@ components: properties: callId: type: string + description: Programmable Voice API Call ID + example: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 messagingCodeResponse: type: object properties: messageId: type: string + description: Messaging API Message ID + example: 9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6 verifyRequestSchema: type: object properties: to: type: string description: The phone number to send the 2fa code to. + pattern: ^\+[1-9]\d{1,14}$ example: '+19195551234' - applicationId: - type: string - description: The application unique ID, obtained from Bandwidth. - example: 66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1 scope: type: string description: >- @@ -197,14 +194,17 @@ components: this to 3 minutes, it will mean any code generated within the last 3 minutes are still valid. The valid range for expiration time is between 0 and 15 minutes, exclusively and inclusively, respectively. + minimum: 1 + maximum: 15 example: 3 code: type: string description: The generated 2fa code to check if valid + minLength: 4 + maxLength: 8 example: '123456' required: - to - - applicationId - expirationTimeInMinutes - code verifyCodeResponse: @@ -212,15 +212,19 @@ components: properties: valid: type: boolean + description: Whether or not the supplied code is valid + example: true mfaRequestError: type: object properties: error: type: string description: A message describing the error with your request. + example: 400 Request is malformed or invalid requestId: type: string description: The associated requestId from AWS. + example: 354cc8a3-6701-461e-8fa7-8671703dd898 mfaUnauthorizedRequestError: type: object properties: From bbca63382fb0ee2f17cd674207c97548b1465e5f Mon Sep 17 00:00:00 2001 From: DX-Bandwidth Date: Tue, 14 Jun 2022 18:16:58 +0000 Subject: [PATCH 09/17] Add Code Snippets to Spec Files --- site/specs/multi-factor-auth.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/site/specs/multi-factor-auth.yml b/site/specs/multi-factor-auth.yml index 6cbc3a59d..9d2ef168e 100644 --- a/site/specs/multi-factor-auth.yml +++ b/site/specs/multi-factor-auth.yml @@ -112,12 +112,12 @@ components: properties: to: type: string - description: The phone number to send the 2fa code to. + description: The phone number to send the mfa code to. pattern: ^\+[1-9]\d{1,14}$ example: '+19195551234' from: type: string - description: The application phone number, the sender of the 2fa code. + description: The application phone number, the sender of the mfa code. pattern: ^\+[1-9]\d{1,14}$ maxLength: 32 example: '+19195554321' @@ -129,26 +129,26 @@ components: scope: type: string description: >- - An optional field to denote what scope or action the 2fa code is + An optional field to denote what scope or action the mfa code is addressing. If not supplied, defaults to "2FA". maxLength: 25 example: 2FA message: type: string description: >- - The message format of the 2fa code. There are three values that the + The message format of the mfa code. There are three values that the system will replace "{CODE}", "{NAME}", "{SCOPE}". The "{SCOPE}" and "{NAME} value template are optional, while "{CODE}" must be supplied. As the name would suggest, code will be replace with the - actual 2fa code. Name is replaced with the application name, - configured during provisioning of 2fa. The scope value is the same + actual mfa code. Name is replaced with the application name, + configured during provisioning of mfa. The scope value is the same value sent during the call and partitioned by the server. maxLength: 2048 example: Your temporary {NAME} {SCOPE} code is {CODE} digits: type: integer description: >- - The number of digits for your 2fa code. The valid number ranges + The number of digits for your mfa code. The valid number ranges from 2 to 8, inclusively. minimum: 4 maximum: 8 @@ -178,19 +178,19 @@ components: properties: to: type: string - description: The phone number to send the 2fa code to. + description: The phone number to send the mfa code to. pattern: ^\+[1-9]\d{1,14}$ example: '+19195551234' scope: type: string description: >- - An optional field to denote what scope or action the 2fa code is + An optional field to denote what scope or action the mfa code is addressing. If not supplied, defaults to "2FA". example: 2FA expirationTimeInMinutes: type: number description: >- - The time period, in minutes, to validate the 2fa code. By setting + The time period, in minutes, to validate the mfa code. By setting this to 3 minutes, it will mean any code generated within the last 3 minutes are still valid. The valid range for expiration time is between 0 and 15 minutes, exclusively and inclusively, respectively. @@ -199,7 +199,7 @@ components: example: 3 code: type: string - description: The generated 2fa code to check if valid + description: The generated mfa code to check if valid minLength: 4 maxLength: 8 example: '123456' @@ -288,10 +288,10 @@ components: schema: type: string securitySchemes: - httpBasic: + basicAuth: type: http scheme: basic security: - - httpBasic: [] + - basicAuth: [] tags: - name: MFA From 39ce7dff359adb83e2e36362b32b964f10c84de0 Mon Sep 17 00:00:00 2001 From: DX-Bandwidth Date: Tue, 14 Jun 2022 18:32:32 +0000 Subject: [PATCH 10/17] Add Code Snippets to Spec Files --- site/specs/multi-factor-auth.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/specs/multi-factor-auth.yml b/site/specs/multi-factor-auth.yml index 9d2ef168e..16a788ba6 100644 --- a/site/specs/multi-factor-auth.yml +++ b/site/specs/multi-factor-auth.yml @@ -288,10 +288,10 @@ components: schema: type: string securitySchemes: - basicAuth: + Basic Authentication: type: http scheme: basic security: - - basicAuth: [] + - Basic Authentication: [] tags: - name: MFA From 8bacd015ee4561f1dc086e5cbe392da845930e83 Mon Sep 17 00:00:00 2001 From: DX-Bandwidth Date: Tue, 21 Jun 2022 15:06:17 +0000 Subject: [PATCH 11/17] Add Code Snippets to Spec Files --- site/specs/multi-factor-auth.yml | 110 +++++++++++++++++-------------- 1 file changed, 60 insertions(+), 50 deletions(-) diff --git a/site/specs/multi-factor-auth.yml b/site/specs/multi-factor-auth.yml index 16a788ba6..532e8654f 100644 --- a/site/specs/multi-factor-auth.yml +++ b/site/specs/multi-factor-auth.yml @@ -12,6 +12,7 @@ info: version: 3.0.1 servers: - url: https://mfa.bandwidth.com/api/v1 + description: Production paths: /accounts/{accountId}/code/voice: post: @@ -23,26 +24,18 @@ paths: parameters: - $ref: '#/components/parameters/accountId' requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/codeRequestSchema' - required: true + $ref: '#/components/requestBodies/codeRequest' responses: '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/voiceCodeResponse' + $ref: '#/components/responses/voiceCodeResponse' '400': - $ref: '#/components/responses/badRequestError' + $ref: '#/components/responses/mfaBadRequestError' '401': - $ref: '#/components/responses/unauthorizedError' + $ref: '#/components/responses/mfaUnauthorizedError' '403': - $ref: '#/components/responses/forbiddenError' + $ref: '#/components/responses/mfaForbiddenError' '500': - $ref: '#/components/responses/internalServerError' + $ref: '#/components/responses/mfaInternalServerError' /accounts/{accountId}/code/messaging: post: tags: @@ -53,26 +46,18 @@ paths: parameters: - $ref: '#/components/parameters/accountId' requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/codeRequestSchema' - required: true + $ref: '#/components/requestBodies/codeRequest' responses: '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/messagingCodeResponse' + $ref: '#/components/responses/messagingCodeResponse' '400': - $ref: '#/components/responses/badRequestError' + $ref: '#/components/responses/mfaBadRequestError' '401': - $ref: '#/components/responses/unauthorizedError' + $ref: '#/components/responses/mfaUnauthorizedError' '403': - $ref: '#/components/responses/forbiddenError' + $ref: '#/components/responses/mfaForbiddenError' '500': - $ref: '#/components/responses/internalServerError' + $ref: '#/components/responses/mfaInternalServerError' /accounts/{accountId}/code/verify: post: tags: @@ -83,31 +68,23 @@ paths: parameters: - $ref: '#/components/parameters/accountId' requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/verifyRequestSchema' - required: true + $ref: '#/components/requestBodies/codeVerify' responses: '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/verifyCodeResponse' + $ref: '#/components/responses/verifyCodeResponse' '400': - $ref: '#/components/responses/badRequestError' + $ref: '#/components/responses/mfaBadRequestError' '401': - $ref: '#/components/responses/unauthorizedError' + $ref: '#/components/responses/mfaUnauthorizedError' '403': - $ref: '#/components/responses/forbiddenError' + $ref: '#/components/responses/mfaForbiddenError' '429': - $ref: '#/components/responses/tooManyRequestsError' + $ref: '#/components/responses/mfaTooManyRequestsError' '500': - $ref: '#/components/responses/internalServerError' + $ref: '#/components/responses/mfaInternalServerError' components: schemas: - codeRequestSchema: + codeRequest: type: object properties: to: @@ -173,7 +150,7 @@ components: type: string description: Messaging API Message ID example: 9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6 - verifyRequestSchema: + verifyCodeRequest: type: object properties: to: @@ -242,35 +219,53 @@ components: forbidden. example: Missing Authentication Token responses: - badRequestError: + voiceCodeResponse: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/voiceCodeResponse' + messagingCodeResponse: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/messagingCodeResponse' + verifyCodeResponse: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/verifyCodeResponse' + mfaBadRequestError: description: Bad Request headers: {} content: application/json: schema: $ref: '#/components/schemas/mfaRequestError' - unauthorizedError: + mfaUnauthorizedError: description: Unauthorized headers: {} content: application/json: schema: $ref: '#/components/schemas/mfaUnauthorizedRequestError' - forbiddenError: + mfaForbiddenError: description: Forbidden headers: {} content: application/json: schema: $ref: '#/components/schemas/mfaForbiddenRequestError' - tooManyRequestsError: + mfaTooManyRequestsError: description: Too Many Requests headers: {} content: application/json: schema: $ref: '#/components/schemas/mfaRequestError' - internalServerError: + mfaInternalServerError: description: Internal Server Error headers: {} content: @@ -287,6 +282,21 @@ components: explode: false schema: type: string + requestBodies: + codeRequest: + description: MFA code request body. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/codeRequest' + codeVerify: + description: MFA code verify request body. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/verifyCodeRequest' securitySchemes: Basic Authentication: type: http From 44036dbe52e1c2c6dfe8aba51d2ce1078ae06369 Mon Sep 17 00:00:00 2001 From: DX-Bandwidth Date: Tue, 21 Jun 2022 19:04:35 +0000 Subject: [PATCH 12/17] Add Code Snippets to Spec Files --- site/specs/multi-factor-auth.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/specs/multi-factor-auth.yml b/site/specs/multi-factor-auth.yml index 532e8654f..1256358cb 100644 --- a/site/specs/multi-factor-auth.yml +++ b/site/specs/multi-factor-auth.yml @@ -9,7 +9,7 @@ info: name: Bandwidth Edge Services email: edge-services@bandwidth.com url: https://support.bandwidth.com - version: 3.0.1 + version: 3.1.0 servers: - url: https://mfa.bandwidth.com/api/v1 description: Production From d5609ee295a2713fdacf15ca62869c29b70b749b Mon Sep 17 00:00:00 2001 From: DX-Bandwidth Date: Tue, 21 Jun 2022 19:05:15 +0000 Subject: [PATCH 13/17] Add Code Snippets to Spec Files --- site/specs/multi-factor-auth.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/site/specs/multi-factor-auth.yml b/site/specs/multi-factor-auth.yml index 1256358cb..0c30422d1 100644 --- a/site/specs/multi-factor-auth.yml +++ b/site/specs/multi-factor-auth.yml @@ -1,9 +1,11 @@ openapi: 3.0.3 info: - title: MultiFactorAuth + title: Multi-Factor Authentication description: |- Bandwidth's Two-Factor Authentication service + ## Base Path + https://mfa.bandwidth.com/api/v1 contact: name: Bandwidth Edge Services From baab68be0cd4799d59ebbebff7e441f19e015388 Mon Sep 17 00:00:00 2001 From: DX-Bandwidth Date: Tue, 21 Jun 2022 19:14:39 +0000 Subject: [PATCH 14/17] Add Code Snippets to Spec Files --- site/specs/multi-factor-auth.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/specs/multi-factor-auth.yml b/site/specs/multi-factor-auth.yml index 0c30422d1..70e48f9e3 100644 --- a/site/specs/multi-factor-auth.yml +++ b/site/specs/multi-factor-auth.yml @@ -8,8 +8,8 @@ info: https://mfa.bandwidth.com/api/v1 contact: - name: Bandwidth Edge Services - email: edge-services@bandwidth.com + name: Bandwidth Support + email: support@bandwidth.com url: https://support.bandwidth.com version: 3.1.0 servers: From ccf65a64abc2ce530e5031fb3a7fbb3bdcf4f52a Mon Sep 17 00:00:00 2001 From: Cameron Koegel Date: Wed, 22 Jun 2022 11:23:01 -0400 Subject: [PATCH 15/17] remove old mfa spec --- site/specs/multiFactorAuth.json | 562 -------------------------------- 1 file changed, 562 deletions(-) delete mode 100644 site/specs/multiFactorAuth.json diff --git a/site/specs/multiFactorAuth.json b/site/specs/multiFactorAuth.json deleted file mode 100644 index ddbc428e0..000000000 --- a/site/specs/multiFactorAuth.json +++ /dev/null @@ -1,562 +0,0 @@ -{ - "openapi": "3.0.0", - "info": { - "title": "MultiFactorAuth", - "description": "Bandwidth's Two-Factor Authentication service\n## Base Path\nhttps://mfa.bandwidth.com/api/v1", - "contact": {}, - "version": "3.0.1", - "x-server-configuration": { - "default-environment": "production", - "default-server": "default", - "environments": [ - { - "name": "production", - "servers": [ - { - "name": "default", - "url": "https://mfa.bandwidth.com/api/v1" - } - ] - }, - { - "name": "custom", - "servers": [ - { - "name": "default", - "url": "{base_url}" - } - ] - } - ], - "parameters": [ - { - "name": "base_url", - "description": "", - "type": "string", - "example": "https://www.example.com" - } - ] - } - }, - "servers": [ - { - "url": "https://mfa.bandwidth.com/api/v1", - "variables": {} - } - ], - "paths": { - "/accounts/{accountId}/code/voice": { - "post": { - "summary": "Voice Authentication", - "description": "Multi-Factor authentication with Bandwidth Voice services. Allows for a user to send an MFA code via a phone call.", - "tags": [ - "MFA" - ], - "operationId": "voiceTwoFactor", - "parameters": [ - { - "name": "accountId", - "description": "Bandwidth Account ID with Voice service enabled", - "in": "path", - "required": true, - "style": "simple", - "explode": false, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TwoFactorCodeRequestSchema" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "successful operation", - "headers": {}, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TwoFactorVoiceResponse" - } - } - } - }, - "400": { - "description": "If there is any issue with values passed in by the user", - "headers": {}, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorWithRequest" - } - } - } - }, - "401": { - "description": "Authentication is either incorrect or not present", - "headers": {}, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UnauthorizedRequest" - } - } - } - }, - "403": { - "description": "The user is not authorized to access this resource", - "headers": {}, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ForbiddenRequest" - } - } - } - }, - "500": { - "description": "An internal server error occurred", - "headers": {}, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorWithRequest" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://mfa.bandwidth.com/api/v1/accounts/12345/code/voice' \\\n -X POST \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"to\": \"+15553334444\",\n \"from\": \"+15554443333\",\n \"applicationId\": \"1234-asdf\",\n \"scope\": \"scope\",\n \"message\": \"Your temporary {NAME} {SCOPE} code is {CODE}\",\n \"digits\": 5\n }'\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.MultiFactorAuth.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n var applicationId = \"1234-qwer\";\n var to = \"+15553334444\";\n var from = \"+15554443333\";\n var scope = \"sample\";\n var digits = 6;\n var message = \"Your temporary {NAME} {SCOPE} code is {CODE}\";\n\n var client = new BandwidthClient.Builder()\n .MultiFactorAuthBasicAuthCredentials(username, password)\n .Build();\n\n var request = new TwoFactorCodeRequestSchema\n {\n ApplicationId = applicationId,\n To = to,\n From = from,\n Scope = scope,\n Digits = digits,\n Message = message\n };\n\n try\n {\n var response = await client.MultiFactorAuth.MFAController.CreateVoiceTwoFactorAsync(accountId, request);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.multifactorauth.models.TwoFactorCodeRequestSchema;\nimport com.bandwidth.multifactorauth.models.TwoFactorVoiceResponse;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n public static final String APPLICATION_ID = \"1234-qwer\";\n\n public static void main(String[] args) {\n BandwidthClient client = new BandwidthClient.Builder()\n .multiFactorAuthBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n String to = \"+15553334444\";\n String from = \"+15554443333\";\n String scope = \"sample\";\n int digits = 6;\n String message = \"Your temporary {NAME} {SCOPE} code is {CODE}\";\n\n TwoFactorCodeRequestSchema request = new TwoFactorCodeRequestSchema();\n request.setApplicationId(APPLICATION_ID);\n request.setTo(to);\n request.setFrom(from);\n request.setScope(scope);\n request.setDigits(digits);\n request.setMessage(message);\n\n try {\n CompletableFuture> completableFuture = client.getMultiFactorAuthClient().getMFAController().createVoiceTwoFactorAsync(ACCOUNT_ID, request);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, MFAController } from '@bandwidth/mfa';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\nconst BW_VOICE_APPLICATION_ID = \"1234-qwer\";\nconst fromNumber = \"+15554443333\";\nconst toNumber = \"+15553334444\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new MFAController(client);\n\nconst payload = {\n applicationId: BW_VOICE_APPLICATION_ID,\n from: fromNumber,\n to: toNumber,\n scope: 'scope',\n digits: 5,\n message: \"Your temporary {NAME} {SCOPE} code is {CODE}\"\n}\n\nconst voiceTwoFactor = async function() {\n try {\n const response = await controller.voiceTwoFactor(BW_ACCOUNT_ID, payload);\n console.log(JSON.stringify(response, null, 2));\n } catch (error) {\n console.error(error);\n}};\n\nvoiceTwoFactor();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'multiFactorAuthBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$mfaClient = $client->getMultiFactorAuth()->getMFA();\n\n$body = new BandwidthLib\\MultiFactorAuth\\Models\\TwoFactorCodeRequestSchema();\n$body->from = $BW_MFA_NUMBER;\n$body->to = $USER_NUMBER;\n$body->applicationId = $BW_MFA_VOICE_APPLICATION_ID;\n$body->scope = \"scope\";\n$body->digits = 6;\n$body->message = \"Your temporary {NAME} {SCOPE} code is {CODE}\";\n\ntry {\n $mfaClient->createVoiceTwoFactor($BW_ACCOUNT_ID, $body);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.multifactorauth.models.two_factor_code_request_schema import TwoFactorCodeRequestSchema\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\nBW_MFA_VOICE_APPLICATION_ID = \"1234-qwer\"\nBW_MFA_NUMBER = \"+15554443333\"\nUSER_NUMBER = \"+15553334444\"\n\nbandwidth_client = BandwidthClient(\n multi_factor_auth_basic_auth_user_name=BW_USERNAME,\n multi_factor_auth_basic_auth_password=BW_PASSWORD\n)\nauth_client = bandwidth_client.multi_factor_auth_client.mfa\n\nbody = TwoFactorCodeRequestSchema(\n mfrom = BW_MFA_NUMBER,\n to = USER_NUMBER,\n application_id = BW_MFA_VOICE_APPLICATION_ID,\n scope = \"scope\",\n digits = 6,\n message = \"Your temporary {NAME} {SCOPE} code is {CODE}\"\n)\n\ntry:\n auth_client.create_voice_two_factor(BW_ACCOUNT_ID, body)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::MultiFactorAuth\n\nbandwidth_client = Bandwidth::Client.new(\n multi_factor_auth_basic_auth_user_name: \"api-username\",\n multi_factor_auth_basic_auth_password: \"api-password\"\n)\nauth_client = bandwidth_client.multi_factor_auth_client.mfa\n\nbody = TwoFactorCodeRequestSchema.new\nbody.application_id = \"1234-qwer\"\nbody.to = \"+15553334444\"\nbody.from = \"+15554443333\"\nbody.digits = 6\nbody.scope = \"scope\"\nbody.message = \"Your temporary {NAME} {SCOPE} code is {CODE}\"\nbegin\n result = auth_client.create_voice_two_factor(\"12345\", body)\n puts 'callId: ' + result.data.call_id\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] - } - }, - "/accounts/{accountId}/code/messaging": { - "post": { - "summary": "Messaging Authentication", - "description": "Multi-Factor authentication with Bandwidth Messaging services. Allows a user to send an MFA code via a text message (SMS).", - "tags": [ - "MFA" - ], - "operationId": "messagingTwoFactor", - "parameters": [ - { - "name": "accountId", - "description": "Bandwidth Account ID with Messaging service enabled", - "in": "path", - "required": true, - "style": "simple", - "explode": false, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TwoFactorCodeRequestSchema" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "successful operation", - "headers": {}, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TwoFactorMessagingResponse" - } - } - } - }, - "400": { - "description": "If there is any issue with values passed in by the user", - "headers": {}, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorWithRequest" - } - } - } - }, - "401": { - "description": "Authentication is either incorrect or not present", - "headers": {}, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UnauthorizedRequest" - } - } - } - }, - "403": { - "description": "The user is not authorized to access this resource", - "headers": {}, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ForbiddenRequest" - } - } - } - }, - "500": { - "description": "An internal server error occurred", - "headers": {}, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorWithRequest" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://mfa.bandwidth.com/api/v1/accounts/12345/code/messaging' \\\n -X POST \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"to\": \"+15553334444\",\n \"from\": \"+15554443333\",\n \"applicationId\": \"1234-asdf\",\n \"scope\": \"scope\",\n \"message\": \"Your temporary {NAME} {SCOPE} code is {CODE}\",\n \"digits\": 6\n }'\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.MultiFactorAuth.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n var applicationId = \"1234-asdf\";\n var to = \"+15553334444\";\n var from = \"+15554443333\";\n var scope = \"sample\";\n var digits = 6;\n var message = \"Your temporary {NAME} {SCOPE} code is {CODE}\";\n\n var client = new BandwidthClient.Builder()\n .MultiFactorAuthBasicAuthCredentials(username, password)\n .Build();\n\n var request = new TwoFactorCodeRequestSchema\n {\n ApplicationId = applicationId,\n To = to,\n From = from,\n Scope = scope,\n Digits = digits,\n Message = message\n };\n\n try\n {\n var response = await client.MultiFactorAuth.MFAController.CreateMessagingTwoFactorAsync(accountId, request);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.multifactorauth.models.TwoFactorCodeRequestSchema;\nimport com.bandwidth.multifactorauth.models.TwoFactorMessagingResponse;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n public static final String APPLICATION_ID = \"1234-asdf\";\n\n public static void main(String[] args) {\n BandwidthClient client = new BandwidthClient.Builder()\n .multiFactorAuthBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n String to = \"+15553334444\";\n String from = \"+15554443333\";\n String scope = \"sample\";\n int digits = 6;\n String message = \"Your temporary {NAME} {SCOPE} code is {CODE}\";\n\n TwoFactorCodeRequestSchema request = new TwoFactorCodeRequestSchema();\n request.setApplicationId(APPLICATION_ID);\n request.setTo(to);\n request.setFrom(from);\n request.setScope(scope);\n request.setDigits(digits);\n request.setMessage(message);\n\n try {\n CompletableFuture> completableFuture = client.getMultiFactorAuthClient().getMFAController().createMessagingTwoFactorAsync(ACCOUNT_ID, request);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, MFAController } from '@bandwidth/mfa';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\nconst BW_MESSAGING_APPLICATION_ID = \"1234-asdf\";\nconst fromNumber = \"+15554443333\";\nconst toNumber = \"+15553334444\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new MFAController(client);\n\nconst payload = {\n applicationId: BW_MESSAGING_APPLICATION_ID,\n from: fromNumber,\n to: toNumber,\n scope: 'scope',\n digits: 6,\n message: \"Your temporary {NAME} {SCOPE} code is {CODE}\"\n}\n\nconst msgTwoFactor = async function() {\n try {\n const response = await controller.messagingTwoFactor(BW_ACCOUNT_ID, payload);\n console.log(JSON.stringify(response, null, 2));\n } catch (error) {\n console.error(error);\n}};\n\nmsgTwoFactor();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'multiFactorAuthBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$mfaClient = $client->getMultiFactorAuth()->getMFA();\n\n$body = new BandwidthLib\\MultiFactorAuth\\Models\\TwoFactorCodeRequestSchema();\n$body->from = $BW_MFA_NUMBER;\n$body->to = $USER_NUMBER;\n$body->applicationId = $BW_MFA_MESSAGING_APPLICATION_ID;\n$body->scope = \"scope\";\n$body->digits = 6;\n$body->message = \"Your temporary {NAME} {SCOPE} code is {CODE}\";\n\ntry {\n $mfaClient->createMessagingTwoFactor($BW_ACCOUNT_ID, $body);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.multifactorauth.models.two_factor_code_request_schema import TwoFactorCodeRequestSchema\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\nBW_MFA_MESSAGING_APPLICATION_ID = \"1234-asdf\"\nBW_MFA_NUMBER = \"+15554443333\"\nUSER_NUMBER = \"+15553334444\"\n\nbandwidth_client = BandwidthClient(\n multi_factor_auth_basic_auth_user_name=BW_USERNAME,\n multi_factor_auth_basic_auth_password=BW_PASSWORD\n)\nauth_client = bandwidth_client.multi_factor_auth_client.mfa\n\nbody = TwoFactorCodeRequestSchema(\n mfrom = BW_MFA_NUMBER,\n to = USER_NUMBER,\n application_id = BW_MFA_MESSAGING_APPLICATION_ID,\n scope = \"scope\",\n digits = 6,\n message = \"Your temporary {NAME} {SCOPE} code is {CODE}\"\n)\ntry:\n auth_client.create_messaging_two_factor(BW_ACCOUNT_ID, body)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::MultiFactorAuth\n\nbandwidth_client = Bandwidth::Client.new(\n multi_factor_auth_basic_auth_user_name: \"api-username\",\n multi_factor_auth_basic_auth_password: \"api-password\"\n)\nauth_client = bandwidth_client.multi_factor_auth_client.mfa\n\nbody = TwoFactorCodeRequestSchema.new\nbody.application_id = \"1234-asdf\"\nbody.to = \"+15553334444\"\nbody.from = \"+15554443333\"\nbody.digits = 6\nbody.scope = \"scope\"\nbody.message = \"Your temporary {NAME} {SCOPE} code is {CODE}\"\nbegin\n result = auth_client.create_messaging_two_factor(\"12345\", body)\n puts 'messageId: ' + result.data.message_id\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] - } - }, - "/accounts/{accountId}/code/verify": { - "post": { - "summary": "Verify Authentication Code", - "description": "Allows a user to verify an MFA code.", - "tags": [ - "MFA" - ], - "operationId": "verifyTwoFactor", - "parameters": [ - { - "name": "accountId", - "description": "Bandwidth Account ID with Two-Factor enabled", - "in": "path", - "required": true, - "style": "simple", - "explode": false, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TwoFactorVerifyRequestSchema" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "successful operation", - "headers": {}, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TwoFactorVerifyCodeResponse" - } - } - } - }, - "400": { - "description": "If there is any issue with values passed in by the user", - "headers": {}, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorWithRequest" - } - } - } - }, - "401": { - "description": "Authentication is either incorrect or not present", - "headers": {}, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UnauthorizedRequest" - } - } - } - }, - "403": { - "description": "The user is not authorized to access this resource", - "headers": {}, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ForbiddenRequest" - } - } - } - }, - "429": { - "description": "The user has made too many bad requests and is temporarily locked out", - "headers": {}, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorWithRequest" - } - } - } - }, - "500": { - "description": "An internal server error occurred", - "headers": {}, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorWithRequest" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://mfa.bandwidth.com/api/v1/accounts/12345/code/verify' \\\n -X POST \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"to\": \"+15553334444\",\n \"applicationId\": \"1234-asdf\",\n \"scope\": \"scope\",\n \"expirationTimeInMinutes\": 3,\n \"code\": \"123456\"\n }'\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.MultiFactorAuth.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n var applicationId = \"1234-asdf\";\n var to = \"+15553334444\";\n var scope = \"sample\";\n var code = \"159193\";\n var expirationTimeInMinutes = 3;\n\n var client = new BandwidthClient.Builder()\n .MultiFactorAuthBasicAuthCredentials(username, password)\n .Build();\n\n var request = new TwoFactorVerifyRequestSchema\n {\n ApplicationId = applicationId,\n To = to,\n Scope = scope,\n Code = code,\n ExpirationTimeInMinutes = expirationTimeInMinutes\n };\n\n try\n {\n var response = await client.MultiFactorAuth.MFAController.CreateVerifyTwoFactorAsync(accountId, request);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.multifactorauth.models.TwoFactorVerifyCodeResponse;\nimport com.bandwidth.multifactorauth.models.TwoFactorVerifyRequestSchema;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n public static final String APPLICATION_ID = \"1234-qwer\";\n\n public static void main(String[] args) {\n BandwidthClient client = new BandwidthClient.Builder()\n .multiFactorAuthBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n String to = \"+15553334444\";\n String scope = \"sample\";\n String code = \"159193\";\n int expirationTimeInMinutes = 3;\n\n TwoFactorVerifyRequestSchema request = new TwoFactorVerifyRequestSchema();\n request.setApplicationId(APPLICATION_ID);\n request.setTo(to);\n request.setScope(scope);\n request.setCode(code);\n request.setExpirationTimeInMinutes(expirationTimeInMinutes);\n\n try {\n CompletableFuture> completableFuture = client.getMultiFactorAuthClient().getMFAController().createVerifyTwoFactorAsync(ACCOUNT_ID, request);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, MFAController } from '@bandwidth/mfa';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\nconst BW_MESSAGING_APPLICATION_ID = \"1234-qwer\";\nconst toNumber = \"+15553334444\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new MFAController(client);\n\nconst payload = {\n applicationId: BW_MESSAGING_APPLICATION_ID,\n to: toNumber,\n code: \"12345\",\n scope: \"scope\",\n expirationTimeInMinutes: 3,\n code: \"123456\"\n}\n\nconst verifyTwoFactor = async function() {\n try {\n const response = await controller.verifyTwoFactor(BW_ACCOUNT_ID, payload);\n console.log(JSON.stringify(response, null, 2));\n } catch (error) {\n console.error(error);\n}};\n\nverifyTwoFactor();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'multiFactorAuthBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$mfaClient = $client->getMultiFactorAuth()->getMFA();\n\n$body = new BandwidthLib\\MultiFactorAuth\\Models\\TwoFactorVerifyRequestSchema();\n$body->from = $BW_MFA_NUMBER;\n$body->to = $USER_NUMBER;\n$body->applicationId = $BW_MFA_MESSAGING_APPLICATION_ID;\n//$body->applicationId = 1234-qwer;\n$body->scope = \"scope\";\n$body->code = \"123456\"; //This is the user's input to validate\n$body->digits = 6;\n$body->expirationTimeInMinutes = 3;\n\ntry {\n $response = $mfaClient->createVerifyTwoFactor($BW_ACCOUNT_ID, $body);\n print_r($response->getResult()->valid);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.multifactorauth.models.two_factor_verify_request_schema import TwoFactorVerifyRequestSchema\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\nBW_MFA_VOICE_APPLICATION_ID = \"1234-qwer\"\n#BW_MFA_MESSAGING_APPLICATION_ID = \"1234-asdf\"\n#Both voice and messaging application IDs can be used. The verify request\n#must have the same ID as the code request.\nUSER_NUMBER = \"+15553334444\"\n\nbandwidth_client = BandwidthClient(\n multi_factor_auth_basic_auth_user_name=BW_USERNAME,\n multi_factor_auth_basic_auth_password=BW_PASSWORD\n)\nauth_client = bandwidth_client.multi_factor_auth_client.mfa\n\nbody = TwoFactorVerifyRequestSchema(\n to = USER_NUMBER,\n application_id = BW_MFA_VOICE_APPLICATION_ID,\n #application_id = MFA_MESSAGING_APPLICATION_ID,\n scope = \"scope\",\n code = \"123456\", #This is the user's input to validate\n expiration_time_in_minutes = 3\n)\n\ntry:\n response = auth_client.create_verify_two_factor(BW_ACCOUNT_ID, body)\n print(response.body.valid)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::MultiFactorAuth\n\nbandwidth_client = Bandwidth::Client.new(\n multi_factor_auth_basic_auth_user_name: \"api-username\",\n multi_factor_auth_basic_auth_password: \"api-password\"\n)\nauth_client = bandwidth_client.multi_factor_auth_client.mfa\n\nbody = TwoFactorVerifyRequestSchema.new\nbody.application_id = \"1234-qwer\"\nbody.to = \"+15553334444\"\nbody.scope = \"scope\"\nbody.code = \"123456\"\nbody.expiration_time_in_minutes = 3\nbegin\n result = auth_client.create_verify_two_factor(\"12345\", body)\n puts 'valid?: ' + result.data.valid\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] - } - } - }, - "components": { - "schemas": { - "TwoFactorCodeRequestSchema": { - "type": "object", - "properties": { - "to": { - "type": "string", - "description": "The phone number to send the 2fa code to." - }, - "from": { - "type": "string", - "description": "The application phone number, the sender of the 2fa code." - }, - "applicationId": { - "type": "string", - "description": "The application unique ID, obtained from Bandwidth." - }, - "scope": { - "type": "string", - "description": "An optional field to denote what scope or action the 2fa code is addressing. If not supplied, defaults to \"2FA\"." - }, - "message": { - "type": "string", - "description": "The message format of the 2fa code. There are three values that the system will replace \"{CODE}\", \"{NAME}\", \"{SCOPE}\". The \"{SCOPE}\" and \"{NAME} value template are optional, while \"{CODE}\" must be supplied. As the name would suggest, code will be replace with the actual 2fa code. Name is replaced with the application name, configured during provisioning of 2fa. The scope value is the same value sent during the call and partitioned by the server." - }, - "digits": { - "type": "number", - "description": "The number of digits for your 2fa code. The valid number ranges from 2 to 8, inclusively." - } - }, - "required": [ - "to", - "from", - "applicationId", - "message", - "digits" - ] - }, - "ErrorWithRequest": { - "type": "object", - "properties": { - "error": { - "type": "string", - "description": "An error message pertaining to what the issue could be" - }, - "requestId": { - "type": "string", - "description": "The associated requestId from AWS" - } - } - }, - "UnauthorizedRequest": { - "type": "object", - "properties": { - "message": { - "type": "string", - "description": "The message containing the reason behind the request being unauthorized" - } - } - }, - "ForbiddenRequest": { - "type": "object", - "properties": { - "Message": { - "type": "string", - "description": "The message containing the reason behind the request being forbidden" - } - } - }, - "TwoFactorVoiceResponse": { - "type": "object", - "properties": { - "callId": { - "type": "string" - } - } - }, - "TwoFactorMessagingResponse": { - "type": "object", - "properties": { - "messageId": { - "type": "string" - } - } - }, - "TwoFactorVerifyRequestSchema": { - "type": "object", - "properties": { - "to": { - "type": "string", - "description": "The phone number to send the 2fa code to." - }, - "applicationId": { - "type": "string", - "description": "The application unique ID, obtained from Bandwidth." - }, - "scope": { - "type": "string", - "description": "An optional field to denote what scope or action the 2fa code is addressing. If not supplied, defaults to \"2FA\"." - }, - "expirationTimeInMinutes": { - "type": "number", - "description": "The time period, in minutes, to validate the 2fa code. By setting this to 3 minutes, it will mean any code generated within the last 3 minutes are still valid. The valid range for expiration time is between 0 and 15 minutes, exclusively and inclusively, respectively." - }, - "code": { - "type": "string", - "description": "The generated 2fa code to check if valid" - } - }, - "required": [ - "to", - "applicationId", - "expirationTimeInMinutes", - "code" - ] - }, - "TwoFactorVerifyCodeResponse": { - "type": "object", - "properties": { - "valid": { - "type": "boolean" - } - } - } - }, - "securitySchemes": { - "httpBasic": { - "type": "http", - "scheme": "basic" - } - } - }, - "security": [ - { - "httpBasic": [] - } - ], - "tags": [ - { - "name": "MFA" - } - ] -} \ No newline at end of file From c9c4fe2dff79b85c7a8f0035a148f148bad06350 Mon Sep 17 00:00:00 2001 From: DX-Bandwidth Date: Mon, 27 Jun 2022 16:19:43 +0000 Subject: [PATCH 16/17] Add Code Snippets to Spec Files --- site/specs/multi-factor-auth.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/site/specs/multi-factor-auth.yml b/site/specs/multi-factor-auth.yml index 70e48f9e3..52c7bcca0 100644 --- a/site/specs/multi-factor-auth.yml +++ b/site/specs/multi-factor-auth.yml @@ -300,10 +300,17 @@ components: schema: $ref: '#/components/schemas/verifyCodeRequest' securitySchemes: - Basic Authentication: + Basic: type: http scheme: basic + description: >- + Basic authentication is a simple authentication scheme built into the + HTTP protocol. To use it, send your HTTP requests with an Authorization + header that contains the word Basic followed by a space and a + base64-encoded string `username:password`. + + Example: `Authorization: Basic ZGVtbZpwQDU1dzByZA==` security: - - Basic Authentication: [] + - Basic: [] tags: - name: MFA From 0702d51c3c560b2d81f79f13de0a715c49c6aaf9 Mon Sep 17 00:00:00 2001 From: DX-Bandwidth Date: Thu, 30 Jun 2022 19:24:27 +0000 Subject: [PATCH 17/17] Add Code Snippets to Spec Files --- site/specs/messaging.json | 192 +------ site/specs/multi-factor-auth.yml | 855 +++++++++++++++++++++++++++++- site/specs/phoneNumberLookup.json | 56 +- site/specs/voice.json | 288 +--------- site/specs/webRtc.json | 352 +----------- 5 files changed, 878 insertions(+), 865 deletions(-) diff --git a/site/specs/messaging.json b/site/specs/messaging.json index 93df8ae0b..cf19f9f4c 100644 --- a/site/specs/messaging.json +++ b/site/specs/messaging.json @@ -120,37 +120,7 @@ "$ref": "#/components/responses/TooManyRequests" } }, - "deprecated": false, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://messaging.bandwidth.com/api/v2/users/12345/media' \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.Messaging.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var client = new BandwidthClient.Builder()\n .MessagingBasicAuthCredentials(username, password)\n .Build();\n\n try\n {\n var response = await client.Messaging.APIController.ListMediaAsync(accountId);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.messaging.models.Media;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\nimport java.util.List;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n BandwidthClient client = new BandwidthClient.Builder()\n .messagingBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n try {\n CompletableFuture>> completableFuture = client.getMessagingClient().getAPIController().listMediaAsync(ACCOUNT_ID, null);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/messaging';\nimport * as fs from 'fs';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst listMedia = async function() {\n try {\n const response = await controller.listMedia(BW_ACCOUNT_ID);\n console.log(response.result)\n } catch (error) {\n console.error(error);\n}};\n\nlistMedia();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'messagingBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$messagingClient = $client->getMessaging()->getClient();\n\ntry {\n $response = $messagingClient->listMedia($BW_ACCOUNT_ID);\n if (count($response->getResult()) > 0) {\n print_r($response->getResult()[0]->mediaName);\n }\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n messaging_basic_auth_user_name=BW_USERNAME,\n messaging_basic_auth_password=BW_PASSWORD\n)\nmessaging_client = bandwidth_client.messaging_client.client\n\ntry:\n response = messaging_client.list_media(BW_ACCOUNT_ID)\n print(response.body)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::Messaging\n\nbandwidth_client = Bandwidth::Client.new(\n messaging_basic_auth_user_name: \"api-username\",\n messaging_basic_auth_password: \"api-password\"\n)\nmessaging_client = bandwidth_client.messaging_client.client\n\nbegin\n media = messaging_client.list_media(\"12345\")\n media.data.each { |item|\n puts item.media_name\n }\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + "deprecated": false } }, "/users/{accountId}/media/{mediaId}": { @@ -221,37 +191,7 @@ "$ref": "#/components/responses/TooManyRequests" } }, - "deprecated": false, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://messaging.bandwidth.com/api/v2/users/12345/media/media-id-123' \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.Messaging.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var client = new BandwidthClient.Builder()\n .MessagingBasicAuthCredentials(username, password)\n .Build();\n\n var mediaId = \"media-id-123\";\n\n try\n {\n var response = await client.Messaging.APIController.GetMediaAsync(accountId, mediaId);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\nimport java.io.InputStream;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n String mediaId = \"media-id-123\";\n\n BandwidthClient client = new BandwidthClient.Builder()\n .messagingBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n try {\n CompletableFuture> completableFuture = client.getMessagingClient().getAPIController().getMediaAsync(ACCOUNT_ID, mediaId);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/messaging';\nimport * as fs from 'fs';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\nconst mediaId = \"media-id-123.pdf\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst getMedia = async function() {\n try {\n const response = await controller.getMedia(BW_ACCOUNT_ID, mediaId);\n const chunks = [];\n for await (let chunk of response.result) {\n chunks.push(chunk);\n }\n fs.writeFileSync('file-to-write.pdf', chunks[0], 'binary');\n } catch (error) {\n console.error(error);\n}};\n\ngetMedia();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'messagingBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$messagingClient = $client->getMessaging()->getClient();\n\n$mediaFileName = \"media-id-123\";\n\ntry {\n $response = $messagingClient->getMedia($BW_ACCOUNT_ID, $mediaFileName);\n $downloadedMediaFile = $response->getResult();\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\n \nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n messaging_basic_auth_user_name=BW_USERNAME,\n messaging_basic_auth_password=BW_PASSWORD\n)\nmessaging_client = bandwidth_client.messaging_client.client\n\nmedia_file_name = 'media-id-123'\n\ntry:\n response = messaging_client.get_media(BW_ACCOUNT_ID, media_file_name)\n downloaded_media_file = response.body\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::Messaging\n\nbandwidth_client = Bandwidth::Client.new(\n messaging_basic_auth_user_name: \"api-username\",\n messaging_basic_auth_password: \"api-password\"\n)\nmessaging_client = bandwidth_client.messaging_client.client\n\nbegin\n downloaded_media = messaging_client.get_media(\"12345\", ENV['MEDIA_ID'])\n f = File.open(\"file_to_write\", \"wb\")\n f.puts(downloaded_media.data)\n f.close()\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + "deprecated": false }, "put": { "tags": [ @@ -345,37 +285,7 @@ "$ref": "#/components/responses/TooManyRequests" } }, - "deprecated": false, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://messaging.bandwidth.com/api/v2/users/12345/media/media-id-123' \\\n -X PUT \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.IO;\nusing System.Text;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.Http.Client;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var client = new BandwidthClient.Builder()\n .MessagingBasicAuthCredentials(username, password)\n .Build();\n\n var mediaId = \"media-id-123\";\n \n var content = \"Hello world\";\n var contentType = \"text/plain\";\n\n var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(content));\n var fileStreamInfo = new FileStreamInfo(memoryStream);\n\n try\n {\n await client.Messaging.APIController.UploadMediaAsync(accountId, mediaId, fileStreamInfo, contentType);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.utilities.FileWrapper;\n\nimport java.io.File;\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n BandwidthClient client = new BandwidthClient.Builder()\n .messagingBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n String mediaId = \"media-id-123\";\n FileWrapper fileWrapper = new FileWrapper(new File(\"/path/to/file\"));\n\n try {\n CompletableFuture> completableFuture = client.getMessagingClient().getAPIController().uploadMediaAsync(ACCOUNT_ID, mediaId, fileWrapper, \"content/type\", \"no-cache\");\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController, Environment } from '@bandwidth/messaging';\nimport * as fs from 'fs';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\nconst mediaId = \"abc123.pdf\";\nconst contentType = \"application/octet-stream\";\nconst cacheControl = \"no-cache\";\nconst contents = Buffer.alloc(8); // Any binary string will work for the upload. This includes file contents\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD,\n});\n\nconst controller = new ApiController(client);\n\nconst uploadMedia = async function() {\n try {\n const response = await controller.uploadMedia(BW_ACCOUNT_ID, mediaId, contents, contentType, cacheControl);\n console.log(response.statusCode)\n } catch (error) {\n console.error(error);\n}};\n\nuploadMedia();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'messagingBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$messagingClient = $client->getMessaging()->getClient();\n\n$mediaFileName = \"sample_file_name\";\n$mediaFile = \"12345\"; //Any binary string will work for the upload. This includes file contents\n\ntry {\n $messagingClient->uploadMedia($BW_ACCOUNT_ID, $mediaFileName, $mediaFile);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n messaging_basic_auth_user_name=BW_USERNAME,\n messaging_basic_auth_password=BW_PASSWORD\n)\nmessaging_client = bandwidth_client.messaging_client.client\n\nmedia_file_name = 'sample_file_name'\nmedia_file = b'12345' #Any binary string will work for the upload. This includes file contents\n\ntry:\n messaging_client.upload_media(BW_ACCOUNT_ID, media_file_name, media_file)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::Messaging\n\nbandwidth_client = Bandwidth::Client.new(\n messaging_basic_auth_user_name: \"api-username\",\n messaging_basic_auth_password: \"api-password\"\n)\nmessaging_client = bandwidth_client.messaging_client.client\n\nbegin\n #f = File.open(\"some_file\", \"rb\")\n #file_content = f.read\n file_content = \"12345\"\n messaging_client.upload_media(\n \"12345\",\n ENV['MEDIA_ID'],\n file_content,\n :content_type => \"application/octet-stream\",\n :cache_control => \"no-cache\"\n )\n f.close()\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + "deprecated": false }, "delete": { "tags": [ @@ -435,37 +345,7 @@ "$ref": "#/components/responses/TooManyRequests" } }, - "deprecated": false, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://messaging.bandwidth.com/api/v2/users/12345/media/media-id-123' \\\n -X DELETE \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.Messaging.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var client = new BandwidthClient.Builder()\n .MessagingBasicAuthCredentials(username, password)\n .Build();\n\n var mediaId = \"media-id-123\";\n\n try\n {\n await client.Messaging.APIController.DeleteMediaAsync(accountId, mediaId);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.messaging.models.BandwidthMessage;\nimport com.bandwidth.messaging.models.MessageRequest;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\nimport java.util.Collections;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n String mediaId = \"media-id-123\";\n\n BandwidthClient client = new BandwidthClient.Builder()\n .messagingBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n try {\n CompletableFuture> completableFuture = client.getMessagingClient().getAPIController().deleteMediaAsync(ACCOUNT_ID, mediaId);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/messaging';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\nconst mediaId = 'abc12345-6def-abc1-2345-6defabc123451.mp3';\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst deleteMedia = async function() {\n try {\n const response = await controller.deleteMedia(BW_ACCOUNT_ID, mediaId);\n console.log(response.statusCode);\n } catch (error) {\n console.error(error);\n}};\n\ndeleteMedia();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'messagingBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$messagingClient = $client->getMessaging()->getClient();\n\n$mediaId = \"m-1234\";\n\ntry {\n $messagingClient->deleteMedia($BW_ACCOUNT_ID, $mediaId);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n messaging_basic_auth_user_name=BW_USERNAME,\n messaging_basic_auth_password=BW_PASSWORD\n)\nmessaging_client = bandwidth_client.messaging_client.client\n\nmedia_id = \"m-1234\"\n\ntry:\n messaging_client.delete_media(BW_ACCOUNT_ID, media_id)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::Messaging\n\nbandwidth_client = Bandwidth::Client.new(\n messaging_basic_auth_user_name: \"api-username\",\n messaging_basic_auth_password: \"api-password\"\n)\nmessaging_client = bandwidth_client.messaging_client.client\n\nbegin\n messaging_client.delete_media(\"12345\", ENV['MEDIA_ID'])\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + "deprecated": false } }, "/users/{accountId}/messages": { @@ -649,37 +529,7 @@ "$ref": "#/components/responses/TooManyRequests" } }, - "deprecated": false, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://messaging.bandwidth.com/api/v2/users/12345/messages?sourceTn=+15554443333' \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.Messaging.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n var bandwidthNumber = \"+15554443333\";\n\n var client = new BandwidthClient.Builder()\n .MessagingBasicAuthCredentials(username, password)\n .Build();\n\n try\n {\n var response = await client.Messaging.APIController.GetMessagesAsync(accountId, sourceTn: bandwidthNumber);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.messaging.models.BandwidthMessagesList;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n String bandwidthNumber = \"+15554443333\";\n\n BandwidthClient client = new BandwidthClient.Builder()\n .messagingBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n try {\n CompletableFuture> completableFuture = client.getMessagingClient().getAPIController().getMessagesAsync(ACCOUNT_ID, null, bandwidthNumber, null, null, null, null, null, null, null);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/messaging';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\nconst messageId = \"1589228074636lm4k2je7j7jklbn2\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst getMessage = async function() {\n try {\n const response = await controller.getMessages(BW_ACCOUNT_ID, messageId);\n console.log(response.body)\n } catch (error) {\n console.error(error);\n}};\n\ngetMessage();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'messagingBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$messagingClient = $client->getMessaging()->getClient();\n\ntry {\n $response = $messagingClient->getMessages($BW_ACCOUNT_ID, $sourceTn = $BW_NUMBER);\n print_r($response->getResult()->totalCount);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n messaging_basic_auth_user_name=BW_USERNAME,\n messaging_basic_auth_password=BW_PASSWORD\n)\nmessaging_client = bandwidth_client.messaging_client.client\n\nsource_tn = \"+15554443333\"\n\ntry:\n response = messaging_client.get_messages(BW_ACCOUNT_ID, source_tn=source_tn)\n print(response.body.total_count)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::Messaging\n\nbandwidth_client = Bandwidth::Client.new(\n messaging_basic_auth_user_name: \"api-username\",\n messaging_basic_auth_password: \"api-password\"\n)\nmessaging_client = bandwidth_client.messaging_client.client\n\nbegin\n result = messaging_client.get_messages(\"12345\", :source_tn => \"+15554443333\")\n puts result.data.total_count\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + "deprecated": false }, "post": { "tags": [ @@ -743,37 +593,7 @@ "$ref": "#/components/responses/TooManyRequests" } }, - "deprecated": false, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://messaging.bandwidth.com/api/v2/users/12345/messages' \\\n -X POST \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"applicationId\": \"$BW_ACCOUNT_ID\",\n \"to\": [\n \"+15553334444\",\n \"+15552223333\"\n ],\n \"from\": \"+15554443333\",\n \"text\": \"Hello World!\",\n \"media\": [\n \"https://dev.bandwidth.com/images/bandwidth-logo.png\",\n \"https://dev.bandwidth.com/images/github_logo.png\"\n ],\n \"tag\": \"custom string\",\n \"priority\": \"default\"\n }'\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.Messaging.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n var applicationId = \"1234-asdf\";\n var bandwidthNumber = \"+15554443333\";\n var userNumber = \"+15553334444\";\n\n var client = new BandwidthClient.Builder()\n .MessagingBasicAuthCredentials(username, password)\n .Build();\n\n var request = new MessageRequest()\n {\n ApplicationId = applicationId,\n To = new List { userNumber },\n From = bandwidthNumber,\n Text = \"Hello world\"\n };\n\n try\n {\n var response = await client.Messaging.APIController.CreateMessageAsync(accountId, request);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.messaging.models.BandwidthMessage;\nimport com.bandwidth.messaging.models.MessageRequest;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\nimport java.util.Collections;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n String messagingApplicationId = \"1234-asdf\";\n String to = \"+15553334444\";\n String from = \"+15554443333\";\n\n BandwidthClient client = new BandwidthClient.Builder()\n .messagingBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n MessageRequest request = new MessageRequest();\n request.setApplicationId(messagingApplicationId);\n request.setTo(Collections.singletonList(to));\n request.setFrom(from);\n request.setText(\"Hello world\");\n\n try {\n CompletableFuture> completableFuture = client.getMessagingClient().getAPIController().createMessageAsync(ACCOUNT_ID, request);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/messaging';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\nconst BW_MESSAGING_APPLICATION_ID = \"1234-asdf\";\nconst BW_NUMBER = \"+15554443333\";\nconst USER_NUMBER = \"+15553334444\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\n\nconst sendMessage = async function() {\n try {\n const response = await controller.createMessage(accountId, {\n applicationId: BW_MESSAGING_APPLICATION_ID,\n to: [USER_NUMBER],\n from: BW_NUMBER,\n text: 'The quick brown fox jumps over the lazy dog.'\n });\n console.log(response.body);\n } catch (error) {\n console.error(error);\n}};\n\nsendMessage();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'messagingBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$messagingClient = $client->getMessaging()->getClient();\n\n$body = new BandwidthLib\\Messaging\\Models\\MessageRequest();\n$body->from = $BW_NUMBER;\n$body->to = array($USER_NUMBER);\n$body->applicationId = $BW_MESSAGING_APPLICATION_ID;\n$body->text = \"Hello world\";\n\ntry {\n $response = $messagingClient->createMessage($BW_ACCOUNT_ID, $body);\n print_r($response->getResult()->id);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.messaging.models.message_request import MessageRequest\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\nBW_MESSAGING_APPLICATION_ID = \"1234-asdf\"\nBW_NUMBER = \"+15554443333\"\nUSER_NUMBER = \"+15553334444\"\n\nbandwidth_client = BandwidthClient(\n messaging_basic_auth_user_name=BW_USERNAME,\n messaging_basic_auth_password=BW_PASSWORD\n)\nmessaging_client = bandwidth_client.messaging_client.client\n\nbody = MessageRequest()\nbody.application_id = BW_MESSAGING_APPLICATION_ID\nbody.to = [USER_NUMBER]\nbody.mfrom = BW_NUMBER\nbody.text = \"Hello world\"\ntry:\n response = messaging_client.create_message(BW_ACCOUNT_ID, body)\n print(response.body.id)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::Messaging\n\nbandwidth_client = Bandwidth::Client.new(\n messaging_basic_auth_user_name: \"api-username\",\n messaging_basic_auth_password: \"api-password\"\n)\nmessaging_client = bandwidth_client.messaging_client.client\n\nbody = MessageRequest.new\nbody.application_id = \"1234-asdf\"\nbody.to = [\"+15553334444\"]\nbody.from = \"+15554443333\"\nbody.text = 'Hey, check this out!'\nbody.tag = '{\"test\": \"message\"}'\nbegin\n result = messaging_client.create_message(\"12345\", body)\n puts 'messageId: ' + result.data.id\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + "deprecated": false } } }, diff --git a/site/specs/multi-factor-auth.yml b/site/specs/multi-factor-auth.yml index 52c7bcca0..cc9721da6 100644 --- a/site/specs/multi-factor-auth.yml +++ b/site/specs/multi-factor-auth.yml @@ -38,6 +38,283 @@ paths: $ref: '#/components/responses/mfaForbiddenError' '500': $ref: '#/components/responses/mfaInternalServerError' + x-codeSamples: + - lang: cURL + source: | + curl 'https://mfa.bandwidth.com/api/v1/accounts/12345/code/voice' \ + -X POST \ + -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \ + -H 'Content-Type: application/json' \ + -d '{ + "to": "+15553334444", + "from": "+15554443333", + "applicationId": "1234-asdf", + "scope": "scope", + "message": "Your temporary {NAME} {SCOPE} code is {CODE}", + "digits": 5 + }' + - lang: C# + source: | + using System; + using System.Threading.Tasks; + using Bandwidth.Standard; + using Bandwidth.Standard.Exceptions; + using Bandwidth.Standard.MultiFactorAuth.Models; + + class Program + { + static async Task Main(string[] args) + { + var username = "api-username"; + var password = "api-pasword"; + var accountId = "12345"; + var applicationId = "1234-qwer"; + var to = "+15553334444"; + var from = "+15554443333"; + var scope = "sample"; + var digits = 6; + var message = "Your temporary {NAME} {SCOPE} code is {CODE}"; + + var client = new BandwidthClient.Builder() + .MultiFactorAuthBasicAuthCredentials(username, password) + .Build(); + + var request = new TwoFactorCodeRequestSchema + { + ApplicationId = applicationId, + To = to, + From = from, + Scope = scope, + Digits = digits, + Message = message + }; + + try + { + var response = await client.MultiFactorAuth.MFAController.CreateVoiceTwoFactorAsync(accountId, request); + Console.WriteLine(response.Data); + } + catch (ApiException e) + { + Console.WriteLine(e.Message); + } + } + } + - lang: Java + source: > + import com.bandwidth.BandwidthClient; + + import com.bandwidth.http.response.ApiResponse; + + import + com.bandwidth.multifactorauth.models.TwoFactorCodeRequestSchema; + + import com.bandwidth.multifactorauth.models.TwoFactorVoiceResponse; + + + import java.util.concurrent.CompletableFuture; + + import java.util.concurrent.ExecutionException; + + + public class Sample { + public static final String USERNAME = "api-username"; + public static final String PASSWORD = "api-password"; + public static final String ACCOUNT_ID = "12345"; + public static final String APPLICATION_ID = "1234-qwer"; + + public static void main(String[] args) { + BandwidthClient client = new BandwidthClient.Builder() + .multiFactorAuthBasicAuthCredentials(USERNAME, PASSWORD) + .build(); + + String to = "+15553334444"; + String from = "+15554443333"; + String scope = "sample"; + int digits = 6; + String message = "Your temporary {NAME} {SCOPE} code is {CODE}"; + + TwoFactorCodeRequestSchema request = new TwoFactorCodeRequestSchema(); + request.setApplicationId(APPLICATION_ID); + request.setTo(to); + request.setFrom(from); + request.setScope(scope); + request.setDigits(digits); + request.setMessage(message); + + try { + CompletableFuture> completableFuture = client.getMultiFactorAuthClient().getMFAController().createVoiceTwoFactorAsync(ACCOUNT_ID, request); + System.out.println(completableFuture.get().getResult()); + } catch (InterruptedException | ExecutionException e) { + System.out.println(e.getMessage()); + } + } + } + - lang: Node.js + source: | + import { Client, MFAController } from '@bandwidth/mfa'; + + const BW_USERNAME = "api-username"; + const BW_PASSWORD = "api-password"; + const BW_ACCOUNT_ID = "12345"; + const BW_VOICE_APPLICATION_ID = "1234-qwer"; + const fromNumber = "+15554443333"; + const toNumber = "+15553334444"; + + const client = new Client({ + basicAuthUserName: BW_USERNAME, + basicAuthPassword: BW_PASSWORD + }); + + const controller = new MFAController(client); + + const payload = { + applicationId: BW_VOICE_APPLICATION_ID, + from: fromNumber, + to: toNumber, + scope: 'scope', + digits: 5, + message: "Your temporary {NAME} {SCOPE} code is {CODE}" + } + + const voiceTwoFactor = async function() { + try { + const response = await controller.voiceTwoFactor(BW_ACCOUNT_ID, payload); + console.log(JSON.stringify(response, null, 2)); + } catch (error) { + console.error(error); + }}; + + voiceTwoFactor(); + - lang: PHP + source: > + $BW_USERNAME, + 'multiFactorAuthBasicAuthPassword' => $BW_PASSWORD, + ) + ); + + $client = new BandwidthLib\BandwidthClient($config); + + + $mfaClient = $client->getMultiFactorAuth()->getMFA(); + + + $body = new + BandwidthLib\MultiFactorAuth\Models\TwoFactorCodeRequestSchema(); + + $body->from = $BW_MFA_NUMBER; + + $body->to = $USER_NUMBER; + + $body->applicationId = $BW_MFA_VOICE_APPLICATION_ID; + + $body->scope = "scope"; + + $body->digits = 6; + + $body->message = "Your temporary {NAME} {SCOPE} code is {CODE}"; + + + try { + $mfaClient->createVoiceTwoFactor($BW_ACCOUNT_ID, $body); + } catch (BandwidthLib\APIException $e) { + print_r($e->getResponseCode()); + } + - lang: Python + source: > + from bandwidth.bandwidth_client import BandwidthClient + + from bandwidth.multifactorauth.models.two_factor_code_request_schema + import TwoFactorCodeRequestSchema + + from bandwidth.exceptions.api_exception import APIException + + + import os + + + BW_USERNAME = "api-username" + + BW_PASSWORD = "api-password" + + BW_ACCOUNT_ID = "12345" + + BW_MFA_VOICE_APPLICATION_ID = "1234-qwer" + + BW_MFA_NUMBER = "+15554443333" + + USER_NUMBER = "+15553334444" + + + bandwidth_client = BandwidthClient( + multi_factor_auth_basic_auth_user_name=BW_USERNAME, + multi_factor_auth_basic_auth_password=BW_PASSWORD + ) + + auth_client = bandwidth_client.multi_factor_auth_client.mfa + + + body = TwoFactorCodeRequestSchema( + mfrom = BW_MFA_NUMBER, + to = USER_NUMBER, + application_id = BW_MFA_VOICE_APPLICATION_ID, + scope = "scope", + digits = 6, + message = "Your temporary {NAME} {SCOPE} code is {CODE}" + ) + + + try: + auth_client.create_voice_two_factor(BW_ACCOUNT_ID, body) + except APIException as e: + print(e.response_code) + - lang: Ruby + source: | + require 'bandwidth' + + include Bandwidth + include Bandwidth::MultiFactorAuth + + bandwidth_client = Bandwidth::Client.new( + multi_factor_auth_basic_auth_user_name: "api-username", + multi_factor_auth_basic_auth_password: "api-password" + ) + auth_client = bandwidth_client.multi_factor_auth_client.mfa + + body = TwoFactorCodeRequestSchema.new + body.application_id = "1234-qwer" + body.to = "+15553334444" + body.from = "+15554443333" + body.digits = 6 + body.scope = "scope" + body.message = "Your temporary {NAME} {SCOPE} code is {CODE}" + begin + result = auth_client.create_voice_two_factor("12345", body) + puts 'callId: ' + result.data.call_id + rescue APIException => e + puts e.response_code + end /accounts/{accountId}/code/messaging: post: tags: @@ -60,6 +337,284 @@ paths: $ref: '#/components/responses/mfaForbiddenError' '500': $ref: '#/components/responses/mfaInternalServerError' + x-codeSamples: + - lang: cURL + source: > + curl + 'https://mfa.bandwidth.com/api/v1/accounts/12345/code/messaging' \ + -X POST \ + -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \ + -H 'Content-Type: application/json' \ + -d '{ + "to": "+15553334444", + "from": "+15554443333", + "applicationId": "1234-asdf", + "scope": "scope", + "message": "Your temporary {NAME} {SCOPE} code is {CODE}", + "digits": 6 + }' + - lang: C# + source: | + using System; + using System.Threading.Tasks; + using Bandwidth.Standard; + using Bandwidth.Standard.Exceptions; + using Bandwidth.Standard.MultiFactorAuth.Models; + + class Program + { + static async Task Main(string[] args) + { + var username = "api-username"; + var password = "api-pasword"; + var accountId = "12345"; + var applicationId = "1234-asdf"; + var to = "+15553334444"; + var from = "+15554443333"; + var scope = "sample"; + var digits = 6; + var message = "Your temporary {NAME} {SCOPE} code is {CODE}"; + + var client = new BandwidthClient.Builder() + .MultiFactorAuthBasicAuthCredentials(username, password) + .Build(); + + var request = new TwoFactorCodeRequestSchema + { + ApplicationId = applicationId, + To = to, + From = from, + Scope = scope, + Digits = digits, + Message = message + }; + + try + { + var response = await client.MultiFactorAuth.MFAController.CreateMessagingTwoFactorAsync(accountId, request); + Console.WriteLine(response.Data); + } + catch (ApiException e) + { + Console.WriteLine(e.Message); + } + } + } + - lang: Java + source: > + import com.bandwidth.BandwidthClient; + + import com.bandwidth.http.response.ApiResponse; + + import + com.bandwidth.multifactorauth.models.TwoFactorCodeRequestSchema; + + import + com.bandwidth.multifactorauth.models.TwoFactorMessagingResponse; + + + import java.util.concurrent.CompletableFuture; + + import java.util.concurrent.ExecutionException; + + + public class Sample { + public static final String USERNAME = "api-username"; + public static final String PASSWORD = "api-password"; + public static final String ACCOUNT_ID = "12345"; + public static final String APPLICATION_ID = "1234-asdf"; + + public static void main(String[] args) { + BandwidthClient client = new BandwidthClient.Builder() + .multiFactorAuthBasicAuthCredentials(USERNAME, PASSWORD) + .build(); + + String to = "+15553334444"; + String from = "+15554443333"; + String scope = "sample"; + int digits = 6; + String message = "Your temporary {NAME} {SCOPE} code is {CODE}"; + + TwoFactorCodeRequestSchema request = new TwoFactorCodeRequestSchema(); + request.setApplicationId(APPLICATION_ID); + request.setTo(to); + request.setFrom(from); + request.setScope(scope); + request.setDigits(digits); + request.setMessage(message); + + try { + CompletableFuture> completableFuture = client.getMultiFactorAuthClient().getMFAController().createMessagingTwoFactorAsync(ACCOUNT_ID, request); + System.out.println(completableFuture.get().getResult()); + } catch (InterruptedException | ExecutionException e) { + System.out.println(e.getMessage()); + } + } + } + - lang: Node.js + source: | + import { Client, MFAController } from '@bandwidth/mfa'; + + const BW_USERNAME = "api-username"; + const BW_PASSWORD = "api-password"; + const BW_ACCOUNT_ID = "12345"; + const BW_MESSAGING_APPLICATION_ID = "1234-asdf"; + const fromNumber = "+15554443333"; + const toNumber = "+15553334444"; + + const client = new Client({ + basicAuthUserName: BW_USERNAME, + basicAuthPassword: BW_PASSWORD + }); + + const controller = new MFAController(client); + + const payload = { + applicationId: BW_MESSAGING_APPLICATION_ID, + from: fromNumber, + to: toNumber, + scope: 'scope', + digits: 6, + message: "Your temporary {NAME} {SCOPE} code is {CODE}" + } + + const msgTwoFactor = async function() { + try { + const response = await controller.messagingTwoFactor(BW_ACCOUNT_ID, payload); + console.log(JSON.stringify(response, null, 2)); + } catch (error) { + console.error(error); + }}; + + msgTwoFactor(); + - lang: PHP + source: > + $BW_USERNAME, + 'multiFactorAuthBasicAuthPassword' => $BW_PASSWORD, + ) + ); + + $client = new BandwidthLib\BandwidthClient($config); + + + $mfaClient = $client->getMultiFactorAuth()->getMFA(); + + + $body = new + BandwidthLib\MultiFactorAuth\Models\TwoFactorCodeRequestSchema(); + + $body->from = $BW_MFA_NUMBER; + + $body->to = $USER_NUMBER; + + $body->applicationId = $BW_MFA_MESSAGING_APPLICATION_ID; + + $body->scope = "scope"; + + $body->digits = 6; + + $body->message = "Your temporary {NAME} {SCOPE} code is {CODE}"; + + + try { + $mfaClient->createMessagingTwoFactor($BW_ACCOUNT_ID, $body); + } catch (BandwidthLib\APIException $e) { + print_r($e->getResponseCode()); + } + - lang: Python + source: > + from bandwidth.bandwidth_client import BandwidthClient + + from bandwidth.multifactorauth.models.two_factor_code_request_schema + import TwoFactorCodeRequestSchema + + from bandwidth.exceptions.api_exception import APIException + + + import os + + + BW_USERNAME = "api-username" + + BW_PASSWORD = "api-password" + + BW_ACCOUNT_ID = "12345" + + BW_MFA_MESSAGING_APPLICATION_ID = "1234-asdf" + + BW_MFA_NUMBER = "+15554443333" + + USER_NUMBER = "+15553334444" + + + bandwidth_client = BandwidthClient( + multi_factor_auth_basic_auth_user_name=BW_USERNAME, + multi_factor_auth_basic_auth_password=BW_PASSWORD + ) + + auth_client = bandwidth_client.multi_factor_auth_client.mfa + + + body = TwoFactorCodeRequestSchema( + mfrom = BW_MFA_NUMBER, + to = USER_NUMBER, + application_id = BW_MFA_MESSAGING_APPLICATION_ID, + scope = "scope", + digits = 6, + message = "Your temporary {NAME} {SCOPE} code is {CODE}" + ) + + try: + auth_client.create_messaging_two_factor(BW_ACCOUNT_ID, body) + except APIException as e: + print(e.response_code) + - lang: Ruby + source: | + require 'bandwidth' + + include Bandwidth + include Bandwidth::MultiFactorAuth + + bandwidth_client = Bandwidth::Client.new( + multi_factor_auth_basic_auth_user_name: "api-username", + multi_factor_auth_basic_auth_password: "api-password" + ) + auth_client = bandwidth_client.multi_factor_auth_client.mfa + + body = TwoFactorCodeRequestSchema.new + body.application_id = "1234-asdf" + body.to = "+15553334444" + body.from = "+15554443333" + body.digits = 6 + body.scope = "scope" + body.message = "Your temporary {NAME} {SCOPE} code is {CODE}" + begin + result = auth_client.create_messaging_two_factor("12345", body) + puts 'messageId: ' + result.data.message_id + rescue APIException => e + puts e.response_code + end /accounts/{accountId}/code/verify: post: tags: @@ -84,6 +639,296 @@ paths: $ref: '#/components/responses/mfaTooManyRequestsError' '500': $ref: '#/components/responses/mfaInternalServerError' + x-codeSamples: + - lang: cURL + source: | + curl 'https://mfa.bandwidth.com/api/v1/accounts/12345/code/verify' \ + -X POST \ + -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \ + -H 'Content-Type: application/json' \ + -d '{ + "to": "+15553334444", + "applicationId": "1234-asdf", + "scope": "scope", + "expirationTimeInMinutes": 3, + "code": "123456" + }' + - lang: C# + source: | + using System; + using System.Threading.Tasks; + using Bandwidth.Standard; + using Bandwidth.Standard.Exceptions; + using Bandwidth.Standard.MultiFactorAuth.Models; + + class Program + { + static async Task Main(string[] args) + { + var username = "api-username"; + var password = "api-pasword"; + var accountId = "12345"; + var applicationId = "1234-asdf"; + var to = "+15553334444"; + var scope = "sample"; + var code = "159193"; + var expirationTimeInMinutes = 3; + + var client = new BandwidthClient.Builder() + .MultiFactorAuthBasicAuthCredentials(username, password) + .Build(); + + var request = new TwoFactorVerifyRequestSchema + { + ApplicationId = applicationId, + To = to, + Scope = scope, + Code = code, + ExpirationTimeInMinutes = expirationTimeInMinutes + }; + + try + { + var response = await client.MultiFactorAuth.MFAController.CreateVerifyTwoFactorAsync(accountId, request); + Console.WriteLine(response.Data); + } + catch (ApiException e) + { + Console.WriteLine(e.Message); + } + } + } + - lang: Java + source: > + import com.bandwidth.BandwidthClient; + + import com.bandwidth.http.response.ApiResponse; + + import + com.bandwidth.multifactorauth.models.TwoFactorVerifyCodeResponse; + + import + com.bandwidth.multifactorauth.models.TwoFactorVerifyRequestSchema; + + + import java.util.concurrent.CompletableFuture; + + import java.util.concurrent.ExecutionException; + + + public class Sample { + public static final String USERNAME = "api-username"; + public static final String PASSWORD = "api-password"; + public static final String ACCOUNT_ID = "12345"; + public static final String APPLICATION_ID = "1234-qwer"; + + public static void main(String[] args) { + BandwidthClient client = new BandwidthClient.Builder() + .multiFactorAuthBasicAuthCredentials(USERNAME, PASSWORD) + .build(); + + String to = "+15553334444"; + String scope = "sample"; + String code = "159193"; + int expirationTimeInMinutes = 3; + + TwoFactorVerifyRequestSchema request = new TwoFactorVerifyRequestSchema(); + request.setApplicationId(APPLICATION_ID); + request.setTo(to); + request.setScope(scope); + request.setCode(code); + request.setExpirationTimeInMinutes(expirationTimeInMinutes); + + try { + CompletableFuture> completableFuture = client.getMultiFactorAuthClient().getMFAController().createVerifyTwoFactorAsync(ACCOUNT_ID, request); + System.out.println(completableFuture.get().getResult()); + } catch (InterruptedException | ExecutionException e) { + System.out.println(e.getMessage()); + } + } + } + - lang: Node.js + source: | + import { Client, MFAController } from '@bandwidth/mfa'; + + const BW_USERNAME = "api-username"; + const BW_PASSWORD = "api-password"; + const BW_ACCOUNT_ID = "12345"; + const BW_MESSAGING_APPLICATION_ID = "1234-qwer"; + const toNumber = "+15553334444"; + + const client = new Client({ + basicAuthUserName: BW_USERNAME, + basicAuthPassword: BW_PASSWORD + }); + + const controller = new MFAController(client); + + const payload = { + applicationId: BW_MESSAGING_APPLICATION_ID, + to: toNumber, + code: "12345", + scope: "scope", + expirationTimeInMinutes: 3, + code: "123456" + } + + const verifyTwoFactor = async function() { + try { + const response = await controller.verifyTwoFactor(BW_ACCOUNT_ID, payload); + console.log(JSON.stringify(response, null, 2)); + } catch (error) { + console.error(error); + }}; + + verifyTwoFactor(); + - lang: PHP + source: > + $BW_USERNAME, + 'multiFactorAuthBasicAuthPassword' => $BW_PASSWORD, + ) + ); + + $client = new BandwidthLib\BandwidthClient($config); + + + $mfaClient = $client->getMultiFactorAuth()->getMFA(); + + + $body = new + BandwidthLib\MultiFactorAuth\Models\TwoFactorVerifyRequestSchema(); + + $body->from = $BW_MFA_NUMBER; + + $body->to = $USER_NUMBER; + + $body->applicationId = $BW_MFA_MESSAGING_APPLICATION_ID; + + //$body->applicationId = 1234-qwer; + + $body->scope = "scope"; + + $body->code = "123456"; //This is the user's input to validate + + $body->digits = 6; + + $body->expirationTimeInMinutes = 3; + + + try { + $response = $mfaClient->createVerifyTwoFactor($BW_ACCOUNT_ID, $body); + print_r($response->getResult()->valid); + } catch (BandwidthLib\APIException $e) { + print_r($e->getResponseCode()); + } + - lang: Python + source: > + from bandwidth.bandwidth_client import BandwidthClient + + from + bandwidth.multifactorauth.models.two_factor_verify_request_schema + import TwoFactorVerifyRequestSchema + + from bandwidth.exceptions.api_exception import APIException + + + import os + + + BW_USERNAME = "api-username" + + BW_PASSWORD = "api-password" + + BW_ACCOUNT_ID = "12345" + + BW_MFA_VOICE_APPLICATION_ID = "1234-qwer" + + #BW_MFA_MESSAGING_APPLICATION_ID = "1234-asdf" + + #Both voice and messaging application IDs can be used. The verify + request + + #must have the same ID as the code request. + + USER_NUMBER = "+15553334444" + + + bandwidth_client = BandwidthClient( + multi_factor_auth_basic_auth_user_name=BW_USERNAME, + multi_factor_auth_basic_auth_password=BW_PASSWORD + ) + + auth_client = bandwidth_client.multi_factor_auth_client.mfa + + + body = TwoFactorVerifyRequestSchema( + to = USER_NUMBER, + application_id = BW_MFA_VOICE_APPLICATION_ID, + #application_id = MFA_MESSAGING_APPLICATION_ID, + scope = "scope", + code = "123456", #This is the user's input to validate + expiration_time_in_minutes = 3 + ) + + + try: + response = auth_client.create_verify_two_factor(BW_ACCOUNT_ID, body) + print(response.body.valid) + except APIException as e: + print(e.response_code) + - lang: Ruby + source: | + require 'bandwidth' + + include Bandwidth + include Bandwidth::MultiFactorAuth + + bandwidth_client = Bandwidth::Client.new( + multi_factor_auth_basic_auth_user_name: "api-username", + multi_factor_auth_basic_auth_password: "api-password" + ) + auth_client = bandwidth_client.multi_factor_auth_client.mfa + + body = TwoFactorVerifyRequestSchema.new + body.application_id = "1234-qwer" + body.to = "+15553334444" + body.scope = "scope" + body.code = "123456" + body.expiration_time_in_minutes = 3 + begin + result = auth_client.create_verify_two_factor("12345", body) + puts 'valid?: ' + result.data.valid + rescue APIException => e + puts e.response_code + end components: schemas: codeRequest: @@ -143,14 +988,14 @@ components: properties: callId: type: string - description: Programmable Voice API Call ID + description: Programmable Voice API Call ID. example: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 messagingCodeResponse: type: object properties: messageId: type: string - description: Messaging API Message ID + description: Messaging API Message ID. example: 9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6 verifyCodeRequest: type: object @@ -178,7 +1023,7 @@ components: example: 3 code: type: string - description: The generated mfa code to check if valid + description: The generated mfa code to check if valid. minLength: 4 maxLength: 8 example: '123456' @@ -191,7 +1036,7 @@ components: properties: valid: type: boolean - description: Whether or not the supplied code is valid + description: Whether or not the supplied code is valid. example: true mfaRequestError: type: object @@ -277,7 +1122,7 @@ components: parameters: accountId: name: accountId - description: Bandwidth Account ID with Voice service enabled + description: Bandwidth Account ID with Voice service enabled. in: path required: true style: simple diff --git a/site/specs/phoneNumberLookup.json b/site/specs/phoneNumberLookup.json index 783cfb8a5..a0a3788b9 100644 --- a/site/specs/phoneNumberLookup.json +++ b/site/specs/phoneNumberLookup.json @@ -262,33 +262,7 @@ "5XX": { "description": "Unexpected error. Please contact Bandwidth Support if your requests are receiving this status code for an extended period of time." } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://numbers.bandwidth.com/api/v1/accounts/12345/tnlookup' \\\n -X POST \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"tns\":\n [\n \"19196104420\"\n ]\n }'\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.PhoneNumberLookup.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var client = new BandwidthClient.Builder()\n .PhoneNumberLookupBasicAuthCredentials(username, password)\n .Build();\n\n var request = new OrderRequest\n {\n Tns = new List { \"+15553334444\" }\n };\n\n try\n {\n var response = await client.PhoneNumberLookup.APIController.CreateLookupRequestAsync(accountId, request);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.phonenumberlookup.models.OrderRequest;\nimport com.bandwidth.phonenumberlookup.models.OrderResponse;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n BandwidthClient client = new BandwidthClient.Builder()\n .phoneNumberLookupBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n List numbers = new ArrayList<>();\n numbers.add(\"+15553334444\");\n\n OrderRequest request = new OrderRequest(numbers);\n\n try {\n CompletableFuture> completableFuture = client.getPhoneNumberLookupClient().getAPIController().createLookupRequestAsync(ACCOUNT_ID, request);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'messagingBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$phoneNumberLookupClient = $client->getPhoneNumberLookup()->getClient();\n\n$body = new BandwidthLib\\PhoneNumberLookup\\Models\\OrderRequest();\n$body->tns = array(\"+15554443333\");\n\ntry {\n $response = $phoneNumberLookupClient->createLookupRequest($BW_ACCOUNT_ID, $body);\n print_r($response->getResult()->requestId);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\nfrom bandwidth.phonenumberlookup.models.order_request import OrderRequest\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n phone_number_lookup_basic_auth_user_name=BW_USERNAME,\n phone_number_lookup_basic_auth_password=BW_PASSWORD\n)\nphone_number_lookup_client = bandwidth_client.phone_number_lookup_client.client\n\nbody = OrderRequest()\nbody.tns = [\"+15554443333\"]\n\ntry:\n response = phone_number_lookup_client.create_lookup_request(BW_ACCOUNT_ID, body)\n print(response.body.request_id)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n \ninclude Bandwidth\ninclude Bandwidth::Voice\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = Bandwidth::Client.new(\n phone_number_lookup_basic_auth_user_name: BW_USERNAME,\n phone_number_lookup_basic_auth_password: BW_PASSWORD\n)\n\nphone_number_lookup_client = bandwidth_client.phone_number_lookup_client.client\n\nbody = OrderRequest.new\nbody.tns = [\"+15554443333\"]\n\nbegin\n result = phone_number_lookup_client.create_lookup_request(BW_ACCOUNT_ID, body)\n puts result.data.request_id\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } } }, "/accounts/{accountId}/tnlookup/{requestId}": { @@ -449,33 +423,7 @@ "5XX": { "description": "Unexpected error. Please contact Bandwidth Support if your requests are receiving this status code for an extended period of time." } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://numbers.bandwidth.com/api/v1/accounts/12345/tnlookup/004223a0-8b17-41b1-bf81-20732adf5590' \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var client = new BandwidthClient.Builder()\n .PhoneNumberLookupBasicAuthCredentials(username, password)\n .Build();\n\n var requestId = \"8a358296-e188-4a3a-b974-8e4d12001dd8\";\n\n try\n {\n var response = await client.PhoneNumberLookup.APIController.GetLookupRequestStatusAsync(accountId, requestId);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.phonenumberlookup.models.OrderStatus;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n BandwidthClient client = new BandwidthClient.Builder()\n .phoneNumberLookupBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n String requestId = \"8a358296-e188-4a3a-b974-8e4d12001dd8\";\n\n try {\n CompletableFuture> completableFuture = client.getPhoneNumberLookupClient().getAPIController().getLookupRequestStatusAsync(ACCOUNT_ID, requestId);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'messagingBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$phoneNumberLookupClient = $client->getPhoneNumberLookup()->getClient();\n\n$requestId = \"1234-abcd\";\n\ntry {\n $response = $phoneNumberLookupClient->getLookupRequestStatus($BW_ACCOUNT_ID, $requestId);\n print_r($response->getResult()->status);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n phone_number_lookup_basic_auth_user_name=BW_USERNAME,\n phone_number_lookup_basic_auth_password=BW_PASSWORD\n)\nphone_number_lookup_client = bandwidth_client.phone_number_lookup_client.client\n\nrequest_id = \"1234-abcd\"\n\ntry:\n response = phone_number_lookup_client.get_lookup_request_status(BW_ACCOUNT_ID, request_id)\n print(response.body.status)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n \ninclude Bandwidth\ninclude Bandwidth::Voice\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = Bandwidth::Client.new(\n phone_number_lookup_basic_auth_user_name: BW_USERNAME,\n phone_number_lookup_basic_auth_password: BW_PASSWORD\n)\n\nphone_number_lookup_client = bandwidth_client.phone_number_lookup_client.client\n\nrequest_id = \"1234-abcd\"\n\nbegin\n result = phone_number_lookup_client.get_lookup_request_status(BW_ACCOUNT_ID, request_id)\n puts result.data.status\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } } } }, diff --git a/site/specs/voice.json b/site/specs/voice.json index 11ed5ff82..65caeb4fa 100644 --- a/site/specs/voice.json +++ b/site/specs/voice.json @@ -304,37 +304,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://voice.bandwidth.com/api/v2/accounts/12345/calls/c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d' \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.Voice.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n // Call id is returned after successfully creating a call.\n var callId = \"c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d\";\n\n var client = new BandwidthClient.Builder()\n .VoiceBasicAuthCredentials(username, password)\n .Build();\n\n try\n {\n var response = await client.Voice.APIController.GetCallAsync(accountId, callId);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.voice.models.CallState;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n // Call id is returned after successfully creating a call.\n String callId = \"c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d\";\n\n BandwidthClient client = new BandwidthClient.Builder()\n .voiceBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n try {\n CompletableFuture> completableFuture = client.getVoiceClient().getAPIController().getCallAsync(ACCOUNT_ID, callId);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/voice';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\n\nconst callId = 'c-abc12345-6defabc1-2345-6def-abc1-23456defabc1';\n\nconst getCall = async function() {\n try {\n const response = await controller.getCall(accountId, callId);\n console.log(response)\n } catch(error) {\n console.error(error);\n }\n}\n\ngetCall();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'voiceBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$voiceClient = $client->getVoice()->getClient();\n\n$callId = \"c-1234\";\n\ntry {\n $response = $voiceClient->getCall($BW_ACCOUNT_ID, $callId);\n print_r($response->getResult()->state);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n voice_basic_auth_user_name=BW_USERNAME,\n voice_basic_auth_password=BW_PASSWORD\n)\nvoice_client = bandwidth_client.voice_client.client\n\ncall_id = \"c-1234\"\n\ntry:\n result = voice_client.get_call(BW_ACCOUNT_ID, call_id)\n print(result.body.state)\nexcept APIException as e: \n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::Voice\n\nbandwidth_client = Bandwidth::Client.new(\n voice_basic_auth_user_name: \"api-username\",\n voice_basic_auth_password: \"api-password\"\n)\n\nvoice_client = bandwidth_client.voice_client.client\n\ncall_id = \"c-1234\"\n\nbegin\n #result = voice_client.get_call(\"12345\", call_id)\n #puts result.data.state\n puts \"Method broke\"\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } }, "post": { "tags": [ @@ -452,37 +422,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://voice.bandwidth.com/api/v2/accounts/12345/calls/c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d' \\\n -X POST \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"state\": \"active\",\n \"redirectUrl\": \"http://example.com\",\n \"redirectFallbackUrl\": \"http://example.com\",\n \"redirectMethod\": \"POST\",\n \"redirectFallbackMethod\": \"POST\",\n \"username\": \"string\",\n \"password\": \"string\",\n \"fallbackUsername\": \"string\",\n \"fallbackPassword\": \"string\",\n \"tag\": \"string\"\n }'\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.Voice.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n var applicationId = \"1234-qwer\";\n\n // Call id is returned after successfully creating a call.\n var callId = \"c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d\";\n\n var client = new BandwidthClient.Builder()\n .VoiceBasicAuthCredentials(username, password)\n .Build();\n\n var request = new ModifyCallRequest()\n {\n State = StateEnum.Completed\n };\n\n try\n {\n await client.Voice.APIController.ModifyCallAsync(accountId, callId, request);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.voice.models.ModifyCallRequest;\nimport com.bandwidth.voice.models.StateEnum;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n String callId = \"c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d\";\n\n BandwidthClient client = new BandwidthClient.Builder()\n .voiceBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n ModifyCallRequest request = new ModifyCallRequest();\n request.setState(StateEnum.COMPLETED);\n\n try {\n CompletableFuture> completableFuture = client.getVoiceClient().getAPIController().modifyCallAsync(ACCOUNT_ID, callId, request);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/voice';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\n\nconst callId = 'c-abc12345-6defabc1-2345-6def-abc1-23456defabc1';\n\nconst modifyCall = async function() {\n try {\n const response = await controller.modifyCall(accountId, callId, {\n state: \"active\",\n redirectUrl: \"http://www.myapp.com/new\"\n });\n console.log(response)\n } catch(error) {\n console.error(error);\n }\n}\n\nmodifyCall();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'voiceBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$voiceClient = $client->getVoice()->getClient();\n\n$callId = \"c-1234\";\n\n$body = new BandwidthLib\\Voice\\Models\\ModifyCallRequest();\n$body->redirectUrl = \"http://www.myapp.com/new\";\n$body->state = \"active\";\n\ntry {\n $voiceClient->modifyCall($BW_ACCOUNT_ID, $callId, $body);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.voice.models.modify_call_request import ModifyCallRequest\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n voice_basic_auth_user_name=BW_USERNAME,\n voice_basic_auth_password=BW_PASSWORD\n)\nvoice_client = bandwidth_client.voice_client.client\n\ncall_id = \"c-1234\"\n\nbody = ModifyCallRequest()\nbody.redirect_url = \"http://www.myapp.com/new\"\nbody.state = \"active\"\n\ntry:\n voice_client.modify_call(BW_ACCOUNT_ID, call_id, body)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::Voice\n\nbandwidth_client = Bandwidth::Client.new(\n voice_basic_auth_user_name: \"api-username\",\n voice_basic_auth_password: \"api-password\"\n)\n\nvoice_client = bandwidth_client.voice_client.client\n\nbody = ModifyCallRequest.new\nbody.redirect_url = \"http://www.myapp.com/new\"\nbody.state = \"active\"\n\ncall_id = \"c-1234\"\n\nbegin\n voice_client.modify_call(\"12345\", call_id, body)\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } } }, "/api/v2/accounts/{accountId}/calls/{callId}/bxml": { @@ -814,37 +754,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://voice.bandwidth.com/api/v2/accounts/12345/calls/c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d/recording' \\\n -X PUT \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"state\": \"NOT_RECORDING\",\n }'\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.Voice.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n // Call id is returned after successfully creating a call.\n var callId = \"c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d\";\n\n var client = new BandwidthClient.Builder()\n .VoiceBasicAuthCredentials(username, password)\n .Build();\n\n var state = new ModifyCallRecordingRequest\n {\n State = State1Enum.PAUSED\n };\n\n try\n {\n await client.Voice.APIController.ModifyCallRecordingStateAsync(accountId, callId, state);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.voice.models.*;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n String callId = \"c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d\";\n\n BandwidthClient client = new BandwidthClient.Builder()\n .voiceBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n ModifyCallRecordingRequest recordingRequest = new ModifyCallRecordingRequest();\n recordingRequest.setState(State1Enum.PAUSED);\n\n try {\n CompletableFuture> completableFuture = client.getVoiceClient().getAPIController().modifyCallRecordingStateAsync(ACCOUNT_ID, callId, recordingRequest);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/voice';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\n\nconst callId = 'c-abc12345-6defabc1-2345-6def-abc1-23456defabc1';\n\nconst modifyCallRecordingState = async function() {\n try {\n const response = await controller.modifyCallRecordingState(accountId, callId, {\n state: 'PAUSED'\n });\n console.log(response)\n } catch(error) {\n console.error(error);\n }\n}\n\nmodifyCallRecordingState();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'voiceBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$voiceClient = $client->getVoice()->getClient();\n\n$callId = \"c-1234\";\n\n$body = new BandwidthLib\\Voice\\Models\\ModifyCallRecordingRequest();\n$body->redirectUrl = \"http://www.myapp.com/new\";\n$body->state = \"paused\";\n\ntry {\n $voiceClient->modifyCallRecordingState($BW_ACCOUNT_ID, $callId, $body);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.voice.models.modify_call_recording_request import ModifyCallRecordingRequest\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n voice_basic_auth_user_name=BW_USERNAME,\n voice_basic_auth_password=BW_PASSWORD\n)\nvoice_client = bandwidth_client.voice_client.client\n\nbody = ModifyCallRecordingRequest()\nbody.state = \"paused\"\n\ncall_id = \"c-1234\"\n\ntry:\n voice_client.modify_call_recording_state(BW_ACCOUNT_ID, call_id, body)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::Voice\n\nbandwidth_client = Bandwidth::Client.new(\n voice_basic_auth_user_name: \"api-username\",\n voice_basic_auth_password: \"api-password\"\n)\n\nvoice_client = bandwidth_client.voice_client.client\n\nbody = ModifyCallRecordingRequest.new\nbody.state = \"paused\"\n\ncall_id = \"c-1234\"\n\nbegin\n voice_client.modify_call_recording_state(\"12345\", call_id, body)\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } } }, "/api/v2/accounts/{accountId}/calls/{callId}/recordings": { @@ -958,37 +868,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://voice.bandwidth.com/api/v2/accounts/12345/calls/c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d/recordings' \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.Voice.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n // Call id is returned after successfully creating a call.\n var callId = \"c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d\";\n\n var client = new BandwidthClient.Builder()\n .VoiceBasicAuthCredentials(username, password)\n .Build();\n\n try\n {\n var response = await client.Voice.APIController.GetCallRecordingsAsync(accountId, callId);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.voice.models.CallRecordingMetadata;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\nimport java.util.List;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n // Call id is returned after successfully creating a call.\n String callId = \"c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d\";\n\n BandwidthClient client = new BandwidthClient.Builder()\n .voiceBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n try {\n CompletableFuture>> completableFuture = client.getVoiceClient().getAPIController().getCallRecordingsAsync(ACCOUNT_ID, callId);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/voice';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\n\nconst callId = 'c-abc12345-6defabc1-2345-6def-abc1-23456defabc1';\nconst recordingId = 'r-abc12345-6def-abc1-2345-6defabc12345';\n\nconst getCallRecordings = async function() {\n try {\n const response = await controller.getCallRecordings(accountId, callId, recordingId);\n console.log(response)\n } catch(error) {\n console.error(error);\n }\n}\n\ngetCallRecordings();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'voiceBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$voiceClient = $client->getVoice()->getClient();\n\n$callId = \"c-1234\";\n\ntry {\n $response = $voiceClient->getCallRecordings($BW_ACCOUNT_ID, $callId);\n if (count($response->getResult()) > 0) {\n print_r($response->getResult()[0]->recordingId);\n }\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n voice_basic_auth_user_name=BW_USERNAME,\n voice_basic_auth_password=BW_PASSWORD\n)\nvoice_client = bandwidth_client.voice_client.client\n\ncall_id = \"c-1234\"\n\ntry:\n response = voice_client.get_call_recordings(BW_ACCOUNT_ID, call_id)\n if len(response.body) > 0:\n print(response.body[0].recording_id)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::Voice\n\nbandwidth_client = Bandwidth::Client.new(\n voice_basic_auth_user_name: \"api-username\",\n voice_basic_auth_password: \"api-password\"\n)\n\nvoice_client = bandwidth_client.voice_client.client\n\ncall_id = \"c-1234\"\n\nbegin\n response = voice_client.get_call_recordings(\"12345\", call_id)\n if response.data.length > 0\n puts response.data[0].media_url\n end\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } } }, "/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}": { @@ -2175,37 +2055,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://voice.bandwidth.com/api/v2/accounts/12345/conferences' \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.Voice.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var client = new BandwidthClient.Builder()\n .VoiceBasicAuthCredentials(username, password)\n .Build();\n\n try\n {\n var response = await client.Voice.APIController.GetConferencesAsync(accountId);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.voice.models.ConferenceState;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\nimport java.util.List;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n BandwidthClient client = new BandwidthClient.Builder()\n .voiceBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n try {\n CompletableFuture>> completableFuture = client.getVoiceClient().getAPIController().getConferencesAsync(ACCOUNT_ID, null, null, null, null, null);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/voice';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\n\nconst getConferences = async function() {\n try {\n const response = await controller.getConferences(accountId);\n console.log(response)\n } catch(error) {\n console.error(error);\n }\n}\n\ngetConferences();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'voiceBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$voiceClient = $client->getVoice()->getClient();\n\ntry {\n $response = $voiceClient->getConferences($BW_ACCOUNT_ID);\n if (count($response->getResult()) > 0) {\n print_r($response->getResult()[0]->id);\n }\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n voice_basic_auth_user_name=BW_USERNAME,\n voice_basic_auth_password=BW_PASSWORD\n)\nvoice_client = bandwidth_client.voice_client.client\n\ntry:\n response = voice_client.get_conferences(BW_ACCOUNT_ID)\n if len(response.body) > 0:\n print(response.body[0].id)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::Voice\n\nbandwidth_client = Bandwidth::Client.new(\n voice_basic_auth_user_name: \"api-username\",\n voice_basic_auth_password: \"api-password\"\n)\n\nvoice_client = bandwidth_client.voice_client.client\n\nbegin\n response = voice_client.get_conferences(\"12345\")\n if response.data.length > 0\n puts response.data[0].id\n end\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } } }, "/api/v2/accounts/{accountId}/conferences/{conferenceId}": { @@ -2458,37 +2308,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://voice.bandwidth.com/api/v2/accounts/12345/conferences/conf-95ac8d8d-28e06798-2afe-434c-b0f4-666a79cd47f8' \\\n -X POST \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"status\": \"active\",\n \"redirectUrl\": \"http://example.com\",\n \"redirectFallbackUrl\": \"http://example.com\",\n \"redirectMethod\": \"POST\",\n \"redirectFallbackMethod\": \"POST\",\n \"username\": \"string\",\n \"password\": \"string\",\n \"fallbackUsername\": \"string\",\n \"fallbackPassword\": \"string\"\n }'\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.Voice.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var conferenceId = \"conf-95ac8d8d-28e06798-2afe-434c-b0f4-666a79cd47f8\";\n\n var client = new BandwidthClient.Builder()\n .VoiceBasicAuthCredentials(username, password)\n .Build();\n\n var request = new ModifyConferenceRequest\n {\n Status = StatusEnum.Completed\n };\n\n try\n {\n await client.Voice.APIController.ModifyConferenceAsync(accountId, conferenceId, request);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.voice.models.*;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n String conferenceId = \"conf-95ac8d8d-28e06798-2afe-434c-b0f4-666a79cd47f8\";\n\n BandwidthClient client = new BandwidthClient.Builder()\n .voiceBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n ModifyConferenceRequest request = new ModifyConferenceRequest();\n request.setStatus(StatusEnum.COMPLETED);\n\n try {\n CompletableFuture> completableFuture = client.getVoiceClient().getAPIController().modifyConferenceAsync(ACCOUNT_ID, conferenceId, request);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/voice';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\n\nconst conferenceId = 'conf-abc12345-6defabc1-2345-6def-abc1-23456defabc1';\n\nconst modifyConference = async function() {\n try {\n const response = await controller.modifyConference(accountId, conferenceId, {\n status: 'active',\n redirectUrl: 'http://www.myapp.com/new'\n });\n console.log(response)\n } catch(error) {\n console.error(error);\n }\n}\n\nmodifyConference();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'voiceBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$voiceClient = $client->getVoice()->getClient();\n\n$conferenceId = \"conf-1234\";\n\n$body = new BandwidthLib\\Voice\\Models\\ModifyConferenceRequest();\n$body->state = \"active\";\n\ntry {\n $voiceClient->modifyConference($BW_ACCOUNT_ID, $conferenceId, $body);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.voice.models.modify_conference_request import ModifyConferenceRequest\nfrom bandwidth.voice.models.status_enum import StatusEnum\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n voice_basic_auth_user_name=BW_USERNAME,\n voice_basic_auth_password=BW_PASSWORD\n)\nvoice_client = bandwidth_client.voice_client.client\n\nbody = ModifyConferenceRequest()\nbody.status = StatusEnum.ACTIVE\n\nconference_id = \"conf-1234\"\n\ntry:\n voice_client.modify_conference(BW_ACCOUNT_ID, conference_id, body)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::Voice\n\nbandwidth_client = Bandwidth::Client.new(\n voice_basic_auth_user_name: \"api-username\",\n voice_basic_auth_password: \"api-password\"\n)\n\nvoice_client = bandwidth_client.voice_client.client\n\nbody = ModifyConferenceRequest.new\nbody.status = StatusEnum::ACTIVE\n\nconference_id = \"conf-1234\"\n\nbegin\n voice_client.modify_conference(\"12345\", conference_id, body)\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } } }, "/api/v2/accounts/{accountId}/conferences/{conferenceId}/bxml": { @@ -2872,37 +2692,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://voice.bandwidth.com/api/v2/accounts/12345/conferences/conf-95ac8d8d-28e06798-2afe-434c-b0f4-666a79cd47f8/members/c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d' \\\n -X PUT \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"callId\": \"string\",\n \"conferenceId\": \"string\",\n \"memberUrl\": \"string\",\n \"mute\": true,\n \"hold\": true,\n \"callIdsToCoach\": [\n \"string\"\n ]\n }'\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.Voice.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var conferenceId = \"conf-95ac8d8d-28e06798-2afe-434c-b0f4-666a79cd47f8\";\n // Call id is returned after successfully creating a call.\n var callId = \"c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d\";\n\n var client = new BandwidthClient.Builder()\n .VoiceBasicAuthCredentials(username, password)\n .Build();\n\n var detail = new ConferenceMemberState\n {\n Mute = true\n };\n\n try\n {\n await client.Voice.APIController.ModifyConferenceMemberAsync(accountId, conferenceId, callId, detail);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.voice.models.*;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n String conferenceId = \"conf-95ac8d8d-28e06798-2afe-434c-b0f4-666a79cd47f8\";\n String callId = \"c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d\";\n\n BandwidthClient client = new BandwidthClient.Builder()\n .voiceBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n ConferenceMemberState conferenceMemberState = new ConferenceMemberState();\n conferenceMemberState.setMute(true);\n\n try {\n CompletableFuture> completableFuture = client.getVoiceClient().getAPIController().modifyConferenceMemberAsync(ACCOUNT_ID, conferenceId, callId, conferenceMemberState);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/voice';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\n\nconst conferenceId = 'conf-abc12345-6defabc1-2345-6def-abc1-23456defabc1';\nconst memberId = 'c-abc12345-6defabc1-2345-6def-abc1-23456defabc1';\n\nconst modifyConferenceMember = async function() {\n try {\n const response = await controller.modifyConferenceMember(accountId, conferenceId, memberId, {\n mute: true,\n callIdsToCoach : [\"c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d\", \"c-2a913f94-6a486f3a-3cae-4034-bcc3-f0c9fa77ca2f\"]\n });\n console.log(response)\n } catch(error) {\n console.error(error);\n }\n}\n\nmodifyConferenceMember();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'voiceBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$voiceClient = $client->getVoice()->getClient();\n\n$conferenceId = \"conf-1234\";\n$callId = \"c-1234\";\n\n$body = new BandwidthLib\\Voice\\Models\\ConferenceMemberState();\n$body->mute = true;\n\ntry {\n $voiceClient->modifyConferenceMember($BW_ACCOUNT_ID, $conferenceId, $callId, $body);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.voice.models.conference_member_state import ConferenceMemberState\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n voice_basic_auth_user_name=BW_USERNAME,\n voice_basic_auth_password=BW_PASSWORD\n)\nvoice_client = bandwidth_client.voice_client.client\n\nbody = ConferenceMemberState()\nbody.mute = True\n\nconference_id = \"conf-1234\"\ncall_id = \"c-1234\"\n\ntry:\n voice_client.modify_conference_member(BW_ACCOUNT_ID, conference_id, call_id, body)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::Voice\n\nbandwidth_client = Bandwidth::Client.new(\n voice_basic_auth_user_name: \"api-username\",\n voice_basic_auth_password: \"api-password\"\n)\n\nvoice_client = bandwidth_client.voice_client.client\n\nbody = ConferenceMemberState.new\nbody.mute = true\n\nconference_id = \"conf-1234\"\ncall_id = \"c-1234\"\n\nbegin\n voice_client.modify_conference_member(\"12345\", conference_id, call_id, body)\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } } }, "/api/v2/accounts/{accountId}/conferences/{conferenceId}/recordings": { @@ -3016,37 +2806,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://voice.bandwidth.com/api/v2/accounts/12345/conferences/conf-95ac8d8d-28e06798-2afe-434c-b0f4-666a79cd47f8/recordings' \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.Voice.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var conferenceId = \"conf-95ac8d8d-28e06798-2afe-434c-b0f4-666a79cd47f8\";\n\n var client = new BandwidthClient.Builder()\n .VoiceBasicAuthCredentials(username, password)\n .Build();\n\n try\n {\n var response = await client.Voice.APIController.GetConferenceRecordingsAsync(accountId, conferenceId);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.voice.models.ConferenceRecordingMetadata;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\nimport java.util.List;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n String conferenceId = \"conf-95ac8d8d-28e06798-2afe-434c-b0f4-666a79cd47f8\";\n\n BandwidthClient client = new BandwidthClient.Builder()\n .voiceBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n try {\n CompletableFuture>> completableFuture = client.getVoiceClient().getAPIController().getConferenceRecordingsAsync(ACCOUNT_ID, conferenceId);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/voice';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\n\nconst conferenceId = 'c-abc12345-6defabc1-2345-6def-abc1-23456defabc1';\n\nconst getConferenceRecordings = async function() {\n try {\n const response = await controller.getConferenceRecordings(accountId, conferenceId);\n console.log(response)\n } catch(error) {\n console.error(error);\n }\n}\n\ngetConferenceRecordings();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'voiceBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$voiceClient = $client->getVoice()->getClient();\n\n$conferenceId = \"c-1234\";\n\ntry {\n $response = $voiceClient->getConferenceRecordings($BW_ACCOUNT_ID, $conferenceId);\n if (count($response->getResult()) > 0) {\n print_r($response->getResult()[0]->name);\n }\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n voice_basic_auth_user_name=BW_USERNAME,\n voice_basic_auth_password=BW_PASSWORD\n)\nvoice_client = bandwidth_client.voice_client.client\n\nconference_id = \"conf-1234\"\n\ntry:\n response = voice_client.get_conference_recordings(BW_ACCOUNT_ID, conference_id)\n if len(response.body) > 0:\n print(response.body[0].name)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::Voice\n\nbandwidth_client = Bandwidth::Client.new(\n voice_basic_auth_user_name: \"api-username\",\n voice_basic_auth_password: \"api-password\"\n)\n\nvoice_client = bandwidth_client.voice_client.client\n\nconference_id = \"conf-1234\"\n\nbegin\n response = voice_client.get_conference_recordings(\"12345\", conference_id)\n if response.data.length > 0\n puts response.body[0].name\n end\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } } }, "/api/v2/accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}": { @@ -3493,37 +3253,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://voice.bandwidth.com/api/v2/accounts/12345/recordings' \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.Voice.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var client = new BandwidthClient.Builder()\n .VoiceBasicAuthCredentials(username, password)\n .Build();\n\n try\n {\n var response = await client.Voice.APIController.GetQueryCallRecordingsAsync(accountId);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.voice.models.*;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\nimport java.util.List;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n BandwidthClient client = new BandwidthClient.Builder()\n .voiceBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n try {\n CompletableFuture>> completableFuture = client.getVoiceClient().getAPIController().getQueryCallRecordingsAsync(ACCOUNT_ID, null, null, null, null);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/voice';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\n\nconst getCallRecordings = async function() {\n try {\n const response = await controller.getQueryCallRecordings(accountId);\n console.log(response)\n } catch(error) {\n console.error(error);\n }\n}\n\ngetCallRecordings();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'voiceBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$voiceClient = $client->getVoice()->getClient();\n\ntry {\n $response = $voiceClient->getQueryCallRecordings($BW_ACCOUNT_ID);\n if (count($response->getResult()) > 0) {\n print_r($response->getResult()[0]->recordingId);\n }\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n voice_basic_auth_user_name=BW_USERNAME,\n voice_basic_auth_password=BW_PASSWORD\n)\nvoice_client = bandwidth_client.voice_client.client\n\ntry:\n result = voice_client.get_query_call_recordings(BW_ACCOUNT_ID)\n if len(result.body) > 0:\n print(result.body[0].recording_id)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::Voice\n\nbandwidth_client = Bandwidth::Client.new(\n voice_basic_auth_user_name: \"api-username\",\n voice_basic_auth_password: \"api-password\"\n)\n\nvoice_client = bandwidth_client.voice_client.client\n\nbegin\n result = voice_client.get_query_call_recordings(\"12345\")\n if result.data.length > 0\n puts result.data[0].recording_id\n end\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } } } }, diff --git a/site/specs/webRtc.json b/site/specs/webRtc.json index 0ea9bc3d6..7ee142fde 100644 --- a/site/specs/webRtc.json +++ b/site/specs/webRtc.json @@ -109,37 +109,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://api.webrtc.bandwidth.com/v1/accounts/12345/participants' \\\n -X POST \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"callbackUrl\": \"https://example.com/callback\",\n \"publishPermissions\": [\n \"VIDEO\",\n \"AUDIO\"\n ],\n \"tag\": \"participant1\",\n \"deviceApiVersion\": \"V3\"\n }'\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.WebRtc.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var client = new BandwidthClient.Builder()\n .WebRtcBasicAuthCredentials(username, password)\n .Build();\n\n var participant = new Participant()\n {\n PublishPermissions = new List() { PublishPermissionEnum.AUDIO, PublishPermissionEnum.VIDEO }\n };\n\n try\n {\n var response = await client.WebRtc.APIController.CreateParticipantAsync(accountId, participant);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.webrtc.models.AccountsParticipantsResponse;\nimport com.bandwidth.webrtc.models.Participant;\nimport com.bandwidth.webrtc.models.PublishPermissionEnum;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\nimport java.util.Arrays;\nimport java.util.List;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n BandwidthClient client = new BandwidthClient.Builder()\n .webRtcBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n Participant participant = new Participant();\n List publishPermissions = Arrays.asList(PublishPermissionEnum.AUDIO, PublishPermissionEnum.VIDEO);\n participant.setPublishPermissions(publishPermissions);\n\n try {\n CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().createParticipantAsync(ACCOUNT_ID, participant);\n } catch (Exception ex) {\n System.out.println(ex.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/webrtc';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\n\nconst createParticipant = async function() {\n try {\n const response = await controller.createParticipant(accountId, {\n callbackUrl: \"http://www.myapp.com/new\",\n publishPermissions: [\"AUDIO\"]\n })\n console.log(response.body);\n } catch(error) {\n console.error(error);\n }\n}\n\ncreateParticipant();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'webRtcBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$webRtcClient = $client->getWebRtc()->getClient();\n\n$body = new BandwidthLib\\WebRtc\\Models\\Participant();\n$body->publishPermissions = array(\"AUDIO\", \"VIDEO\");\n$body->deviceApiVersion = \"V3\";\n\ntry {\n $response = $webRtcClient->createParticipant($BW_ACCOUNT_ID, $body);\n print_r($response->getResult()->participant->id);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\nfrom bandwidth.webrtc.models.participant import Participant\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n web_rtc_basic_auth_user_name=BW_USERNAME,\n web_rtc_basic_auth_password=BW_PASSWORD\n)\n\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nbody = Participant()\nbody.publish_permissions = [\"AUDIO\", \"VIDEO\"]\nbody.device_api_version = \"V3\"\n\ntry:\n response = web_rtc_client.create_participant(BW_ACCOUNT_ID, body)\n print(response.body.participant.id)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::WebRtc\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = Bandwidth::Client.new(\n web_rtc_basic_auth_user_name: BW_USERNAME,\n web_rtc_basic_auth_password: BW_PASSWORD\n)\n\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nbody = Participant.new\nbody.publish_permissions = [\"AUDIO\", \"VIDEO\"]\nbody.device_api_version = \"V3\"\n\nbegin\n response = web_rtc_client.create_participant(BW_ACCOUNT_ID, :body => body)\n puts response.data.participant.id\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } } }, "/accounts/{accountId}/participants/{participantId}": { @@ -203,37 +173,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://api.webrtc.bandwidth.com/v1/accounts/12345/participants/320e2af6-13ec-498d-8b51-daba52c37853' \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.WebRtc.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var participantId = \"320e2af6-13ec-498d-8b51-daba52c37853\";\n\n var client = new BandwidthClient.Builder()\n .WebRtcBasicAuthCredentials(username, password)\n .Build();\n\n try\n {\n var response = await client.WebRtc.APIController.GetParticipantAsync(accountId, participantId);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.webrtc.models.Participant;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n String participantId = \"568749d5-04d5-483d-adf5-deac7dd3d521\";\n\n BandwidthClient client = new BandwidthClient.Builder()\n .webRtcBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n try {\n CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().getParticipantAsync(ACCOUNT_ID, participantId);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/webrtc';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\nconst participantId = \"320e2af6-13ec-498d-8b51-daba52c37853\"\n\nconst getParticipant = async function() {\n try {\n const response = await controller.getParticipant(accountId, participantId)\n console.log(response.body);\n } catch(error) {\n console.error(error);\n }\n}\n\ngetParticipant();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'webRtcBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$webRtcClient = $client->getWebRtc()->getClient();\n\n$participantId = \"1234-qwer\";\n\ntry {\n $response = $webRtcClient->getParticipant($BW_ACCOUNT_ID, $participantId);\n print_r($response->getResult()->id);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n web_rtc_basic_auth_user_name=BW_USERNAME,\n web_rtc_basic_auth_password=BW_PASSWORD\n)\n\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nparticipant_id = \"1234-abcd\"\n\ntry:\n response = web_rtc_client.get_participant(BW_ACCOUNT_ID, participant_id)\n print(response.body.id)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::WebRtc\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = Bandwidth::Client.new(\n web_rtc_basic_auth_user_name: BW_USERNAME,\n web_rtc_basic_auth_password: BW_PASSWORD\n)\n\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nparticipant_id = \"1234-abcd\"\n\nbegin\n response = web_rtc_client.get_participant(BW_ACCOUNT_ID, participant_id)\n puts response.data.id\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } }, "delete": { "tags": [ @@ -287,37 +227,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://api.webrtc.bandwidth.com/v1/accounts/12345/participants/320e2af6-13ec-498d-8b51-daba52c37853' \\\n -X DELETE \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.WebRtc.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var participantId = \"320e2af6-13ec-498d-8b51-daba52c37853\";\n\n var client = new BandwidthClient.Builder()\n .WebRtcBasicAuthCredentials(username, password)\n .Build();\n\n try\n {\n await client.WebRtc.APIController.DeleteParticipantAsync(accountId, participantId);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n BandwidthClient client = new BandwidthClient.Builder()\n .webRtcBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n String participantId = \"568749d5-04d5-483d-adf5-deac7dd3d521\";\n\n try {\n CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().deleteParticipantAsync(ACCOUNT_ID, participantId);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/webrtc';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\nconst participantId = \"320e2af6-13ec-498d-8b51-daba52c37853\"\n\nconst deleteParticipant = async function() {\n try {\n const response = await controller.deleteParticipant(accountId, participantId)\n console.log(response.body);\n } catch(error) {\n console.error(error);\n }\n}\n\ndeleteParticipant();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'webRtcBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$webRtcClient = $client->getWebRtc()->getClient();\n\n$participantId = \"1234-abcd\";\n\ntry {\n $webRtcClient->deleteParticipant($BW_ACCOUNT_ID, $participantId);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n web_rtc_basic_auth_user_name=BW_USERNAME,\n web_rtc_basic_auth_password=BW_PASSWORD\n)\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nparticipant_id = \"1234-abcd\"\n\ntry:\n web_rtc_client.delete_participant(BW_ACCOUNT_ID, participant_id)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::WebRtc\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = Bandwidth::Client.new(\n web_rtc_basic_auth_user_name: BW_USERNAME,\n web_rtc_basic_auth_password: BW_PASSWORD\n)\n\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nparticipant_id = \"1234-abcd\"\n\nbegin\n web_rtc_client.delete_participant(BW_ACCOUNT_ID, participant_id)\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } } }, "/accounts/{accountId}/sessions": { @@ -380,37 +290,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://api.webrtc.bandwidth.com/v1/accounts/12345/sessions' \\\n -X POST \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"tag\": \"session1\"\n }'\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.WebRtc.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var client = new BandwidthClient.Builder()\n .WebRtcBasicAuthCredentials(username, password)\n .Build();\n\n var session = new Session()\n {\n Tag = \"new-session\"\n };\n\n try\n {\n var response = await client.WebRtc.APIController.CreateSessionAsync(accountId, session);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}" - }, - { - "lang": "Java", - "source": "import java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\nimport com.bandwidth.*;\nimport com.bandwidth.webrtc.models.*;\nimport com.bandwidth.http.response.ApiResponse;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n BandwidthClient client = new BandwidthClient.Builder()\n .webRtcBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n Session session = new Session();\n session.setTag(\"new-session\");\n\n try {\n CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().createSessionAsync(ACCOUNT_ID, session);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/webrtc';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\n\nconst createSession = async function() {\n try {\n const response = await controller.createSession(accountId, {\n tag: '{\"SessionName\": \"my_session\"}'\n })\n console.log(response.body);\n } catch(error) {\n console.error(error);\n }\n}\n\ncreateSession();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'webRtcBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$webRtcClient = $client->getWebRtc()->getClient();\n\n$body = new BandwidthLib\\WebRtc\\Models\\Session();\n$body->tag = \"tag\";\n\ntry {\n $response = $webRtcClient->createSession($BW_ACCOUNT_ID, $body);\n print_r($response->getResult()->id);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\nfrom bandwidth.webrtc.models.session import Session\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n web_rtc_basic_auth_user_name=BW_USERNAME,\n web_rtc_basic_auth_password=BW_PASSWORD\n)\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nbody = Session()\nbody.tag = \"tag\"\n\ntry:\n response = web_rtc_client.create_session(BW_ACCOUNT_ID, body)\n print(response.body.id)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::WebRtc\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = Bandwidth::Client.new(\n web_rtc_basic_auth_user_name: BW_USERNAME,\n web_rtc_basic_auth_password: BW_PASSWORD\n)\n\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nbody = Session.new\nbody.tag = \"tag\"\n\nbegin\n response = web_rtc_client.create_session(BW_ACCOUNT_ID, :body => body)\n puts response.data.id\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } } }, "/accounts/{accountId}/sessions/{sessionId}": { @@ -474,37 +354,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://api.webrtc.bandwidth.com/v1/accounts/12345/sessions/75c21163-e110-41bc-bd76-1bb428ec85d5' \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.WebRtc.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\"; // Returned via WebRTC's create session request.\n\n var client = new BandwidthClient.Builder()\n .WebRtcBasicAuthCredentials(username, password)\n .Build();\n\n try\n {\n var response = await client.WebRtc.APIController.GetSessionAsync(accountId, sessionId);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.webrtc.models.Session;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n String sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\";\n\n BandwidthClient client = new BandwidthClient.Builder()\n .webRtcBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n try {\n CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().getSessionAsync(ACCOUNT_ID, sessionId);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/webrtc';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\nconst sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\"\n\nconst getSession = async function() {\n try {\n const response = await controller.getSession(accountId, sessionId)\n console.log(response.body);\n } catch(error) {\n console.error(error);\n }\n}\n\ngetSession();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'webRtcBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$webRtcClient = $client->getWebRtc()->getClient();\n\n$sessionId = \"1234-qwer\";\n\ntry {\n $response = $webRtcClient->getSession($BW_ACCOUNT_ID, $sessionId);\n print_r($response->getResult()->id);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n web_rtc_basic_auth_user_name=BW_USERNAME,\n web_rtc_basic_auth_password=BW_PASSWORD\n)\n\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nsession_id = \"1234-abcd\"\n\ntry:\n response = web_rtc_client.get_session(BW_ACCOUNT_ID, session_id)\n print(response.body.id)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::WebRtc\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = Bandwidth::Client.new(\n web_rtc_basic_auth_user_name: BW_USERNAME,\n web_rtc_basic_auth_password: BW_PASSWORD\n)\n\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nsession_id = \"1234-abcd\"\n\nbegin\n response = web_rtc_client.get_session(BW_ACCOUNT_ID, session_id)\n print(response.data.id)\nrescue APIException => e\n print(e.response_code)\nend\n" - } - ] + } }, "delete": { "tags": [ @@ -556,37 +406,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://api.webrtc.bandwidth.com/v1/accounts/12345/sessions/75c21163-e110-41bc-bd76-1bb428ec85d5' \\\n -X DELETE \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.WebRtc.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\"; // Returned via WebRTC's create session request.\n\n var client = new BandwidthClient.Builder()\n .WebRtcBasicAuthCredentials(username, password)\n .Build();\n\n try\n {\n await client.WebRtc.APIController.DeleteSessionAsync(accountId, sessionId);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n BandwidthClient client = new BandwidthClient.Builder()\n .webRtcBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n String sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\";\n\n try {\n CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().deleteSessionAsync(ACCOUNT_ID, sessionId);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/webrtc';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\nconst sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\"\n\nconst deleteSession = async function() {\n try {\n const response = await controller.deleteSession(accountId, sessionId)\n console.log(response.body);\n } catch(error) {\n console.error(error);\n }\n}\n\ndeleteSession();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'webRtcBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$webRtcClient = $client->getWebRtc()->getClient();\n\n$sessionId = \"1234-qwer\";\n\ntry {\n $webRtcClient->deleteSession($BW_ACCOUNT_ID, $sessionId);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n web_rtc_basic_auth_user_name=BW_USERNAME,\n web_rtc_basic_auth_password=BW_PASSWORD\n)\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nsession_id = \"1234-abcd\"\n\ntry:\n web_rtc_client.delete_session(BW_ACCOUNT_ID, session_id)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::WebRtc\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = Bandwidth::Client.new(\n web_rtc_basic_auth_user_name: BW_USERNAME,\n web_rtc_basic_auth_password: BW_PASSWORD\n)\n\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nsession_id = \"1234-abcd\"\n\nbegin\n web_rtc_client.delete_session(BW_ACCOUNT_ID, session_id)\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } } }, "/accounts/{accountId}/sessions/{sessionId}/participants": { @@ -650,37 +470,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://api.webrtc.bandwidth.com/v1/accounts/12345/sessions/75c21163-e110-41bc-bd76-1bb428ec85d5/participants' \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.WebRtc.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\"; // Returned via WebRTC's create session request.\n\n var client = new BandwidthClient.Builder()\n .WebRtcBasicAuthCredentials(username, password)\n .Build();\n\n try\n {\n var response = await client.WebRtc.APIController.ListSessionParticipantsAsync(accountId, sessionId);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.webrtc.models.Participant;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\nimport java.util.List;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n String sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\";\n\n BandwidthClient client = new BandwidthClient.Builder()\n .webRtcBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n try {\n CompletableFuture>> completableFuture = client.getWebRtcClient().getAPIController().listSessionParticipantsAsync(ACCOUNT_ID, sessionId);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/webrtc';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\nconst sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\"\n\nconst listSessionParticipants = async function() {\n try {\n const response = await controller.listSessionParticipants(accountId, sessionId)\n console.log(response.body);\n } catch(error) {\n console.error(error);\n }\n}\n\nlistSessionParticipants();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'webRtcBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$webRtcClient = $client->getWebRtc()->getClient();\n\n$sessionId = \"1234-qwer\";\n\ntry {\n $response = $webRtcClient->listSessionParticipants($BW_ACCOUNT_ID, $sessionId);\n print_r($response->getResult());\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n web_rtc_basic_auth_user_name=BW_USERNAME,\n web_rtc_basic_auth_password=BW_PASSWORD\n)\n\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nsession_id = \"1234-abcd\"\n\ntry:\n response = web_rtc_client.list_session_participants(BW_ACCOUNT_ID, session_id)\n print(response.body)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::WebRtc\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = Bandwidth::Client.new(\n web_rtc_basic_auth_user_name: BW_USERNAME,\n web_rtc_basic_auth_password: BW_PASSWORD\n)\n\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nsession_id = \"1234-abcd\"\n\nbegin\n response = web_rtc_client.list_session_participants(BW_ACCOUNT_ID, session_id)\n puts response.end\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } } }, "/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}": { @@ -754,37 +544,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://api.webrtc.bandwidth.com/v1/accounts/12345/sessions/75c21163-e110-41bc-bd76-1bb428ec85d5/participants/568749d5-04d5-483d-adf5-deac7dd3d521' \\\n -X PUT \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"sessionId\": \"d8886aad-b956-4e1b-b2f4-d7c9f8162772\",\n \"participants\": [\n {\n \"participantId\": \"568749d5-04d5-483d-adf5-deac7dd3d521\"\n },\n {\n \"participantId\": \"0275e47f-dd21-4cf0-a1e1-dfdc719e73a7\"\n }\n ]\n }'\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.WebRtc.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\"; // Returned via WebRTC's create session request.\n var participantId = \"568749d5-04d5-483d-adf5-deac7dd3d521\"; // Returned via WebRTC's create participant request.\n\n var client = new BandwidthClient.Builder()\n .WebRtcBasicAuthCredentials(username, password)\n .Build();\n\n try\n {\n await client.WebRtc.APIController.AddParticipantToSessionAsync(accountId, sessionId, participantId);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n String sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\"; // Returned via WebRTC's create session request.\n String participantId = \"568749d5-04d5-483d-adf5-deac7dd3d521\"; // Returned via WebRTC's create participant request.\n\n BandwidthClient client = new BandwidthClient.Builder()\n .webRtcBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n try {\n CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().addParticipantToSessionAsync(ACCOUNT_ID, sessionId, participantId, null);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/webrtc';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\nconst sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\"\nconst participantId = \"320e2af6-13ec-498d-8b51-daba52c37853\"\n\nconst addParticipantToSession = async function() {\n try {\n const response = await controller.addParticipantToSession(accountId, sessionId, participantId)\n console.log(response.body);\n } catch(error) {\n console.error(error);\n }\n}\n\naddParticipantToSession();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'webRtcBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$webRtcClient = $client->getWebRtc()->getClient();\n\n$sessionId = \"1234-abcd\";\n$participantId = \"4321-dcba\";\n\ntry {\n $webRtcClient->addParticipantToSession($BW_ACCOUNT_ID, $sessionId, $participantId);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n web_rtc_basic_auth_user_name=BW_USERNAME,\n web_rtc_basic_auth_password=BW_PASSWORD\n)\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nsession_id = \"1234-abcd\"\nparticipant_id = \"4321-dcba\"\n\ntry:\n web_rtc_client.add_participant_to_session(BW_ACCOUNT_ID, session_id, participant_id)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::WebRtc\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = Bandwidth::Client.new(\n web_rtc_basic_auth_user_name: BW_USERNAME,\n web_rtc_basic_auth_password: BW_PASSWORD\n)\n\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nsession_id = \"1234-abcd\"\nparticipant_id = \"4321-dcba\"\n\nbegin\n web_rtc_client.add_participant_to_session(BW_ACCOUNT_ID, session_id, participant_id)\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } }, "delete": { "tags": [ @@ -845,37 +605,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://api.webrtc.bandwidth.com/v1/accounts/12345/sessions/75c21163-e110-41bc-bd76-1bb428ec85d5/participants/568749d5-04d5-483d-adf5-deac7dd3d521' \\\n -X DELETE \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.WebRtc.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\"; // Returned via WebRTC's create session request.\n var participantId = \"568749d5-04d5-483d-adf5-deac7dd3d521\"; // Returned via WebRTC's create participant request.\n\n var client = new BandwidthClient.Builder()\n .WebRtcBasicAuthCredentials(username, password)\n .Build();\n\n try\n {\n await client.WebRtc.APIController.RemoveParticipantFromSessionAsync(accountId, sessionId, participantId);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n String sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\";\n String participantId = \"568749d5-04d5-483d-adf5-deac7dd3d521\";\n\n BandwidthClient client = new BandwidthClient.Builder()\n .webRtcBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n try {\n CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().removeParticipantFromSessionAsync(ACCOUNT_ID, sessionId, participantId);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/webrtc';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\nconst sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\"\nconst participantId = \"320e2af6-13ec-498d-8b51-daba52c37853\"\n\nconst removeParticipantFromSession = async function() {\n try {\n const response = await controller.removeParticipantFromSession(accountId, sessionId, participantId)\n console.log(response.body);\n } catch(error) {\n console.error(error);\n }\n}\n\nremoveParticipantFromSession();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'webRtcBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$webRtcClient = $client->getWebRtc()->getClient();\n\n$sessionId = \"1234-abcd\";\n$participantId = \"4321-dcba\";\n\ntry {\n $webRtcClient->removeParticipantFromSession($BW_ACCOUNT_ID, $sessionId, $participantId);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n web_rtc_basic_auth_user_name=BW_USERNAME,\n web_rtc_basic_auth_password=BW_PASSWORD\n)\n\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nsession_id = \"1234-abcd\"\nparticipant_id = \"4312-dbca\"\n\ntry:\n web_rtc_client.remove_participant_from_session(BW_ACCOUNT_ID, session_id, participant_id)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::WebRtc\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = Bandwidth::Client.new(\n web_rtc_basic_auth_user_name: BW_USERNAME,\n web_rtc_basic_auth_password: BW_PASSWORD\n)\n\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nsession_id = \"1234-abcd\"\nparticipant_id = \"4312-dbca\"\n\nbegin\n web_rtc_client.remove_participant_from_session(BW_ACCOUNT_ID, session_id, participant_id)\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } } }, "/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}/subscriptions": { @@ -948,37 +678,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://api.webrtc.bandwidth.com/v1/accounts/12345/sessions/75c21163-e110-41bc-bd76-1bb428ec85d5/participants/568749d5-04d5-483d-adf5-deac7dd3d521/subscriptions' \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.WebRtc.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\"; // Returned via WebRTC's create session request.\n var participantId = \"568749d5-04d5-483d-adf5-deac7dd3d521\"; // Returned via WebRTC's create participant request.\n\n var client = new BandwidthClient.Builder()\n .WebRtcBasicAuthCredentials(username, password)\n .Build();\n\n try\n {\n var response = await client.WebRtc.APIController.GetParticipantSubscriptionsAsync(accountId, sessionId, participantId);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.webrtc.models.Subscriptions;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n String sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\";\n String participantId = \"568749d5-04d5-483d-adf5-deac7dd3d521\";\n\n BandwidthClient client = new BandwidthClient.Builder()\n .webRtcBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n try {\n CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().getParticipantSubscriptionsAsync(ACCOUNT_ID, sessionId, participantId);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/webrtc';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\nconst sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\"\nconst participantId = \"320e2af6-13ec-498d-8b51-daba52c37853\"\n\nconst getParticipantSubscriptions = async function() {\n try {\n const response = await controller.getParticipantSubscriptions(accountId, sessionId, participantId)\n console.log(response.body);\n } catch(error) {\n console.error(error);\n }\n}\n\ngetParticipantSubscriptions();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'webRtcBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$webRtcClient = $client->getWebRtc()->getClient();\n\n$participantId = \"1234-abcd\";\n$sessionId = \"4321-dcba\";\n\ntry {\n $response = $webRtcClient->getParticipantSubscriptions($BW_ACCOUNT_ID, $sessionId, $participantId);\n print_r($response->getResult());\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n web_rtc_basic_auth_user_name=BW_USERNAME,\n web_rtc_basic_auth_password=BW_PASSWORD\n)\n\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nparticipant_id = \"1234-abcd\"\nsession_id = \"4321-dcba\"\n\ntry:\n response = web_rtc_client.get_participant_subscriptions(BW_ACCOUNT_ID, session_id, participant_id)\n print(response.body)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::WebRtc\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = Bandwidth::Client.new(\n web_rtc_basic_auth_user_name: BW_USERNAME,\n web_rtc_basic_auth_password: BW_PASSWORD\n)\n\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nparticipant_id = \"1234-abcd\"\nsession_id = \"4321-dcba\"\n\nbegin\n response = web_rtc_client.get_participant_subscriptions(BW_ACCOUNT_ID, session_id, participant_id)\n puts response.data\nrescue APIException => e\n puts e.response_code\nend\n" - } - ] + } }, "put": { "tags": [ @@ -1053,37 +753,7 @@ } } } - }, - "x-codeSamples": [ - { - "lang": "cURL", - "source": "curl 'https://api.webrtc.bandwidth.com/v1/accounts/12345/sessions/75c21163-e110-41bc-bd76-1bb428ec85d5/participants/568749d5-04d5-483d-adf5-deac7dd3d521/subscriptions' \\\n -X PUT \\\n -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"sessionId\": \"d8886aad-b956-4e1b-b2f4-d7c9f8162772\",\n \"participants\": [\n {\n \"participantId\": \"568749d5-04d5-483d-adf5-deac7dd3d521\"\n },\n {\n \"participantId\": \"0275e47f-dd21-4cf0-a1e1-dfdc719e73a7\"\n }\n ]\n }'\n" - }, - { - "lang": "C#", - "source": "using System;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.WebRtc.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\"; // Returned via WebRTC's create session request.\n var participantId = \"568749d5-04d5-483d-adf5-deac7dd3d521\"; // Returned via WebRTC's create participant request.\n\n var client = new BandwidthClient.Builder()\n .WebRtcBasicAuthCredentials(username, password)\n .Build();\n\n var subscriptions = new Subscriptions()\n {\n SessionId = sessionId\n };\n\n try\n {\n await client.WebRtc.APIController.UpdateParticipantSubscriptionsAsync(accountId, sessionId, participantId, subscriptions);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - }, - { - "lang": "Java", - "source": "import com.bandwidth.BandwidthClient;\nimport com.bandwidth.http.response.ApiResponse;\nimport com.bandwidth.webrtc.models.Subscriptions;\n\nimport java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.ExecutionException;\n\npublic class Sample {\n public static final String USERNAME = \"api-username\";\n public static final String PASSWORD = \"api-password\";\n public static final String ACCOUNT_ID = \"12345\";\n\n public static void main(String[] args) {\n String sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\";\n String participantId = \"568749d5-04d5-483d-adf5-deac7dd3d521\";\n\n BandwidthClient client = new BandwidthClient.Builder()\n .webRtcBasicAuthCredentials(USERNAME, PASSWORD)\n .build();\n\n Subscriptions subscriptions = new Subscriptions();\n subscriptions.setSessionId(sessionId);\n\n try {\n CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().updateParticipantSubscriptionsAsync(ACCOUNT_ID, sessionId, participantId, subscriptions);\n System.out.println(completableFuture.get().getResult());\n } catch (InterruptedException | ExecutionException e) {\n System.out.println(e.getMessage());\n }\n }\n}\n" - }, - { - "lang": "Node.js", - "source": "import { Client, ApiController } from '@bandwidth/webrtc';\n\nconst BW_USERNAME = \"api-username\";\nconst BW_PASSWORD = \"api-password\";\nconst BW_ACCOUNT_ID = \"12345\";\n\nconst client = new Client({\n basicAuthUserName: BW_USERNAME,\n basicAuthPassword: BW_PASSWORD\n});\n\nconst controller = new ApiController(client);\n\nconst accountId = BW_ACCOUNT_ID;\nconst sessionId = \"75c21163-e110-41bc-bd76-1bb428ec85d5\"\nconst participantId = \"320e2af6-13ec-498d-8b51-daba52c37853\"\nconst body = { \"sessionId\": \"75c21163-e110-41bc-bd76-1bb428ec85d5\",\n \"participants\": [{\n \"participantId\": \"568749d5-04d5-483d-adf5-deac7dd3d521\"\n }, {\n \"participantId\": \"0275e47f-dd21-4cf0-a1e1-dfdc719e73a7\"\n }]\n }\n\nconst updateParticipantSubscriptions = async function() {\n try {\n const response = await controller.updateParticipantSubscriptions(accountId, sessionId, participantId, body)\n console.log(response.body);\n } catch(error) {\n console.error(error);\n }\n}\n\nupdateParticipantSubscriptions();\n" - }, - { - "lang": "PHP", - "source": " $BW_USERNAME,\n 'webRtcBasicAuthPassword' => $BW_PASSWORD,\n )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n\n$webRtcClient = $client->getWebRtc()->getClient();\n\n$body = new BandwidthLib\\WebRtc\\Models\\Subscriptions();\n$body->sessionId = \"1234-abcd\";\n\n$sessionId = \"1234-abcd\";\n$participantId = \"4321-dcba\";\n\ntry {\n $webRtcClient->updateParticipantSubscriptions($BW_ACCOUNT_ID, $sessionId, $participantId, $body);\n} catch (BandwidthLib\\APIException $e) {\n print_r($e->getResponseCode());\n}\n" - }, - { - "lang": "Python", - "source": "from bandwidth.bandwidth_client import BandwidthClient\nfrom bandwidth.exceptions.api_exception import APIException\nfrom bandwidth.webrtc.models.subscriptions import Subscriptions\n\nimport os\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = BandwidthClient(\n web_rtc_basic_auth_user_name=BW_USERNAME,\n web_rtc_basic_auth_password=BW_PASSWORD\n)\n\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nbody = Subscriptions()\nbody.session_id = \"1234-abcd\"\n\nsession_id = \"1234-abcd\"\nparticipant_id = \"4321-dcba\"\n\ntry:\n web_rtc_client.update_participant_subscriptions(BW_ACCOUNT_ID, session_id, participant_id, body)\nexcept APIException as e:\n print(e.response_code)\n" - }, - { - "lang": "Ruby", - "source": "require 'bandwidth'\n\ninclude Bandwidth\ninclude Bandwidth::WebRtc\n\nBW_USERNAME = \"api-username\"\nBW_PASSWORD = \"api-password\"\nBW_ACCOUNT_ID = \"12345\"\n\nbandwidth_client = Bandwidth::Client.new(\n web_rtc_basic_auth_user_name: BW_USERNAME,\n web_rtc_basic_auth_password: BW_PASSWORD\n)\n\nweb_rtc_client = bandwidth_client.web_rtc_client.client\n\nbody = Subscriptions.new\nbody.session_id = \"1234-abcd\"\n\nsession_id = \"1234-abcd\"\nparticipant_id = \"4321-dcba\"\n\nbegin\n web_rtc_client.update_participant_subscriptions(BW_ACCOUNT_ID, session_id, participant_id, :body => body)\n #NOTE: This is currently improperly defined\nrescue APIException => e\n puts e.response_code\nend\n\n" - } - ] + } } } },