From 3a0e3708a50a0672c94c79e165aa834dfe8f4e9a Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Mon, 30 Jul 2012 14:26:15 +0000 Subject: Add public class for registering api calls --- lib/public/api.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 lib/public/api.php (limited to 'lib/public') diff --git a/lib/public/api.php b/lib/public/api.php new file mode 100644 index 00000000000..270aa893297 --- /dev/null +++ b/lib/public/api.php @@ -0,0 +1,41 @@ +. +* +*/ + +namespace OCP; + +/** + * This class provides functions to manage apps in ownCloud + */ +class API { + + /** + * registers an api call + * @param string $method the http method + * @param string $url the url to match + * @param callable $action the function to run + * @param string $app the id of the app registering the call + */ + public function register($method, $url, $action, $app){ + OC_API::register($method, $url, $action, $app); + } + +} -- cgit v1.2.3 From cc6911e1f709edc42ea5558e19fcdeea75cdcf39 Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Tue, 31 Jul 2012 09:28:12 +0000 Subject: Make method static --- lib/public/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/public') diff --git a/lib/public/api.php b/lib/public/api.php index 270aa893297..518e6f00970 100644 --- a/lib/public/api.php +++ b/lib/public/api.php @@ -34,7 +34,7 @@ class API { * @param callable $action the function to run * @param string $app the id of the app registering the call */ - public function register($method, $url, $action, $app){ + public static function register($method, $url, $action, $app){ OC_API::register($method, $url, $action, $app); } -- cgit v1.2.3 From b05639e745cabf8d11785f673593680448d844a2 Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Tue, 31 Jul 2012 10:10:15 +0000 Subject: Fix error with namespacing --- lib/public/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/public') diff --git a/lib/public/api.php b/lib/public/api.php index 518e6f00970..ed1f6ef237c 100644 --- a/lib/public/api.php +++ b/lib/public/api.php @@ -35,7 +35,7 @@ class API { * @param string $app the id of the app registering the call */ public static function register($method, $url, $action, $app){ - OC_API::register($method, $url, $action, $app); + \OC_API::register($method, $url, $action, $app); } } -- cgit v1.2.3 From 8b409dfe2ad634b84dcbcc54cdd668488318e79b Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Thu, 13 Sep 2012 14:15:04 +0000 Subject: API: Default to user authentication level --- lib/public/api.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/public') diff --git a/lib/public/api.php b/lib/public/api.php index ed1f6ef237c..2821554229b 100644 --- a/lib/public/api.php +++ b/lib/public/api.php @@ -33,9 +33,10 @@ class API { * @param string $url the url to match * @param callable $action the function to run * @param string $app the id of the app registering the call + * @param int $authlevel the level of authentication required for the call (See OC_API constants) */ - public static function register($method, $url, $action, $app){ - \OC_API::register($method, $url, $action, $app); + public static function register($method, $url, $action, $app, $authlevel = OC_API::USER_AUTH){ + \OC_API::register($method, $url, $action, $app, $authlevel); } } -- cgit v1.2.3 From 07111ff672037282a6ca870fc19eab9f36875ea0 Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Sun, 28 Oct 2012 11:04:23 +0000 Subject: Allow apps to pass defaults and requirements for their API calls --- lib/public/api.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/public') diff --git a/lib/public/api.php b/lib/public/api.php index 2821554229b..9d6d1153e6c 100644 --- a/lib/public/api.php +++ b/lib/public/api.php @@ -34,9 +34,11 @@ class API { * @param callable $action the function to run * @param string $app the id of the app registering the call * @param int $authlevel the level of authentication required for the call (See OC_API constants) + * @param array $defaults + * @param array $requirements */ - public static function register($method, $url, $action, $app, $authlevel = OC_API::USER_AUTH){ - \OC_API::register($method, $url, $action, $app, $authlevel); + public static function register($method, $url, $action, $app, $authlevel = OC_API::USER_AUTH, $defaults = array(), $requirements = array()){ + \OC_API::register($method, $url, $action, $app, $authlevel, $defaults, $requirements); } } -- cgit v1.2.3