Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

bwdb-15583-new #1163

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
279 changes: 157 additions & 122 deletions site/specs/messaging.yml

Large diffs are not rendered by default.

195 changes: 72 additions & 123 deletions site/specs/multi-factor-auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,52 +101,35 @@ paths:
}
}
- 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;

source: |
import com.bandwidth.sdk.ApiClient;
import com.bandwidth.sdk.ApiException;
import com.bandwidth.sdk.Configuration;
import com.bandwidth.sdk.auth.*;
import com.bandwidth.sdk.model.*;
import com.bandwidth.sdk.api.MfaApi;

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);
ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure HTTP basic authorization: Basic
HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
Basic.setUsername("YOUR USERNAME");
Basic.setPassword("YOUR PASSWORD");

MfaApi apiInstance = new MfaApi(defaultClient);
String accountId = "9900000"; // String | Your Bandwidth Account ID.
CodeRequest codeRequest = new CodeRequest(); // CodeRequest | MFA code request body.
try {
CompletableFuture<ApiResponse<TwoFactorVoiceResponse>> completableFuture = client.getMultiFactorAuthClient().getMFAController().createVoiceTwoFactorAsync(ACCOUNT_ID, request);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
VoiceCodeResponse result = apiInstance.generateVoiceCode(accountId, codeRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MfaApi#generateVoiceCode");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Expand Down Expand Up @@ -402,53 +385,35 @@ paths:
}
}
- 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;

source: |
import com.bandwidth.sdk.ApiClient;
import com.bandwidth.sdk.ApiException;
import com.bandwidth.sdk.Configuration;
import com.bandwidth.sdk.auth.*;
import com.bandwidth.sdk.model.*;
import com.bandwidth.sdk.api.MfaApi;

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);
ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure HTTP basic authorization: Basic
HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
Basic.setUsername("YOUR USERNAME");
Basic.setPassword("YOUR PASSWORD");

MfaApi apiInstance = new MfaApi(defaultClient);
String accountId = "9900000"; // String | Your Bandwidth Account ID.
CodeRequest codeRequest = new CodeRequest(); // CodeRequest | MFA code request body.
try {
CompletableFuture<ApiResponse<TwoFactorMessagingResponse>> completableFuture = client.getMultiFactorAuthClient().getMFAController().createMessagingTwoFactorAsync(ACCOUNT_ID, request);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
MessagingCodeResponse result = apiInstance.generateMessagingCode(accountId, codeRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MfaApi#generateMessagingCode");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Expand Down Expand Up @@ -701,51 +666,35 @@ paths:
}
}
- 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;

source: |
import com.bandwidth.sdk.ApiClient;
import com.bandwidth.sdk.ApiException;
import com.bandwidth.sdk.Configuration;
import com.bandwidth.sdk.auth.*;
import com.bandwidth.sdk.model.*;
import com.bandwidth.sdk.api.MfaApi;

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);
ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure HTTP basic authorization: Basic
HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
Basic.setUsername("YOUR USERNAME");
Basic.setPassword("YOUR PASSWORD");

MfaApi apiInstance = new MfaApi(defaultClient);
String accountId = "9900000"; // String | Your Bandwidth Account ID.
VerifyCodeRequest verifyCodeRequest = new VerifyCodeRequest(); // VerifyCodeRequest | MFA code verify request body.
try {
CompletableFuture<ApiResponse<TwoFactorVerifyCodeResponse>> completableFuture = client.getMultiFactorAuthClient().getMFAController().createVerifyTwoFactorAsync(ACCOUNT_ID, request);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
VerifyCodeResponse result = apiInstance.verifyCode(accountId, verifyCodeRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MfaApi#verifyCode");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Expand Down
Loading