Skip to content

Commit

Permalink
remove twilio package.
Browse files Browse the repository at this point in the history
  • Loading branch information
ihabzee committed Dec 16, 2024
1 parent 84b2fe3 commit 264495f
Show file tree
Hide file tree
Showing 1,409 changed files with 7 additions and 208,818 deletions.
73 changes: 2 additions & 71 deletions AppointmentScheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
require __DIR__ . '/vendor/autoload.php';
}

use Twilio\Rest\Client;


/**
* Constants where appointment is located
Expand Down Expand Up @@ -80,7 +80,6 @@
* Class AppointmentScheduler
* @package Stanford\AppointmentScheduler
* @property \CalendarEmail $emailClient
* @property Client $twilioClient
* @property array $instances
* @property int $eventId
* @property array $eventInstance
Expand All @@ -105,11 +104,6 @@ class AppointmentScheduler extends \ExternalModules\AbstractExternalModule
*/
private $emailClient = null;

/**
* @var Client|null
*/
private $twilioClient = null;

/**
* @var array of all instances in the project
*/
Expand Down Expand Up @@ -181,12 +175,6 @@ public function __construct()
*/
$this->setInstances();

// Initiate Twilio Client
$sid = $this->getProjectSetting('twilio_sid', $this->getProjectId());
$token = $this->getProjectSetting('twilio_token', $this->getProjectId());
if ($sid != '' && $token != '') {
$this->setTwilioClient(new Client($sid, $token));
}

$this->setProject(new \Project($this->getProjectId()));

Expand Down Expand Up @@ -290,21 +278,6 @@ public function setProjectId($projectId)
}


/**
* @return Client
*/
public function getTwilioClient()
{
return $this->twilioClient;
}

/**
* @param Client $twilioClient
*/
public function setTwilioClient($twilioClient)
{
$this->twilioClient = $twilioClient;
}

/**
* @return array
Expand Down Expand Up @@ -694,52 +667,10 @@ public function notifyUser($user)
true
);
}
if ($user['mobile'] && $this->getTwilioClient()) {
$message = array(
'from' => '+' . $instance['phone_number_country_code'] . $instance['twilio_sender_number'],
'body' => '--CONFIRMATION-- This message to confirm your appointment at ' . date('m/d/Y',
strtotime($this->calendarParams['calendarDate'])) . ' from ' . date('h:i',
strtotime($this->calendarParams['calendarStartTime'])) . ' to ' . date('h:i',
strtotime($this->calendarParams['calendarEndTime']))
);
return $this->sendTextMessage($user, $message);
}
}

/**
* @param $user
* @param $message
* @throws \Twilio\Exceptions\TwilioException
*/
private function sendTextMessage($user, $message)
{
try {
$result = $this->twilioClient->messages->create(
$user['mobile'],
$message
);
/**
* log sent message.
*/
if ($result->errorCode == null) {
$this->log('Text message sent to ' . $result->to, array(
'user_id' => UI_ID,
'from' => $result->from,
'to' => $result->to,
'body' => $result->body,
'time' => time()
));
} elseif ($result->errorCode) {
throw new \Twilio\Exceptions\TwilioException('Cant send message');
}
return array('status' => 'success', 'message' => 'Message sent successfully');
} catch (\LogicException $e) {
return array('status' => 'error', 'message' => $e->getMessage());
} catch (\Twilio\Exceptions\TwilioException $e) {
return array('status' => 'error', 'message' => $e->getMessage());
}
}


/**
* send calendar or regular emails
* @param string $email
Expand Down
2 changes: 1 addition & 1 deletion CalendarEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public function sendCalendarEmail($param){
$result = $this->send();
} catch (\LogicException $e) {
} catch (\Exception $e) {
$e->getMessage();
echo $e->getMessage();
}
}

Expand Down
6 changes: 1 addition & 5 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ If you are using Appointment Scheduler to follow up with survey participants. Yo
12. Type Calendar Email subject.
13. Type Calendar Email body.

2. If you want to send mobile text messages for reservation confirmation you can define Twilio configuration(configured only once for all instances).
1. Phone number country code(just numbers without leading zeros).
2. Phone number.
3. Twilio SID.
4. Twilio token.




Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"require": {
"twilio/sdk": "^8.3.8",
"psr/log": "^1.1",
"phpmailer/phpmailer": "^6.1",
"kigkonsult/icalcreator": "^2.29"
Expand Down
55 changes: 1 addition & 54 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 0 additions & 30 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,36 +262,6 @@
}
]
},
{
"key": "twilio_config",
"name": "<b>Twilio Config</b>",
"required": false,
"type": "descriptive"
},
{
"key": "phone_number_country_code",
"name": "<b>Country Phone code</b>",
"required": false,
"type": "text"
},
{
"key": "twilio_sender_number",
"name": "<b>Twilio Phone number to send from(Numbers only)</b>",
"required": false,
"type": "text"
},
{
"key": "twilio_sid",
"name": "<b>Twilio SID(You can find it in your Twilio dashboard)</b>",
"required": false,
"type": "text"
},
{
"key": "twilio_token",
"name": "<b>Twilio Token(You can find it in your Twilio dashboard)</b>",
"required": false,
"type": "text"
},
{
"key": "enable-project-debug-logging",
"name": "<b>Enable Debug Logging</b></h6><i> (Requires emLogger)</i><br>If you have questions enabling debugging, please contact the REDCap team for help.",
Expand Down
1 change: 0 additions & 1 deletion vendor/composer/autoload_psr4.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
$baseDir = dirname($vendorDir);

return array(
'Twilio\\' => array($vendorDir . '/twilio/sdk/src/Twilio'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
'PHPMailer\\PHPMailer\\' => array($vendorDir . '/phpmailer/phpmailer/src'),
'Kigkonsult\\Icalcreator\\' => array($vendorDir . '/kigkonsult/icalcreator/src'),
Expand Down
8 changes: 0 additions & 8 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ class ComposerStaticInit0ca2fe265bd983ef5c7398b78614ba2d
);

public static $prefixLengthsPsr4 = array (
'T' =>
array (
'Twilio\\' => 7,
),
'P' =>
array (
'Psr\\Log\\' => 8,
Expand All @@ -27,10 +23,6 @@ class ComposerStaticInit0ca2fe265bd983ef5c7398b78614ba2d
);

public static $prefixDirsPsr4 = array (
'Twilio\\' =>
array (
0 => __DIR__ . '/..' . '/twilio/sdk/src/Twilio',
),
'Psr\\Log\\' =>
array (
0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
Expand Down
56 changes: 0 additions & 56 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,62 +246,6 @@
"source": "https://github.com/php-fig/log/tree/1.1.4"
},
"install-path": "../psr/log"
},
{
"name": "twilio/sdk",
"version": "8.3.8",
"version_normalized": "8.3.8.0",
"source": {
"type": "git",
"url": "https://github.com/twilio/twilio-php.git",
"reference": "d05c08d0b9ed017f61ebbc31bc4e5f4d758a0326"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twilio/twilio-php/zipball/d05c08d0b9ed017f61ebbc31bc4e5f4d758a0326",
"reference": "d05c08d0b9ed017f61ebbc31bc4e5f4d758a0326",
"shasum": ""
},
"require": {
"php": ">=7.1.0"
},
"require-dev": {
"guzzlehttp/guzzle": "^6.3 || ^7.0",
"phpunit/phpunit": ">=7.0 < 10"
},
"suggest": {
"guzzlehttp/guzzle": "An HTTP client to execute the API requests"
},
"time": "2024-11-15T07:19:40+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Twilio\\": "src/Twilio/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Twilio API Team",
"email": "[email protected]"
}
],
"description": "A PHP wrapper for Twilio's API",
"homepage": "https://github.com/twilio/twilio-php",
"keywords": [
"api",
"sms",
"twilio"
],
"support": {
"issues": "https://github.com/twilio/twilio-php/issues",
"source": "https://github.com/twilio/twilio-php/tree/8.3.8"
},
"install-path": "../twilio/sdk"
}
],
"dev": true,
Expand Down
13 changes: 2 additions & 11 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'name' => '__root__',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '4460cb29380fb6f97a573de15792a5be269fdb0c',
'reference' => '84b2fe3ea619cfb96c62bcc796b23c134cc6031d',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -13,7 +13,7 @@
'__root__' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '4460cb29380fb6f97a573de15792a5be269fdb0c',
'reference' => '84b2fe3ea619cfb96c62bcc796b23c134cc6031d',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down Expand Up @@ -46,14 +46,5 @@
'aliases' => array(),
'dev_requirement' => false,
),
'twilio/sdk' => array(
'pretty_version' => '8.3.8',
'version' => '8.3.8.0',
'reference' => 'd05c08d0b9ed017f61ebbc31bc4e5f4d758a0326',
'type' => 'library',
'install_path' => __DIR__ . '/../twilio/sdk',
'aliases' => array(),
'dev_requirement' => false,
),
),
);
Loading

0 comments on commit 264495f

Please sign in to comment.