-
Notifications
You must be signed in to change notification settings - Fork 3
/
demo.php
113 lines (89 loc) · 3.15 KB
/
demo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
require_once('vendor/autoload.php');
foreach (glob('src/*.php') as $filename){require_once $filename;}
foreach (glob('src/Controllers/*.php') as $filename){require_once $filename;}
foreach (glob('src/Models/*.php') as $filename){require_once $filename;}
use FlowrouteNumbersLib\Controllers\InboundRoutesController;
use FlowrouteNumbersLib\Controllers\PurchasablePhoneNumbersController;
use FlowrouteNumbersLib\Controllers\TelephoneNumbersController;
use FlowrouteNumbersLib\APIException;
use FlowrouteNumbersLib\Models\BillingMethod;
print "Number Control Demo." . PHP_EOL;
//--- Purchasable Phone Numbers
// Create our controller
$pnc = new PurchasablePhoneNumbersController();
// Retrieve Available NPAs
print("--Retrieve Available NPAs\n");
$response = $pnc->listAvailableNPAs(10);
print_r($response);
// Retrieve Available NPA NXXs
print("--Retrieve Available NPA NXXs\n");
$response = $pnc->listAreaAndExchange();
print_r($response);
// Search for purchasable Numbers
print("--Search for numbers in Seattle Washington\n");
$response = $pnc->search(10,206,641,null,'seattle','wa',null);
print_r($response);
//--- Telephone Numbers
// Create our controller
$tnc = new TelephoneNumbersController();
// Purchase a Phone Number
print("--Purchase a Phone Number\n");
$billing = new BillingMethod('METERED');
$number = '12066417661';
try {
$response = $tnc->purchase($billing, $number);
print_r($response);
} catch(APIException $e) {
print("Error - " . strval($e->getResponseCode()) . ' ' . $e->getMessage() . PHP_EOL);
}
// List Account Phone Numbers
print("--List Account Phone Numbers\n");
try {
$response = $tnc->listAccountTelephoneNumbers();
print_r($response);
} catch(APIException $e) {
print("Error - " . strval($e->getResponseCode()) . ' ' . $e->getMessage() . PHP_EOL);
}
// Retrieve Phone Number Details
print("--Retrieve Number Details\n");
try {
$response = $tnc->telephoneNumberDetails($number);
print_r($response);
} catch(APIException $e) {
print("Error - " . strval($e->getResponseCode()) . ' ' . $e->getMessage() . PHP_EOL);
}
//--- Inbound Routes
// Create our controller
$inbound = new InboundRoutesController();
// Retrieve Routes
print("--Retrieve Inbound Routes\n");
try {
$response = $inbound->mlist();
print_r($response);
} catch(APIException $e) {
print("Error - " . strval($e->getResponseCode()) . ' ' . $e->getMessage() . PHP_EOL);
}
// Create Route
print("--Create New Inbound Route\n");
try {
$routename = 'PSTNroute1';
$routetype = 'PSTN';
$routevalue = '12065551212';
$response = $inbound->createNewRoute($routename, $routetype, $routevalue);
print_r("New Inbound Route Successfully Created\n");
} catch(APIException $e) {
print("Error - " . strval($e->getResponseCode()) . ' ' . $e->getMessage() . PHP_EOL);
}
//update routes
print("--Update TN's Primary and Failover Route\n");
try {
$rtes = '{"routes": [{"name": "PSTNroute1"}, {"name": "PSTNroute1"}]}';
$tn = "19515551212";
$response = $tnc->update($tn, $rtes);
print_r($response);
} catch(APIException $e) {
print("Error - " . strval($e->getResponseCode()) . ' ' . $e->getMessage() . PHP_EOL);
}