|
1 | | -# Bandwidth Numbers Java SDK |
| 1 | +# IMPORTANT! This SDK has been Deprecated! |
2 | 2 |
|
3 | | -Java SDK for Bandwidth's number management API. |
| 3 | +This SDK is no longer supported by Bandwidth and has been deprecated. Please use the SDK found here instead: https://github.com/Bandwidth/java-bandwidth-iris |
4 | 4 |
|
5 | | -## Release Notes |
6 | | - |
7 | | -| Version | Notes | |
8 | | -|:---|:---| |
9 | | -| 0.3.0 | Fixed `quantity` and `tollFreeWildCardPattern` for search requests | |
10 | | - |
11 | | -## Dependency |
12 | | - |
13 | | -### Maven |
14 | | -```xml |
15 | | -<dependency> |
16 | | - <groupId>com.bandwidth.sdk</groupId> |
17 | | - <artifactId>numbers</artifactId> |
18 | | - <version>(put desired version here)</version> |
19 | | -</dependency> |
20 | | -``` |
21 | | - |
22 | | -### Gradle |
23 | | -``` |
24 | | -compile 'com.bandwidth.sdk:numbers:(put desired version here)' |
25 | | -``` |
26 | | - |
27 | | - |
28 | | -## Quick Start |
29 | | - |
30 | | -All objects in the SDK follow the Builder pattern for easy construction. To search for and order numbers, construct the |
31 | | -relevant request and pass it to the appropriate client method. |
32 | | - |
33 | | -### Construct the client |
34 | | -Instances of the NumbersClient must be closed, typically on application shutdown to avoid resource leaks. Use the |
35 | | -provided close method. The client also implements the AutoClosable interface for convenient use in try-with-resources |
36 | | -blocks. |
37 | | - |
38 | | -The client builder exposes a configuration method that allows access to the underlying AsyncHttpClient configuration |
39 | | -should you want to configure it. See the [documentation](https://github.com/AsyncHttpClient/async-http-client) for that |
40 | | -project to see what can be configured. |
41 | | -```java |
42 | | -NumbersClientImpl numbersClient = NumbersClientImpl.builder() |
43 | | - .account("1") |
44 | | - .username("username") |
45 | | - .password("password") |
46 | | - .build(); |
47 | | - |
48 | | -// Optionally an AsyncHttpClientConfig may be provided to fine tune settings |
49 | | -NumbersClientImpl numbersClient = NumbersClientImpl.builder() |
50 | | - .account("1") |
51 | | - .username("username") |
52 | | - .password("password") |
53 | | - .config( |
54 | | - new DefaultAsyncHttpClientConfig.Builder() |
55 | | - .setRequestTimeout(60_000) |
56 | | - .build()) |
57 | | - .build(); |
58 | | -``` |
59 | | - |
60 | | -### Search for available telephone numbers |
61 | | -```java |
62 | | -AvailableNumberSearchRequest availableNumberSearchRequest = AvailableNumberSearchRequest.builder() |
63 | | - .state("NC") |
64 | | - .city("CARY") |
65 | | - .enableTNDetail(false) |
66 | | - .quantity(10) |
67 | | - .tollFreeWildCardPattern("8**") |
68 | | - .build(); |
69 | | - |
70 | | -SearchResult searchResult = numbersClient.getAvailableTelephoneNumbers(availableNumberSearchRequest); |
71 | | -``` |
72 | | - |
73 | | -### Place an order for telephone numbers |
74 | | -Placing an order is a synchronous operation that will submit an order request to bandwidth and poll until the order has |
75 | | -completed behind the scenes. One invocation may result in several API calls in the background before control returns to |
76 | | -the calling thread. |
77 | | -```java |
78 | | -// Each order type has a separate implementation |
79 | | -ExistingTelephoneNumberOrderType existingTelephoneNumberOrderType = ExistingTelephoneNumberOrderType.builder() |
80 | | - .addTelephoneNumberList("8042994451") |
81 | | - .build(); |
82 | | - |
83 | | -// Wrap the order type in an Order wrapper and choose site id and peer for numbers to be associated with |
84 | | -Order order = Order.builder() |
85 | | - .siteId("1") |
86 | | - .peerId("500539") |
87 | | - .existingTelephoneNumberOrderType(existingTelephoneNumberOrderType) |
88 | | - .build(); |
89 | | - |
90 | | -OrderResponse orderResponse = numbersClient.orderTelephoneNumbers(order); |
91 | | -``` |
92 | | - |
93 | | -### Important Links |
94 | | -* [Bandwidth Dashboard](https://dashboard.bandwidth.com/portal/report/#login:) |
95 | | -* [Bandwidth Application](https://app.bandwidth.com/login) |
96 | | -* [Bandwidth Developer Homepage](https://dev.bandwidth.com/) |
97 | | - |
98 | | - |
99 | | - |
100 | | -```java |
101 | | -public class MyAwesomeBandwidthNumbersApp { |
102 | | - |
103 | | - public static void main(String[] args) { |
104 | | - |
105 | | - try (NumbersClientImpl numbersClient = NumbersClientImpl.builder() |
106 | | - .account("1") |
107 | | - .username("username") |
108 | | - .password("password") |
109 | | - .build()) { |
110 | | - |
111 | | - AvailableNumberSearchRequest availableNumberSearchRequest = AvailableNumberSearchRequest.builder() |
112 | | - .state("NC") |
113 | | - .city("CARY") |
114 | | - .enableTNDetail(false) |
115 | | - .quantity(10) |
116 | | - .build(); |
117 | | - |
118 | | - SearchResult searchResult = numbersClient.getAvailableTelephoneNumbers(availableNumberSearchRequest); |
119 | | - |
120 | | - // putting it all together, place an order for numbers returned from a number search |
121 | | - ExistingTelephoneNumberOrderType existingTelephoneNumberOrderType = |
122 | | - ExistingTelephoneNumberOrderType.builder() |
123 | | - .addAllTelephoneNumberList(searchResult.getTelephoneNumberList()) |
124 | | - .build(); |
125 | | - |
126 | | - Order order = Order.builder() |
127 | | - .siteId("1") |
128 | | - .peerId("500539") |
129 | | - .existingTelephoneNumberOrderType(existingTelephoneNumberOrderType) |
130 | | - .build(); |
131 | | - |
132 | | - OrderResponse orderResponse = numbersClient.orderTelephoneNumbers(order); |
133 | | - } |
134 | | - } |
135 | | -} |
136 | | -``` |
0 commit comments