| 1 |
<?php |
| 2 |
|
| 3 |
namespace LearnPress\MCP\Schemas; |
| 4 |
|
| 5 |
use LearnPress\MCP\Support\Schemas; |
| 6 |
|
| 7 |
defined( 'ABSPATH' ) || exit; |
| 8 |
|
| 9 |
/** |
| 10 |
* Input/output schemas for section write tools. |
| 11 |
*/ |
| 12 |
class SectionSchemas { |
| 13 |
|
| 14 |
/** |
| 15 |
* create-section input. |
| 16 |
* |
| 17 |
* @return array |
| 18 |
*/ |
| 19 |
public static function create_input(): array { |
| 20 |
return Schemas::object( |
| 21 |
array( |
| 22 |
'course_id' => Schemas::id(), |
| 23 |
'name' => Schemas::string(), |
| 24 |
'description' => Schemas::string(), |
| 25 |
'order' => Schemas::integer( 1 ), |
| 26 |
), |
| 27 |
array( 'course_id', 'name' ) |
| 28 |
); |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* update-section input. |
| 33 |
* |
| 34 |
* @return array |
| 35 |
*/ |
| 36 |
public static function update_input(): array { |
| 37 |
return Schemas::object( |
| 38 |
array( |
| 39 |
'course_id' => Schemas::id(), |
| 40 |
'section_id' => Schemas::id(), |
| 41 |
'name' => Schemas::string(), |
| 42 |
'description' => Schemas::string(), |
| 43 |
'order' => Schemas::integer( 1 ), |
| 44 |
), |
| 45 |
array( 'course_id', 'section_id' ) |
| 46 |
); |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* delete-section input. |
| 51 |
* |
| 52 |
* @return array |
| 53 |
*/ |
| 54 |
public static function delete_input(): array { |
| 55 |
return Schemas::object( |
| 56 |
array( |
| 57 |
'course_id' => Schemas::id(), |
| 58 |
'section_id' => Schemas::id(), |
| 59 |
), |
| 60 |
array( 'course_id', 'section_id' ) |
| 61 |
); |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Write output wrapped under "section". |
| 66 |
* |
| 67 |
* @return array |
| 68 |
*/ |
| 69 |
public static function write_output(): array { |
| 70 |
return Schemas::object_output( 'section' ); |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* delete-section output. |
| 75 |
* |
| 76 |
* @return array |
| 77 |
*/ |
| 78 |
public static function delete_output(): array { |
| 79 |
return Schemas::object( |
| 80 |
array( |
| 81 |
'removed' => Schemas::boolean(), |
| 82 |
'section_id' => Schemas::integer(), |
| 83 |
'course_id' => Schemas::integer(), |
| 84 |
'affected_items' => array( |
| 85 |
'type' => 'array', |
| 86 |
'items' => array( 'type' => 'object' ), |
| 87 |
), |
| 88 |
'recovery' => array( 'type' => 'object' ), |
| 89 |
), |
| 90 |
array( 'removed', 'section_id' ) |
| 91 |
); |
| 92 |
} |
| 93 |
} |
| 94 |
|