Skip to content

Java Client Library for Bandwidth's Phone Number Dashboard (AKA Dashboard, Iris)

License

Notifications You must be signed in to change notification settings

mrmeyers99/java-bandwidth-iris

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java-bandwidth-iris

Java Client library for IRIS / BBS API

Installing

Bandwidth Java IRIS SDK uses Maven. The jars are available from a public Maven repository

Use the following dependency in your project:

<dependency>
  <groupId>com.bandwidth.sdk</groupId>
  <artifactId>bandwidth-java-iris-sdk</artifactId>
  <version>1.0</version>
  <scope>compile</scope>
</dependency>

If you want to compile it yourself, here's how:

$ git clone [email protected]:bandwidthcom/java-bandwidth-iris.git
$ cd java-bandwidth-iris
$ mvn install

Usage

Creating the client

IrisClient client = new IrisClient(accountId, username, password);

// You can then use the client to call a particular object's methods, e.g.
Site s = new Site();
Site returnSite = Site.create(client, s);

Examples

There is an 'examples' folder in the source tree that shows how each of the API objects work with simple example code. To run each of the examples, set them as run targets in your IDE, then set the following system environment variables:

export BANDWIDTH_IRIS_ACCOUNTID=<youraccountid>
export BANDWIDTH_IRIS_USERNAME=<yourusername>
export BANDWIDTH_IRIS_PASSWORD=<yourpassword>
export BANDWIDTH_IRIS_URL=https://api.inetwork.com //OR https://api.test.inetwork.com if you are working on test network

API Objects

General principles

When fetching objects from the API, it will always return an object that has the client instantiated so that you can call dependent methods as well as update, delete.

Example:

Site newSite = new Site();
newSite.setName("My New Site");

Site s = Site.create(client, newSite);
s.setName("Some Other Name");
s.update();
//then
s.delete();// etc

Each entity, where appropriate has a get, list, create, update and delete method

Available Numbers

Map<String, Object> query = new HashMap<String, Object>();
query.put("areaCode", "205");
query.put("enableTNDetail", true);
query.put("quantity", 2);

List<TelephoneNumberDetail> numbers = (List<TelephoneNumberDetail>) AvailableNumbers.search(client, query);
for (TelephoneNumberDetail number : numbers)
{
    System.out.println(String.format("Full number: %s : Rate Center: %s", number.getFullNumber(), number.getRateCenter()));
}

Available NpaNxx

Map<String, Object> query = new HashMap<String, Object>();
query.put("areaCode", "805");
query.put("quantity", 2);
List<AvailableNpaNxx> availableNpaNxxList = AvailableNpaNxx.list(client, query);
for(AvailableNpaNxx npaNxx : availableNpaNxxList){
    System.out.println(
      String.format("City: %s | Npa: %s | Nxx: %s | State: %s ", npaNxx.getCity(), npaNxx.getNpa(),
              npaNxx.getNxx(), npaNxx.getState())
    );
}

Cities

Map<String, Object> query = new HashMap<String, Object>();
query.put("state", "NC");

List<City> cities = City.list(client, query);
for(City c : cities){
    System.out.println(String.format("Name: %s | RcAbbreviation: %s", c.getName(), c.getRcAbbreviation()));
}

Covered Rate Centers

Map<String, Object> query = new HashMap<String, Object>();
query.put("state", "NC");

List<CoveredRateCenter> rateCenters = CoveredRateCenter.list(client, query);
for(CoveredRateCenter rc : rateCenters){
    System.out.println(String.format("Name: %s | Abbreviation: %s | State: %s | Lata: %s", rc.getName(),
            rc.getAbbreviation(), rc.getState(), rc.getLata()));
}

Disconnect Numbers

The Disconnect object is used to disconnect numbers from an account. Creates a disconnect order that can be tracked

Create Disconnect

DisconnectTelephoneNumberOrder disco = new DisconnectTelephoneNumberOrder();
disco.setName("A test order");
disco.getDisconnectTelephoneNumberOrderType().getTelephoneNumberList().add("9195551212");

DisconnectTelephoneNumberOrderResponse response = DisconnectTelephoneNumberOrder.create(client, disco);

Get Disconnect

DisconnectTelephoneNumberOrderResponse response = DisconnectTelephoneNumberOrder.get(client, "orderId");

Dlda

Create Ddla

DldaTnGroup dldaTnGroup = new DldaTnGroup();
dldaTnGroup.getTelephoneNumberList().add("9195551212");
dldaTnGroup.setAccountType("RESIDENTIAL");
dldaTnGroup.setListingType("LISTED");
DldaOrder order = new DldaOrder();
order.getDldaTnGroups().add(dldaTnGroup);

DldaOrder newOrder = DldaOrder.create(client, order);

Get Dlda

DldaOrder order = DldaOrder.get(client, "orderId");

List Dldas

Map<String, Object> query = new HashMap<String, Object>();
query.put("telephoneNumber", "9195551212");

ResponseSelectWrapper wrapper = DldaOrder.list(client, query);

In Service Numbers

List InService Numbers

Map<String, Object> query = new HashMap<String, Object>();
query.put("state", "NC");

TNs tns = InserviceNumber.list(getDefaultClient(), query);

Lidb

Create

LidbTnGroup group = new LidbTnGroup();
group.getTelephoneNumberList().add("9195551212");
LidbOrder order = new LidbOrder();
order.getLidbTnGroupList().add(group);
order = LidbOrder.create(client, order);

Get Lidb

LidbOrder order = LidbOrder.get(client, "orderId");

LNP Checker

Check LNP

NumberPortabilityRequest request = new NumberPortabilityRequest();
request.getTnList().add("9195551212");
NumberPortabilityResponse response = LnpChecker.checkLnp(client, request, "true");
System.out.println(response.getPortableNumbers().get(0));

Orders

Create Order

Order o = new Order();
o.setName("A New Order");
ExistingTelephoneNumberOrderType existingTelephoneNumberOrderType = new ExistingTelephoneNumberOrderType();
existingTelephoneNumberOrderType.getTelephoneNumberList().add("2052865046");
o.setExistingTelephoneNumberOrderType(existingTelephoneNumberOrderType);

OrderResponse createdOrder = Order.create(client, o);

Get Order

Order o = Order.get(client, "orderId");

Order Instance Methods

order.update();
order.delete();
order.getNotes()
order.addNote(Note n);

Port Ins

Create PortIn

LnpOrder order = new LnpOrder();
order.setSiteId(getFirstSite().getId());
order.setPeerId(getFirstSipPeer().getPeerId());
order.setBillingTelephoneNumber("9195551212");
Subscriber s = new Subscriber();
s.setSubscriberType("BUSINESS");
s.setBusinessName("Company");
ServiceAddress serviceAddress = new ServiceAddress();
serviceAddress.setHouseNumber("123");
serviceAddress.setStreetName("Anywhere St");
serviceAddress.setCity("Raleigh");
serviceAddress.setStateCode("NC");
serviceAddress.setZip("27609");
s.setServiceAddress(serviceAddress);
order.setSubscriber(s);
order.setLoaAuthorizingPerson("Joe Blow");
order.getListOfPhoneNumbers().add("9195551212");

order = LnpOrder.create(client, order);

Get PortIn

LnpOrder order = LnpOrder.get(client, "orderId");

PortIn Instance methods

order.update(client, LnpOrderSupp supp);
order.delete();

PortIn File Management

order.uploadLoa(File file, LoaFileType type);
order.updateLoa(File file, LoaFileType type);
order.deleteLoa(String fileName);
order.getLoaMetaData(String fileName);
order.updateLoaMetaData(String fileName, FileMetaData metaData);
order.deleteLoaMetaData(String fileName);

Rate Centers

List Ratecenters

Map<String, Object> query = new HashMap<String, Object>();
query.put("state", "NC");
query.put("available", true);

List<RateCenter> rateCenters = RateCenter.list(client,query);
for(RateCenter rc : rateCenters){
    System.out.println(String.format("Name: %s | Abbreviation: %s", rc.getName(), rc.getAbbreviation()));
}

SIP Peers

Create SIP Peer

Host host = new Host();
host.setHostName("new host");

TerminationHost termHost = new TerminationHost();
termHost.setHostName("term host");
termHost.setPort("5060");

SipPeer peer = new SipPeer();
peer.setPeerName("A new Sip Peer");
peer.setDefaultPeer(false);
peer.setShortMessagingProtocol("SMPP");
peer.setSiteId(getFirstSite().getId());

peer.getVoiceHosts().add(host);
peer.getSmsHosts().add(host);
peer.getTerminationHosts().add(termHost);

peer = SipPeer.create(client, getFirstSite().getId(), peer);

Get SIP Peer

SipPeer peer = SipPeer.get(client, "peerId");

List SIP Peers

List<SipPeer> peers = SipPeer.list(client, "siteId");

Delete SIP Peer

SipPeer peer = SipPeer.get(client, "peerId");
peer.delete()

SipPeer TN Methods

peer.updateTn(sipPeerTelephoneNumber);
peer.getTn("number");
peer.moveTns(sipPeerTelephoneNumbers);

Sites

Create A Site

A site is what is called Location in the web UI.

Site s = new Site();
s.setName("My New Site");

s = Site.create(client, s);

Updating a Site

Site s = Site.get(client, "siteId");
s.setName("New Name");
s.update();

Deleting a Site

Site s = Site.get(client, "siteId");
s.delete();

Listing All Sites

List<Site> sites = Site.list(client);

Subscriptions

Create Subscription

Subscription subscription = new Subscription();
subscription.setOrderType("orders");
subscription.setOrderId("orderId");
EmailSubscription emailSubscription = new EmailSubscription();
emailSubscription.setEmail("[email protected]");
emailSubscription.setDigestRequested("NONE");
subscription.setEmailSubscription(emailSubscription);
Subscription createdSubscription = Subscription.create(getDefaultClient(), subscription);

Get Subscription

Subscription s = Subscription.get(client, "subscriptionId");

List Subscriptions

Map<String, Object> query = new HashMap<String, Object>();
query.put("orderType", "orders");

List<Subscription> subscriptions = Subscription.list(client, query);

Subscription Instance Methods

subscription.update();
subcription.delete();

TNs

Get TN

TelephoneNumberDetail detail = Tns.getTnDetails(getClient(), "9195551212");

List TNs

Map<String, Object> query = new HashMap<String, Object>();
query.put("state", "NC");

TelephoneNumbersResponse response = Tns.list(getClient(),query );

TN Reservation

Create TN Reservation

Reservation r = new Reservation();
r.getReservedTn().add("9195551212");
r = Reservation.create(client, r);

Get TN Reservation

Reservation r = Reservation.get(getDefaultClient(), "9195551212");

Delete TN Reservation

Reservation r = Reservation.get(getDefaultClient(), "9195551212");
r.delete();

About

Java Client Library for Bandwidth's Phone Number Dashboard (AKA Dashboard, Iris)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%