.NET API Wrapper

The Flowroute .NET API Wrapper provides methods for interacting with Number Management v1 and Messaging v2 of the Flowroute API.

Requirements


Installation

Use the Package Manager Console built into Visual Studio (2012 or later) to install the Flowroute .NET SDK.

Install-Package Flowroute

            

Initialization

Initialize a new instance of the Flowroute client as follows:

string AccessKey = "accessKey";
string SecretKey = "secretKey";

FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);

            

Credentials

Replace accessKey:secretKey with your API credentials from the Flowroute Manager.

Usage

The Flowroute .NET SDK uses asynchronous methods to avoid performance bottlenecks and enhance the overall responsiveness of the application. Read more about asynchronous programming here.

Numbers SDK (v1)

View Repo

Number Management

After you have created an instance of the Flowroute client, you will have access to the PhoneNumbers client. This client provides the following methods:

Methods

ListAvailableNPAsAsync()

The method accepts the limit and page parameters which you can learn more about in the API reference. The following example limits the number of NPAs returned to 2:

#List Available NPAs
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var results = await client.PhoneNumbers.ListAvailableNPAsAsync(2);

            
Example Response
{
 "npas": {
   "201": {
     "nxxs": "/v1/available-tns/npanxxs/?npa=201",
    "tns": "/v1/available-tns/tns/?npa=201"
   },
   "202": {
      "nxxs": "/v1/available-tns/npanxxs/?npa=202",
      "tns": "/v1/available-tns/tns/?npa=202"
    }
  },
  "links": {
  "next": "/v1/available-tns/npas/?limit=2&page=2"
  }
}
            
            
RetrieveAvailableNPANetworkNumberingExchangesAsync()

The method accepts the limit, npa, and page parameters which you can learn more about in the API reference. The following example restricts the npa to 757:

#List NPA and NXX
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var results = await client.PhoneNumbers.RetrieveAvailableNPANetworkNumberingExchangesAsync(757);

            
Example Response

Results are returned in numerical order, starting with the lowest NPA number. The npaxxs parameter variable is formatted as a combination of the NPA and NXX. In the following example, 757258 is the combination of NPA 757 and NXX 258.

{
"npanxxs": {
  "757258": {
    "tns": "/v1/available-tns/tns/?npa=757"
   },
   "757238": {
     "tns": "/v1/available-tns/tns/?npa=757"
    }
  },
  "links": {
    "next": "/v1/available-tns/npanxxs/?npa=757&page=2",
 }
}
            
            
SearchAsync()

The search() method is the most robust option for searching through Flowroute's purchasable phone number inventory. It allows you to search by NPA, NXX, Ratecenter, State, and/or TN (telephone number). The method accepts the limit, npa, nxx, and page parameters which you can learn more about in the API reference.

In the following example, a search request sets the npa to 757, the ratecenter to "SEATTLE", and the state to "WA".

#Search
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var results = await client.PhoneNumbers.SearchAsync(new FlowroutePhoneNumberSearchCriteria() { NPA = 757 });
var results = await client.PhoneNumbers.SearchAsync(new FlowroutePhoneNumberSearchCriteria() { RateCenter = "SEATTLE", State = "WA" });

            
Example Response
{
"links": {
  "next": "/v1/available-tns/tns/?npa=757&state=WA&ratecenter=SEATTLE"
 },
 "tns": {
    "17576439178": {
     "initial_cost": "1.00",
     "monthly_cost": "1.25",
    "state": "WA",
    "ratecenter": "SEATTLE",
    "billing_methods": [
     "METERED"
   ]
   }
     }
}
            
            
PurchasePhoneNumber()

The purchase() method is used to purchase a telephone number from Flowroute's inventory. The method accepts the telephone_number parameter which you can learn more about in the API reference.

#Purchase a Telephone Number
var goodPhoneNumber = "17575555555";
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var results = await client.PhoneNumbers.PurchasePhoneNumberAsync(goodPhoneNumber);

            
Example Response

For a successful purchase, the API returns an empty line. No other success message is displayed.

201 Created
{ }
           
            
ListTelephoneNumbers()

The method accepts the limit, page, and pattern parameters which you can learn more about in the API reference.

#List Account Telephone Numbers
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var results = await client.PhoneNumbers.ListTelephoneNumbersAsync();

            
ListTelephoneNumberDetails()

The method accepts the telephone_number parameter which you can learn more about in the API reference. In the following example, details are requested for the telephone number just purchased using the purchase method.

#Telephone Number Details
var goodPhoneNumber = "17575555555";
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var results = await client.PhoneNumbers.ListTelephoneNumberDetailsAsync(goodPhoneNumber);

            
UpdateTelephoneNumberRoutes()

The method accepts the routes and telephone_number parameters which you can learn more about in the API reference.

#Update Telephone Number Routes
var goodPhoneNumber = "17575555555";
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var results = await client.PhoneNumbers.UpdateTelephoneNumberRoutesAsync(goodPhoneNumber,
    new FlowrouteRoute() { Name = "Primary1" },
    new FlowrouteRoute() { Name = "Primary2" });

            
ListInboundRoutes()

The method accepts the limit and page parameters which you can learn more about in the API reference.

#List Routes
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var results = await client.PhoneNumbers.ListInboundRoutesAsync();

            
createNewRoute()

The method accepts the route_name, type, and value parameters which you can learn more about in the API reference.

You can pass as many createNewRoute methods in a single operation. The following example creates a new HOST route:

#Create a New Route
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var results = await client.PhoneNumbers.CreateInboundRouteAsync("TestRoute", InboundRouteType.HOST, "example.com");

            
Example Response

An empty string ('') is returned for each successfully created route; no other code or message is returned. An error encountered for a specific irc->createNewRoute() line does not prevent the other routes from being created.

' '
            
            

Messaging SDK (v2)

View Repo

Messaging

After you have created an instance of the Flowroute client, you will have access to the Messaging client. This client provides the following methods:

Methods

SendMessageAsync()

The method accepts the msg, to, from, and body parameters which you can learn more about in the API reference.

#Create and send the message
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var response = await client.Messaging.SendMessageAsync("17578675309", "17575555555", $"TestMessage");

            
GetMessageDetailsAsync()

The method accepts the record_id parameter which you can learn more about in the API reference.

#Get the MDR
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var response = await client.Messaging.GetMessageDetailsAsync('mdr1-fab29a740129404a8ca794efc1359e12');

            

©2004 - 2024 BCM One. All right reserved. Legal | Privacy Policy | Blog | News | Contact