Skip to content

Commit 225011f

Browse files
committed
Only use secure channel
1 parent 5a56bc5 commit 225011f

File tree

6 files changed

+16
-30
lines changed

6 files changed

+16
-30
lines changed

examples/Sms/send-sms.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//require_once(__DIR__ . '/../../src/Instasent/SmsClient.php');
99

1010
$instasentClient = new Instasent\SmsClient("my-token");
11-
$response = $instasentClient->sendSms("test", "+34647000000", "test message");
11+
$response = $instasentClient->sendSms("test", "+34647188472", "test message");
1212

1313
echo $response["response_code"];
1414
echo $response["response_body"];

src/Instasent/Abstracts/InstasentClient.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,13 @@
1313

1414
abstract class InstasentClient
1515
{
16-
/**
17-
* Endpoint URL
18-
*
19-
* @var string
20-
*/
21-
protected $rootEndpoint = 'http://api.instasent.com';
2216

2317
/**
2418
* Secure Channel URL
2519
*
2620
* @var string
2721
*/
28-
protected $secureChannel = 'http://api.instasent.com';
22+
protected $secureChannel = 'https://api.instasent.com';
2923

3024
/**
3125
* Api Token
@@ -34,23 +28,15 @@ abstract class InstasentClient
3428
*/
3529
protected $token;
3630

37-
/**
38-
* Use secure channel flag
39-
*
40-
* @var boolean
41-
*/
42-
protected $useSecureChannel = true;
43-
4431
/**
4532
* InstasentClient constructor.
4633
*
4734
* @param $token
4835
* @param bool $useSecureChannel
4936
*/
50-
public function __construct($token, $useSecureChannel = true)
37+
public function __construct($token)
5138
{
5239
$this->token = $token;
53-
$this->useSecureChannel = $useSecureChannel;
5440
}
5541

5642
/**

src/Instasent/AccountClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class AccountClient extends InstasentClient
2323
*/
2424
public function getAccountBalance()
2525
{
26-
$url = ($this->useSecureChannel) ? $this->secureChannel.'/organization/account/' : $this->rootEndpoint.'/organization/account/';
26+
$url = $this->secureChannel.'/organization/account/';
2727
$httpMethod = 'GET';
2828
return $this->execRequest($url, $httpMethod, array());
2929
}

src/Instasent/LookupClient.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class LookupClient extends InstasentClient
2424
*/
2525
public function doLookup($to)
2626
{
27-
$url = ($this->useSecureChannel) ? $this->secureChannel.'/lookup/' : $this->rootEndpoint.'/lookup/';
27+
$url = $this->secureChannel.'/lookup/';
2828
$httpMethod = 'POST';
2929
$data = array('to' => $to);
3030

@@ -39,7 +39,7 @@ public function doLookup($to)
3939
*/
4040
public function getLookupById($id)
4141
{
42-
$url = ($this->useSecureChannel) ? $this->secureChannel.'/lookup/'.$id : $this->rootEndpoint.'/lookup/'.$id;
42+
$url = $this->secureChannel.'/lookup/'.$id;
4343
$httpMethod = 'GET';
4444
return $this->execRequest($url, $httpMethod, array());
4545
}
@@ -54,7 +54,7 @@ public function getLookupById($id)
5454
public function getLookups($page = 1, $perPage = 10)
5555
{
5656
$query = http_build_query(array('page' => $page, 'per_page' => $perPage));
57-
$url = ($this->useSecureChannel) ? $this->secureChannel.'/lookup/?'.$query : $this->rootEndpoint.'/lookup/?'.$query;
57+
$url = $this->secureChannel.'/lookup/?'.$query;
5858
$httpMethod = 'GET';
5959
return $this->execRequest($url, $httpMethod, array());
6060
}

src/Instasent/SmsClient.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class SmsClient extends InstasentClient
2727
*/
2828
public function sendSms($from, $to, $text, $clientId = null)
2929
{
30-
$url = ($this->useSecureChannel) ? $this->secureChannel.'/sms/' : $this->rootEndpoint.'/sms/';
30+
$url = $this->secureChannel.'/sms/';
3131
$httpMethod = 'POST';
3232
$data = array('from' => $from, 'to' => $to, 'text' => $text);
3333
if ($clientId) {
@@ -47,7 +47,7 @@ public function sendSms($from, $to, $text, $clientId = null)
4747
*/
4848
public function sendUnicodeSms($from, $to, $text, $clientId = null)
4949
{
50-
$url = ($this->useSecureChannel) ? $this->secureChannel.'/sms/' : $this->rootEndpoint.'/sms/';
50+
$url = $this->secureChannel.'/sms/';
5151
$httpMethod = 'POST';
5252
$data = array('allowUnicode' => true, 'from' => $from, 'to' => $to, 'text' => $text);
5353
if ($clientId) {
@@ -67,7 +67,7 @@ public function sendUnicodeSms($from, $to, $text, $clientId = null)
6767
*/
6868
public function sendBulkSms($messages, $clientId = null)
6969
{
70-
$url = ($this->useSecureChannel) ? $this->secureChannel.'/sms/bulk/' : $this->rootEndpoint.'/sms/bulk/';
70+
$url = $this->secureChannel.'/sms/bulk/';
7171
$httpMethod = 'POST';
7272

7373
if ($clientId) {
@@ -84,7 +84,7 @@ public function sendBulkSms($messages, $clientId = null)
8484
*/
8585
public function getSmsById($id)
8686
{
87-
$url = ($this->useSecureChannel) ? $this->secureChannel.'/sms/'.$id : $this->rootEndpoint.'/sms/'.$id;
87+
$url = $this->secureChannel.'/sms/'.$id;
8888
$httpMethod = 'GET';
8989
return $this->execRequest($url, $httpMethod, array());
9090
}
@@ -99,7 +99,7 @@ public function getSmsById($id)
9999
public function getSms($page = 1, $perPage = 10)
100100
{
101101
$query = http_build_query(array('page' => $page, 'per_page' => $perPage));
102-
$url = ($this->useSecureChannel) ? $this->secureChannel.'/sms/?'.$query : $this->rootEndpoint.'/sms/?'.$query;
102+
$url = $this->secureChannel.'/sms/?'.$query;
103103
$httpMethod = 'GET';
104104
return $this->execRequest($url, $httpMethod, array());
105105
}

src/Instasent/VerifyClient.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class VerifyClient extends InstasentClient
2929
*/
3030
public function requestVerify($from, $to, $text, $tokenLength = null, $timeout = null, $clientId = null)
3131
{
32-
$url = ($this->useSecureChannel) ? $this->secureChannel.'/verify/' : $this->rootEndpoint.'/verify/';
32+
$url = $this->secureChannel.'/verify/';
3333
$httpMethod = 'POST';
3434
$data = array('sms' => array('from' => $from, 'to' => $to, 'text' => $text));
3535

@@ -58,7 +58,7 @@ public function requestVerify($from, $to, $text, $tokenLength = null, $timeout =
5858
*/
5959
public function checkVerify($id, $token)
6060
{
61-
$url = ($this->useSecureChannel) ? $this->secureChannel.'/verify/'.$id : $this->rootEndpoint.'/verify/'.$id;
61+
$url = $this->secureChannel.'/verify/'.$id;
6262
$url .= '?token='.$token;
6363
$httpMethod = 'GET';
6464
return $this->execRequest($url, $httpMethod, array());
@@ -72,7 +72,7 @@ public function checkVerify($id, $token)
7272
*/
7373
public function getVerifyById($id)
7474
{
75-
$url = ($this->useSecureChannel) ? $this->secureChannel.'/verify/'.$id : $this->rootEndpoint.'/verify/'.$id;
75+
$url = $this->secureChannel.'/verify/'.$id;
7676
$httpMethod = 'GET';
7777
return $this->execRequest($url, $httpMethod, array());
7878
}
@@ -87,7 +87,7 @@ public function getVerifyById($id)
8787
public function getVerify($page = 1, $perPage = 10)
8888
{
8989
$query = http_build_query(array('page' => $page, 'per_page' => $perPage));
90-
$url = ($this->useSecureChannel) ? $this->secureChannel.'/verify/?'.$query : $this->rootEndpoint.'/verify/?'.$query;
90+
$url = $this->secureChannel.'/verify/?'.$query;
9191
$httpMethod = 'GET';
9292
return $this->execRequest($url, $httpMethod, array());
9393
}

0 commit comments

Comments
 (0)