Skip to content

Commit

Permalink
Merge pull request #53 from nemerald-voip:ringotel-apps
Browse files Browse the repository at this point in the history
Updated and improved Ringotel API
  • Loading branch information
nemerald-voip authored Dec 28, 2024
2 parents a5eb33e + cc819cd commit c60efc3
Show file tree
Hide file tree
Showing 28 changed files with 4,846 additions and 524 deletions.
2 changes: 2 additions & 0 deletions app/Console/Commands/UpdateApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Services\GitHubApiService;
use Symfony\Component\Process\Process;
use App\Console\Commands\Updates\Update097;
use App\Console\Commands\Updates\Update0917;


class UpdateApp extends Command
Expand Down Expand Up @@ -48,6 +49,7 @@ public function handle()
$updateSteps = [
'0.9.7' => Update097::class,
'0.9.11' => Update097::class,
'0.9.17' => Update0917::class,
// Add more versions as needed
];

Expand Down
316 changes: 316 additions & 0 deletions app/Console/Commands/Updates/Update0917.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,316 @@
<?php

namespace App\Console\Commands\Updates;

use App\Models\DefaultSettings;
use Illuminate\Support\Str;

class Update0917
{
/**
* Apply the 0.9.16 update steps.
*
* @return bool
*/
public function apply()
{
$updates = [
[
'category' => 'mobile_apps',
'subcategory' => 'windows_link',
'type' => 'text',
'value' => '',
'description' => '',
],
[
'category' => 'mobile_apps',
'subcategory' => 'apple_store_link',
'type' => 'text',
'value' => '',
'description' => '',
],
[
'category' => 'mobile_apps',
'subcategory' => 'google_play_link',
'type' => 'text',
'value' => '',
'description' => '',
],
[
'category' => 'mobile_apps',
'subcategory' => 'mac_link',
'type' => 'text',
'value' => '',
'description' => '',
],
[
'category' => 'mobile_apps',
'subcategory' => 'organization_region',
'type' => 'text',
'value' => '',
'description' => '1 - US East, 2 - US West, 3 - Europe (Frankfurt), 4 - Asia Pacific (Singapore), 5 - Europe (London), 6 - India, 7 - Australia, 8 - Europe (Dublin), 9 - Canada (Central), 10 - South Africa',
],
[
'category' => 'mobile_apps',
'subcategory' => 'package',
'type' => 'text',
'value' => '',
'description' => '1 - Essentials, 2 - Pro',
],
[
'category' => 'mobile_apps',
'subcategory' => 'connection_port',
'type' => 'text',
'value' => '',
'description' => '',
],
[
'category' => 'mobile_apps',
'subcategory' => 'mobile_app_conn_protocol',
'type' => 'text',
'value' => 'sip',
'description' => 'sip or sip-tcp or sips or DNS-NAPTR',
],
[
'category' => 'mobile_apps',
'subcategory' => 'mobile_app_proxy',
'type' => 'text',
'value' => '',
'description' => '',
],
[
'category' => 'mobile_apps',
'subcategory' => 'dont_send_user_credentials',
'type' => 'boolean',
'value' => 'false',
'description' => "Don't include user credentials in the welcome email",
],
[
'category' => 'mobile_apps',
'subcategory' => 'dont_verify_server_certificate',
'type' => 'boolean',
'value' => 'false',
'description' => '',
],
[
'category' => 'mobile_apps',
'subcategory' => 'disable_srtp',
'type' => 'boolean',
'value' => 'false',
'description' => '',
],
[
'category' => 'mobile_apps',
'subcategory' => 'multitenant_mode',
'type' => 'boolean',
'value' => 'true',
'description' => '',
],
[
'category' => 'mobile_apps',
'subcategory' => 'allow_call_recording',
'type' => 'boolean',
'value' => 'false',
'description' => 'Allow users to record calls.',
],
[
'category' => 'mobile_apps',
'subcategory' => 'max_registrations',
'type' => 'text',
'value' => '3',
'description' => 'Max. number of parallel registrations per softphone user.',
],
[
'category' => 'mobile_apps',
'subcategory' => 'registration_ttl',
'type' => 'text',
'value' => '3600',
'description' => '',
],
[
'category' => 'mobile_apps',
'subcategory' => 'voicemail_extension',
'type' => 'text',
'value' => '*97',
'description' => '',
],
[
'category' => 'mobile_apps',
'subcategory' => 'pbx_features',
'type' => 'boolean',
'value' => 'true',
'description' => '',
],
[
'category' => 'mobile_apps',
'subcategory' => 'dnd_on_code',
'type' => 'text',
'value' => '*78',
'description' => '',
],
[
'category' => 'mobile_apps',
'subcategory' => 'dnd_off_code',
'type' => 'text',
'value' => '*79',
'description' => '',
],
[
'category' => 'mobile_apps',
'subcategory' => 'cf_on_code',
'type' => 'text',
'value' => '*72',
'description' => 'The feature code used to activate CF',
],
[
'category' => 'mobile_apps',
'subcategory' => 'cf_off_code',
'type' => 'text',
'value' => '*73',
'description' => 'The feature code used to deactivate CF',
],
[
'category' => 'mobile_apps',
'subcategory' => 'g711u_enabled',
'type' => 'boolean',
'value' => 'true',
'description' => 'Enable G711 Ulaw codec',
],
[
'category' => 'mobile_apps',
'subcategory' => 'g711a_enabled',
'type' => 'boolean',
'value' => 'true',
'description' => 'Enable G711 Alaw codec',
],
[
'category' => 'mobile_apps',
'subcategory' => 'g729_enabled',
'type' => 'boolean',
'value' => 'false',
'description' => 'Enable G729 codec',
],
[
'category' => 'mobile_apps',
'subcategory' => 'opus_enabled',
'type' => 'boolean',
'value' => 'false',
'description' => 'Enable OPUS codec',
],
[
'category' => 'mobile_apps',
'subcategory' => 'show_call_settings',
'type' => 'boolean',
'value' => 'true',
'description' => 'Allow users to configure call settings from within the app, such as call forwarding, voicemail, call waiting.',
],
[
'category' => 'mobile_apps',
'subcategory' => 'allow_state_change',
'type' => 'boolean',
'value' => 'true',
'description' => 'Allow users to change their state from the app, such as Online/DND/At the desk.',
],
[
'category' => 'mobile_apps',
'subcategory' => 'allow_video_calls',
'type' => 'boolean',
'value' => 'true',
'description' => 'Allow users to make 1-on-1 video calls.',
],
[
'category' => 'mobile_apps',
'subcategory' => 'allow_internal_chat',
'type' => 'boolean',
'value' => 'true',
'description' => 'Allow users to use internal chat feature and create new chats.',
],
[
'category' => 'mobile_apps',
'subcategory' => 'disable_iphone_recents',
'type' => 'boolean',
'value' => 'false',
'description' => "If enabled, this option disables call history syncing in iPhone Recents and hides the 'Show calls in iPhone Recents' option from the app's settings.",
],
[
'category' => 'mobile_apps',
'subcategory' => 'app_opus_codec',
'type' => 'boolean',
'value' => 'true',
'description' => 'Enable the OPUS audio codec between the softphone apps and a softphone server',
],
[
'category' => 'mobile_apps',
'subcategory' => 'one_push',
'type' => 'boolean',
'value' => 'false',
'description' => "Don't send a second push notification in the case of the user's mobile app was not waked up by the first one.",
],
[
'category' => 'mobile_apps',
'subcategory' => 'call_delay',
'type' => 'text',
'value' => '10',
'description' => "Call Delay for 'At the Desk' Status (Seconds)",
],
[
'category' => 'mobile_apps',
'subcategory' => 'desktop_app_delay',
'type' => 'boolean',
'value' => 'false',
'description' => "Delay incoming calls to the desktop app",
],
];

try {
foreach ($updates as $update) {
$this->updateOrCreateRecord(
$update['category'],
$update['subcategory'],
$update['type'],
$update['value'],
$update['description']
);
}

return true;
} catch (\Exception $e) {
echo "Error applying update 0.9.16: " . $e->getMessage() . "\n";
return false;
}
}

/**
* Update or create a record in the DefaultSettings table.
*
* @param string $category
* @param string $subcategory
* @param string $description
* @return void
*/
private function updateOrCreateRecord($category, $subcategory, $type, $value, $description)
{
$defaultSetting = DefaultSettings::where('default_setting_category', $category)
->where('default_setting_subcategory', $subcategory)
->first();

if ($defaultSetting) {
// Update the description if the record exists
$defaultSetting->default_setting_description = $description;
$defaultSetting->save();
echo "Updated existing record in category '$category' and subcategory '$subcategory'.\n";
} else {
// Create a new record if it does not exist
DefaultSettings::create([
'default_setting_uuid' => Str::uuid()->toString(), // Generate a new UUID
'default_setting_category' => $category,
'default_setting_subcategory' => $subcategory,
'default_setting_name' => $type,
'default_setting_value' => $value,
'default_setting_enabled' => 't',
'default_setting_description' => $description,
]);
echo "Created new record in category '$category' and subcategory '$subcategory'.\n";
}
}
}
31 changes: 31 additions & 0 deletions app/DTO/RingotelConnectionDTO.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
namespace App\DTO;

class RingotelConnectionDTO
{
public $accountId;
public $address;
public $created;
public $domain;
public $name;
public $id;
public $status;
public $provision;

public function __construct(array $data)
{
$this->accountId = $data['accountid'];
$this->address = $data['address'];
$this->created = $data['created'];
$this->domain = $data['domain'];
$this->name = $data['name'];
$this->id = $data['id'];
$this->status = $data['status'];
$this->provision = $data['provision'] ?? [];
}

public static function fromArray(array $data)
{
return new self($data);
}
}
5 changes: 5 additions & 0 deletions app/DTO/RingotelOrganizationDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ public static function fromArray(array $data)
{
return new self($data);
}

public function __toString()
{
return json_encode(get_object_vars($this));
}
}
Loading

0 comments on commit c60efc3

Please sign in to comment.