aboutsummaryrefslogtreecommitdiff
path: root/externallib.php
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2019-05-10 23:17:20 +0300
committerValentin Popov <info@valentineus.link>2019-05-10 23:17:20 +0300
commited0ce52060690eff5459c037338d26796307ef79 (patch)
treeb555dc3316a47296a71c32149766889d53b0dd55 /externallib.php
parent6b18cffc970a69a292c2d9836ff5b460a5d1005a (diff)
downloadlocal_webhooks-ed0ce52060690eff5459c037338d26796307ef79.tar.xz
local_webhooks-ed0ce52060690eff5459c037338d26796307ef79.zip
Added external function delete service
Signed-off-by: Valentin Popov <info@valentineus.link>
Diffstat (limited to 'externallib.php')
-rw-r--r--externallib.php56
1 files changed, 50 insertions, 6 deletions
diff --git a/externallib.php b/externallib.php
index 4db6a74..15ed0e2 100644
--- a/externallib.php
+++ b/externallib.php
@@ -32,9 +32,51 @@ use local_webhooks\local\record;
*/
final class local_webhooks_external extends external_api {
/**
+ * Delete the existing service.
+ *
+ * @param int $serviceid
+ *
+ * @return bool
+ *
+ * @throws \dml_exception
+ * @throws \invalid_parameter_exception
+ * @throws \restricted_context_exception
+ */
+ public static function del_service(int $serviceid): bool {
+ $parameters = self::validate_parameters(self::del_service_parameters(), [
+ 'serviceid' => $serviceid,
+ ]);
+
+ $context = context_system::instance();
+ self::validate_context($context);
+
+ return api::del_service($parameters['serviceid']);
+ }
+
+ /**
+ * Returns description of the method parameters.
+ *
+ * @return \external_function_parameters
+ */
+ public static function del_service_parameters(): external_function_parameters {
+ return new external_function_parameters([
+ 'serviceid' => new external_value(PARAM_INT, 'The service\'s ID.'),
+ ], '');
+ }
+
+ /**
+ * Returns description of the method result value.
+ *
+ * @return \external_value
+ */
+ public static function del_service_returns(): external_value {
+ return new external_value(PARAM_BOOL, 'The result operation.');
+ }
+
+ /**
* Get data by service.
*
- * @param int $serviceid Service's ID.
+ * @param int $serviceid
*
* @return \local_webhooks\local\record
*
@@ -43,7 +85,9 @@ final class local_webhooks_external extends external_api {
* @throws \restricted_context_exception
*/
public static function get_service(int $serviceid): record {
- $parameters = self::validate_parameters(self::get_service_parameters(), ['serviceid' => $serviceid]);
+ $parameters = self::validate_parameters(self::get_service_parameters(), [
+ 'serviceid' => $serviceid,
+ ]);
$context = context_system::instance();
self::validate_context($context);
@@ -52,7 +96,7 @@ final class local_webhooks_external extends external_api {
}
/**
- * Returns description of method parameters.
+ * Returns description of the method parameters.
*
* @return \external_function_parameters
*/
@@ -63,7 +107,7 @@ final class local_webhooks_external extends external_api {
}
/**
- * Returns description of method parameters.
+ * Returns description of the method result value.
*
* @return \external_single_structure
*/
@@ -115,7 +159,7 @@ final class local_webhooks_external extends external_api {
}
/**
- * Returns description of method parameters.
+ * Returns description of the method parameters.
*
* @return \external_function_parameters
*/
@@ -135,7 +179,7 @@ final class local_webhooks_external extends external_api {
}
/**
- * Returns description of method parameters.
+ * Returns description of the method result value.
*
* @return \external_multiple_structure
*/