12 private array $settings;
19 $this->settings = $settings;
27 $this->userid = $userid;
34 public function add() {
35 $this->request(
"POST");
42 public function remove() {
43 $this->request(
"DELETE");
51 private function request($type) {
52 $token = $this->settings[
"userToken"];
55 curl_setopt_array($curl, array(
56 CURLOPT_URL => $this->settings[
"domain"] .
"/v2beta/users/$this->userid/otp_sms",
57 CURLOPT_RETURNTRANSFER =>
true,
58 CURLOPT_ENCODING =>
'',
59 CURLOPT_MAXREDIRS => 10,
61 CURLOPT_FOLLOWLOCATION =>
true,
62 CURLOPT_CUSTOMREQUEST =>
'POST',
63 CURLOPT_POSTFIELDS =>
"{}",
64 CURLOPT_HTTPHEADER => array(
65 "Content-Type: application/json",
66 "Accept: application/json",
67 "Authorization: Bearer $token"
71 $response = json_decode(curl_exec($curl));
73 if(isset($response->code)) {
74 throw new Exception(
"Error-Code: " . $response->code .
" Message: " . $response->message);