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

Commit

Permalink
Add Code Snippets to Spec Files
Browse files Browse the repository at this point in the history
  • Loading branch information
DX-Bandwidth committed Oct 12, 2023
1 parent f2509f4 commit bfdf593
Show file tree
Hide file tree
Showing 8 changed files with 8,687 additions and 6,183 deletions.
2,913 changes: 2,913 additions & 0 deletions site/specs/emergency.yml

Large diffs are not rendered by default.

452 changes: 240 additions & 212 deletions site/specs/messaging.yml

Large diffs are not rendered by default.

303 changes: 127 additions & 176 deletions site/specs/multi-factor-auth.yml

Large diffs are not rendered by default.

210 changes: 126 additions & 84 deletions site/specs/numbers.yml

Large diffs are not rendered by default.

7,031 changes: 4,222 additions & 2,809 deletions site/specs/numbers_v2.yml

Large diffs are not rendered by default.

166 changes: 70 additions & 96 deletions site/specs/phone-number-lookup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,36 +99,34 @@ paths:
}
- lang: Java
source: |
import com.bandwidth.BandwidthClient;
import com.bandwidth.http.response.ApiResponse;
import com.bandwidth.phonenumberlookup.models.OrderRequest;
import com.bandwidth.phonenumberlookup.models.OrderResponse;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.ArrayList;
import java.util.List;
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.PhoneNumberLookupApi;
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 void main(String[] args) {
BandwidthClient client = new BandwidthClient.Builder()
.phoneNumberLookupBasicAuthCredentials(USERNAME, PASSWORD)
.build();
List<String> numbers = new ArrayList<>();
numbers.add("+15553334444");
ApiClient defaultClient = Configuration.getDefaultApiClient();
OrderRequest request = new OrderRequest(numbers);
// Configure HTTP basic authorization: Basic
HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
Basic.setUsername("YOUR USERNAME");
Basic.setPassword("YOUR PASSWORD");
PhoneNumberLookupApi apiInstance = new PhoneNumberLookupApi(defaultClient);
String accountId = "9900000"; // String | Your Bandwidth Account ID.
LookupRequest lookupRequest = new LookupRequest(); // LookupRequest | Phone number lookup request.
try {
CompletableFuture<ApiResponse<OrderResponse>> completableFuture = client.getPhoneNumberLookupClient().getAPIController().createLookupRequestAsync(ACCOUNT_ID, request);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
CreateLookupResponse result = apiInstance.createLookup(accountId, lookupRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PhoneNumberLookupApi#createLookup");
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 @@ -213,40 +211,28 @@ paths:
print(e.response_code)
- lang: Ruby
source: >
require 'bandwidth'
include Bandwidth
include Bandwidth::Voice
BW_USERNAME = "api-username"
BW_PASSWORD = "api-password"
BW_ACCOUNT_ID = "12345"
require 'bandwidth-sdk'
bandwidth_client = Bandwidth::Client.new(
phone_number_lookup_basic_auth_user_name: BW_USERNAME,
phone_number_lookup_basic_auth_password: BW_PASSWORD
)
Bandwidth.configure do |config|
config.username = 'api-username'
config.password = 'api-password'
end
phone_number_lookup_client =
bandwidth_client.phone_number_lookup_client.client
api_instance = Bandwidth::PhoneNumberLookupApi.new
body = OrderRequest.new
account_id = '12345'
body.tns = ["+15554443333"]
lookup_request = Bandwidth::LookupRequest.new({ tns:
['+15554443333'] })
begin
result = phone_number_lookup_client.create_lookup_request(BW_ACCOUNT_ID, body)
puts result.data.request_id
rescue APIException => e
puts e.response_code
result = api_instance.create_lookup(account_id, lookup_request)
p result.request_id
rescue Bandwidth::ApiError => e
p "Error when calling PhoneNumberLookupApi->create_lookup: #{e}"
end
/accounts/{accountId}/tnlookup/{requestId}:
get:
Expand Down Expand Up @@ -315,30 +301,34 @@ paths:
}
- lang: Java
source: |
import com.bandwidth.BandwidthClient;
import com.bandwidth.http.response.ApiResponse;
import com.bandwidth.phonenumberlookup.models.OrderStatus;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
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.PhoneNumberLookupApi;
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 void main(String[] args) {
BandwidthClient client = new BandwidthClient.Builder()
.phoneNumberLookupBasicAuthCredentials(USERNAME, PASSWORD)
.build();
ApiClient defaultClient = Configuration.getDefaultApiClient();
String requestId = "8a358296-e188-4a3a-b974-8e4d12001dd8";
// Configure HTTP basic authorization: Basic
HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
Basic.setUsername("YOUR USERNAME");
Basic.setPassword("YOUR PASSWORD");
PhoneNumberLookupApi apiInstance = new PhoneNumberLookupApi(defaultClient);
String accountId = "9900000"; // String | Your Bandwidth Account ID.
String requestId = "004223a0-8b17-41b1-bf81-20732adf5590"; // String | The phone number lookup request ID from Bandwidth.
try {
CompletableFuture<ApiResponse<OrderStatus>> completableFuture = client.getPhoneNumberLookupClient().getAPIController().getLookupRequestStatusAsync(ACCOUNT_ID, requestId);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
LookupStatus result = apiInstance.getLookupStatus(accountId, requestId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PhoneNumberLookupApi#getLookupStatus");
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 @@ -415,39 +405,23 @@ paths:
except APIException as e:
print(e.response_code)
- lang: Ruby
source: >
require 'bandwidth'
include Bandwidth
include Bandwidth::Voice
BW_USERNAME = "api-username"
BW_PASSWORD = "api-password"
BW_ACCOUNT_ID = "12345"
bandwidth_client = Bandwidth::Client.new(
phone_number_lookup_basic_auth_user_name: BW_USERNAME,
phone_number_lookup_basic_auth_password: BW_PASSWORD
)
phone_number_lookup_client =
bandwidth_client.phone_number_lookup_client.client
source: |
require 'bandwidth-sdk'
request_id = "1234-abcd"
Bandwidth.configure do |config|
config.username = 'api-username'
config.password = 'api-password'
end
api_instance = Bandwidth::PhoneNumberLookupApi.new
account_id = '12345'
request_id = '004223a0-8b17-41b1-bf81-20732adf5590'
begin
result = phone_number_lookup_client.get_lookup_request_status(BW_ACCOUNT_ID, request_id)
puts result.data.status
rescue APIException => e
puts e.response_code
result = api_instance.get_lookup_status(account_id, request_id)
p result.status
rescue Bandwidth::ApiError => e
p "Error when calling PhoneNumberLookupApi->get_lookup_status: #{e}"
end
components:
schemas:
Expand Down
Loading

0 comments on commit bfdf593

Please sign in to comment.