add-user-to-board.php
11 months ago
assign-task.php
1 year ago
create-board.php
1 week ago
create-label.php
8 months ago
create-stage.php
8 months ago
create-sub-task.php
11 months ago
create-subtask-group.php
11 months ago
create-task.php
1 week ago
get-board-details.php
11 months ago
get-crm-contact-for-task.php
1 week ago
get-task-assignees.php
1 week ago
get-task-details.php
11 months ago
list-task-labels.php
11 months ago
list-tasks.php
1 year ago
remove-assignee-from-task.php
1 year ago
get-board-details.php
101 lines
| 1 | <?php |
| 2 | /** |
| 3 | * GetBoardDetails. |
| 4 | * php version 5.6 |
| 5 | * |
| 6 | * @category GetBoardDetails |
| 7 | * @package SureTriggers |
| 8 | * @author BSF <username@example.com> |
| 9 | * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 |
| 10 | * @link https://www.brainstormforce.com/ |
| 11 | * @since 1.0.0 |
| 12 | */ |
| 13 | |
| 14 | namespace SureTriggers\Integrations\FluentBoards\Actions; |
| 15 | |
| 16 | use Exception; |
| 17 | use SureTriggers\Integrations\AutomateAction; |
| 18 | use SureTriggers\Traits\SingletonLoader; |
| 19 | /** |
| 20 | * GetBoardDetails |
| 21 | * |
| 22 | * @category GetBoardDetails |
| 23 | * @package SureTriggers |
| 24 | * @author BSF <username@example.com> |
| 25 | * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 |
| 26 | * @link https://www.brainstormforce.com/ |
| 27 | * @since 1.0.0 |
| 28 | */ |
| 29 | class GetBoardDetails extends AutomateAction { |
| 30 | |
| 31 | |
| 32 | /** |
| 33 | * Integration type. |
| 34 | * |
| 35 | * @var string |
| 36 | */ |
| 37 | public $integration = 'FluentBoards'; |
| 38 | |
| 39 | /** |
| 40 | * Action name. |
| 41 | * |
| 42 | * @var string |
| 43 | */ |
| 44 | public $action = 'fbs_get_board_details'; |
| 45 | |
| 46 | use SingletonLoader; |
| 47 | |
| 48 | /** |
| 49 | * Register a action. |
| 50 | * |
| 51 | * @param array $actions actions. |
| 52 | * @return array |
| 53 | */ |
| 54 | public function register( $actions ) { |
| 55 | |
| 56 | $actions[ $this->integration ][ $this->action ] = [ |
| 57 | 'label' => __( 'Get Board', 'suretriggers' ), |
| 58 | 'action' => $this->action, |
| 59 | 'function' => [ $this, 'action_listener' ], |
| 60 | ]; |
| 61 | |
| 62 | return $actions; |
| 63 | |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Action listener. |
| 68 | * |
| 69 | * @param int $user_id user_id. |
| 70 | * @param int $automation_id automation_id. |
| 71 | * @param array $fields fields. |
| 72 | * @param array $selected_options selected_options. |
| 73 | * |
| 74 | * @return array|void |
| 75 | * |
| 76 | * @throws Exception Exception. |
| 77 | */ |
| 78 | public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { |
| 79 | $board_id = $selected_options['board_id'] ? sanitize_text_field( $selected_options['board_id'] ) : ''; |
| 80 | |
| 81 | // Check if FluentBoardsApi function exists, if not, return early. |
| 82 | if ( ! class_exists( 'FluentBoards\App\Models\Board' ) ) { |
| 83 | return [ |
| 84 | 'status' => 'error', |
| 85 | 'message' => __( 'FluentBoards\App\Models\Board class not found.', 'suretriggers' ), |
| 86 | |
| 87 | ]; |
| 88 | } |
| 89 | $board = \FluentBoards\App\Models\Board::find( $board_id ); |
| 90 | if ( empty( $board ) ) { |
| 91 | return [ |
| 92 | 'status' => 'error', |
| 93 | 'message' => 'There is error while getting board details.', |
| 94 | ]; |
| 95 | } |
| 96 | return $board; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | GetBoardDetails::get_instance(); |
| 101 |