AnsweredAssumed Answered

Manifest.php for custom endpoint

Question asked by john Fieldsend on May 16, 2019
Latest reply on May 21, 2019 by john Fieldsend

Hi all so i've put together a manifest.php file to install a new custom endpoint to our sugar cloud api 

 

Manifest.php

<?php

$manifest = array(
'name' => 'Printer Cases',
'description' => 'API Endpoints fields and methods for printer cases from support.magicard.com',
'author' => 'John Fieldsend',
'version' => '1.0.0.0.1',
'is_uninstallable' => true,
'published_date' => '05/16/2019 14:15:12',
'type' => 'module',
'acceptable_sugar_versions' =>
array(
'regex_matches' => array(
'9.0.*' //any 9.0 release
),
),
'acceptable_sugar_flavors' =>
array(
'PRO',
'ENT',
'ULT'
),
'readme' => '',
'icon' => '',
'remove_tables' => '',
'uninstall_before_upgrade' => false,
);

$installdefs['copy'] = array(
array(
'from' => '<basepath>/Files/custom/clients/base/api/printerCase.php',
'to' => 'custom/clients/base/api/printerCase.php',
),
);

?>

 

i then created the printerCase.php file

 

if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

class PrinterCasesApi extends SugarApi {

public function registerApiRest() {
return array(
'createCase' => array(
'reqType' => 'POST',
'noLoginRequired' => false,
'path' => array('Contact', 'CreateACase'),
// 'pathVars' => array('', '', 'data'),
'method' => 'createACase',
'shortHelp' => 'Create A Case and associate it with Contact',
// 'longHelp' => 'custom/clients/base/api/help/MyEndPoint_MyGetEndPoint_help.html',
),
);
}

public function CreateACase($api, $args) {
global $db;
$result = array(
'id' => '',
'success' => false,
'errors' => 'Invalid Parameteres',
);

$casebean = BeanFactory::getBean("Cases");
$casebean->contact_id = $args['ContactId'];
$result['args'] = $args;
return $result;
}

}

 

Created a zip archive of these files and uploaded to sugar through the admin -> module-Loader

 

however if i try to install the package I get an error saying that the class PrinterCasesApi cannot be redefined, im pretty sure there are no other classes called this so confused as to whats happening and what im doing wrong to get this endpoint installed

Outcomes