-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #261 from jesusantguerrero/release/beta-8
Release/beta 8
- Loading branch information
Showing
90 changed files
with
1,747 additions
and
734 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
app/Domains/Automation/Concerns/AutomationActionContract.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace App\Domains\Automation\Concerns; | ||
|
||
use App\Domains\Automation\Models\Automation; | ||
use App\Domains\Automation\Models\AutomationTaskAction; | ||
|
||
interface AutomationActionContract | ||
{ | ||
/** | ||
* Validate and create a new team for the given user. | ||
* | ||
* @param Automation $automation | ||
* @param Google_Calendar_Events $calendarEvents | ||
* @return void | ||
*/ | ||
public static function handle( | ||
Automation $automation, | ||
mixed $payload, | ||
AutomationTaskAction $task, | ||
AutomationTaskAction $previousTask, | ||
AutomationTaskAction $trigger | ||
); | ||
|
||
public function getName(): string; | ||
public function getDescription(): string; | ||
public function label(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
namespace App\Domains\Automation\Data; | ||
|
||
use Spatie\LaravelData\Data; | ||
|
||
class AutomationData extends Data { | ||
|
||
public function __construct( | ||
public int $team_id, | ||
public int $user_id, | ||
public int $service_id, | ||
public int $integration_id | ||
) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
namespace App\Domains\Automation\Enums; | ||
|
||
enum AutomationTaskType: string { | ||
const ACTION = 'action'; | ||
const TRIGGER = 'trigger'; | ||
const COMPONENT = 'component'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
namespace App\Domains\Automation\Helpers; | ||
|
||
use App\Domains\Automation\Concerns\AutomationActionContract; | ||
use App\Domains\Automation\Data\AutomationData; | ||
use App\Domains\Automation\Enums\AutomationTaskType; | ||
|
||
class AutomationBuilder { | ||
private array $tasks = []; | ||
|
||
public function __construct(public AutomationData $data) {} | ||
|
||
public static function make(AutomationData $data): self | ||
{ | ||
return new self($data); | ||
} | ||
|
||
public function addAction(AutomationActionContract $action, string $type, mixed $config): AutomationBuilder { | ||
$this->tasks[] = [ | ||
"name" => $action->getName(), | ||
"entity" => get_class($action), | ||
"action" => $action, | ||
"order" => count($this->tasks), | ||
"task_type" => $type, | ||
"values" => $config['values'] ?? [] | ||
]; | ||
|
||
return $this; | ||
} | ||
|
||
public function getSchema() { | ||
return [ | ||
... $this->data->toArray(), | ||
"description" => implode(" ", array_map(fn ($task) => $task['action']?->label(), $this->tasks)) , | ||
"integration_id" => $this->data->integration_id, | ||
"service_id" => $this->data->service_id, | ||
"sentence" => implode(" ", array_map(fn ($task) => $task['action']?->label(), $this->tasks)), | ||
"name" => implode(" ", array_map(fn ($task) => $task['action']?->getName(), $this->tasks)), | ||
"sentence" => "", | ||
"tasks" => $this->tasks | ||
]; | ||
} | ||
} |
10 changes: 5 additions & 5 deletions
10
.../Controllers/Api/AutomationController.php → ...Http/Controllers/AutomationController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
app/Domains/Automation/Http/Controllers/AutomationRecipeController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace App\Domains\Automation\Http\Controllers; | ||
|
||
use App\Domains\Automation\Models\AutomationRecipe; | ||
use App\Http\Controllers\Controller; | ||
|
||
|
||
|
||
class AutomationRecipeController extends Controller | ||
{ | ||
public function index() { | ||
return AutomationRecipe::all(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
app/Domains/Automation/Http/Controllers/AutomationServiceController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace App\Domains\Automation\Http\Controllers; | ||
|
||
use App\Domains\Automation\Models\AutomationService; | ||
use App\Http\Controllers\Controller; | ||
|
||
class AutomationServiceController extends Controller | ||
{ | ||
public function index() { | ||
return AutomationService::all(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s/Integration/Models/AutomationRecipe.php → ...ns/Automation/Models/AutomationRecipe.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../Integration/Models/AutomationService.php → ...s/Automation/Models/AutomationService.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ins/Integration/Models/AutomationTask.php → ...ains/Automation/Models/AutomationTask.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...tegration/Models/AutomationTaskAction.php → ...utomation/Models/AutomationTaskAction.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
use App\Domains\Automation\Http\Controllers\AutomationController; | ||
use App\Domains\Automation\Http\Controllers\AutomationRecipeController; | ||
use App\Domains\Automation\Http\Controllers\AutomationServiceController; | ||
use Illuminate\Support\Facades\Route; | ||
|
||
/************************************************************************************** | ||
* API Section | ||
***************************************************************************************/ | ||
|
||
|
||
Route::middleware(['auth:sanctum', 'atmosphere.teamed', 'verified'])->prefix('/api')->name('api.')->group(function () { | ||
Route::controller(AutomationController::class)->group(function () { | ||
Route::apiResource('automation', AutomationController::class); | ||
Route::post('/automation/{id}/run', 'run'); | ||
Route::post('/automation/run-all', 'runAll'); | ||
}); | ||
|
||
Route::apiResource('/automation-services', AutomationServiceController::class); | ||
Route::apiResource('/automation-recipes', AutomationRecipeController::class); | ||
}); |
Oops, something went wrong.