Created
June 28, 2019 01:11
-
-
Save elchele/cb9320c8987121ab4a0db7a5443dd918 to your computer and use it in GitHub Desktop.
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
<?php | |
/* File: ./custom/clients/base/api/MyCustomApi.php */ | |
class MyCustomApi extends SugarApi { | |
public function registerApiRest() { | |
return array( | |
'myCustomMethod' => array( | |
'reqType' => 'GET', | |
'path' => array('customEndpoint'), | |
'pathVars' => array(), | |
'method' => 'myCustomMethod', | |
'shortHelp' => 'This is a custom endpoint.', | |
'longHelp' => '', | |
) | |
); | |
} | |
public function myCustomMethod($api, $args) | |
{ | |
//Some code | |
//Here we raise the exception with our custom error message | |
throw new SugarApiExceptionMissingParameter('You are missing a parameter required for properly invoking this endpoint.'); | |
//the rest of your code for your custom method | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment