Skip to content

Commit

Permalink
Merge pull request #38 from dnlk17/new_endpoints
Browse files Browse the repository at this point in the history
Implementation of new endpoints: count & duplicateCheck
  • Loading branch information
geraldclark committed Nov 5, 2018
2 parents 2d75cae + 8ee0f9d commit 84a934e
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/DuplicateCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

require_once __DIR__ . '/../vendor/autoload.php';

try {
$SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Pro/7621/', array('username' => 'admin','password'=>'asdf'));
$SugarAPI->login();
$EP = $SugarAPI->duplicateCheck('Accounts');
$data = array(
'name' => 'Airline'
);
$response = $EP->execute($data)->getResponse();
if ($response->getStatus()=='200') {
$recordList = $response->getBody(false);
$max=count($recordList->records);
echo $EP->getUrl() . " <br>\n";
echo "$max duplicate record(s) found. <br>\n";
}
$SugarAPI->logout();
} catch (\SugarAPI\SDK\Exception\AuthenticationException $ex) {
print $ex->getMessage();
}
21 changes: 21 additions & 0 deletions examples/ModuleCount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

require_once __DIR__ . '/../vendor/autoload.php';

try {
$SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Pro/7621/', array('username' => 'admin','password'=>'asdf'));
$SugarAPI->login();
foreach (['Accounts', 'Contacts'] as $module) {
$EP = $SugarAPI->count($module);
$response = $EP->execute()->getResponse();
if ($response->getStatus()=='200') {
$result = $response->getBody(false);
$count = $result->record_count;
echo $EP->getUrl() . " <br>\n";
echo "$count $module found. <br>\n";
}
}
$SugarAPI->logout();
} catch (\SugarAPI\SDK\Exception\AuthenticationException $ex) {
print $ex->getMessage();
}
2 changes: 2 additions & 0 deletions src/Client/Abstracts/AbstractSugarClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
* @method EPInterface unfavorite(string $module = '',string $record_id = '')
* @method EPInterface deleteFile(string $module = '',string $record_id = '')
* @method EPInterface unlinkRecords(string $module = '',string $record_id = '',string $relationship = '',string $related_id = '')
* @method EPInterface duplicateCheck(string $module = '')
* @method EPInterface count(string $module = '')
*/
abstract class AbstractSugarClient extends AbstractClient
{
Expand Down
16 changes: 16 additions & 0 deletions src/Endpoint/GET/ModuleCount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* ©[2016] SugarCRM Inc. Licensed by SugarCRM under the Apache 2.0 license.
*/

namespace SugarAPI\SDK\Endpoint\GET;

use SugarAPI\SDK\Endpoint\Abstracts\GET\AbstractGetEndpoint;

class ModuleCount extends AbstractGetEndpoint
{
/**
* @inheritdoc
*/
protected $_URL = '$module/count';
}
16 changes: 16 additions & 0 deletions src/Endpoint/POST/ModuleDuplicateCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* ©[2016] SugarCRM Inc. Licensed by SugarCRM under the Apache 2.0 license.
*/

namespace SugarAPI\SDK\Endpoint\POST;

use SugarAPI\SDK\Endpoint\Abstracts\POST\AbstractPostEndpoint;

class ModuleDuplicateCheck extends AbstractPostEndpoint
{
/**
* @inheritdoc
*/
protected $_URL = '$module/duplicateCheck';
}
2 changes: 2 additions & 0 deletions src/Helpers/registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'search' => 'GET\\Search',
'preferences' => 'GET\\MePreferences',
'serverTime' => 'GET\\ServerTime',
'count' => 'GET\\ModuleCount',

//POST API Endpoints
'oauth2Token' => 'POST\\OAuth2Token',
Expand All @@ -28,6 +29,7 @@
'linkRecords' => 'POST\\ModuleRecordLinkRecord',
'relateRecord' => 'POST\\ModuleRecordLinkRecord',
'massRelate' => 'POST\\ModuleRecordLink',
'duplicateCheck' => 'POST\\ModuleDuplicateCheck',
'bulk' => 'POST\\Bulk',

//PUT API Endpoints
Expand Down

0 comments on commit 84a934e

Please sign in to comment.