<?php

require_once __DIR__ . '/../include/env_loader.php';

class VelstackServiceProvider {


    public function sendQuickSMS($recipient, $message)
    {
                     
                  $url = "https://api.velstack.com/v1/sms/quick";
                   $data = [
                  'title' => 'Information',
                  'sender' => "STHRotation",
                  'recipient' => [$recipient],
                  'message' => $message,
                  'is_scheduled' => false
                       ];

                   $fields_string = http_build_query($data);

                   //open connection
                  $ch = curl_init();

                  //set the url, number of POST vars, POST data
                  curl_setopt($ch, CURLOPT_URL, $url);
                  curl_setopt($ch, CURLOPT_POST, true);
                  curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
                  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                  "Authorization: Bearer " . env('VELSTACK_SMS_TOKEN', ''),
                  "Accept: application/json",
                  ));

                  //So that curl_exec returns the contents of the cURL; rather than echoing it
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

                  //execute post
                  $result = curl_exec($ch);
                  $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
                  curl_close($ch);

                  return [
                      'response' => $result,
                      'status_code' => $http_code
                  ];
    }




}