add delete apis
This commit is contained in:
parent
abcca83e0d
commit
d7930660f3
6 changed files with 294 additions and 0 deletions
45
api/v3/TwingleCampaign/Delete.php
Normal file
45
api/v3/TwingleCampaign/Delete.php
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
use CRM_TwingleCampaign_ExtensionUtil as E;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TwingleCampaign.Delete API specification (optional)
|
||||||
|
* This is used for documentation and validation.
|
||||||
|
*
|
||||||
|
* @param array $spec description of fields supported by this API call
|
||||||
|
*
|
||||||
|
* @see https://docs.civicrm.org/dev/en/latest/framework/api-architecture/
|
||||||
|
*/
|
||||||
|
function _civicrm_api3_twingle_campaign_Delete_spec(&$spec) {
|
||||||
|
$spec['magicword']['api.required'] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TwingleCampaign.Delete API
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* API result descriptor
|
||||||
|
*
|
||||||
|
* @see civicrm_api3_create_success
|
||||||
|
*
|
||||||
|
* @throws API_Exception
|
||||||
|
*/
|
||||||
|
function civicrm_api3_twingle_campaign_Delete($params) {
|
||||||
|
if (array_key_exists('magicword', $params) && $params['magicword'] == 'sesame') {
|
||||||
|
$returnValues = array(
|
||||||
|
// OK, return several data rows
|
||||||
|
12 => ['id' => 12, 'name' => 'Twelve'],
|
||||||
|
34 => ['id' => 34, 'name' => 'Thirty four'],
|
||||||
|
56 => ['id' => 56, 'name' => 'Fifty six'],
|
||||||
|
);
|
||||||
|
// ALTERNATIVE: $returnValues = []; // OK, success
|
||||||
|
// ALTERNATIVE: $returnValues = ["Some value"]; // OK, return a single value
|
||||||
|
|
||||||
|
// Spec: civicrm_api3_create_success($values = 1, $params = [], $entity = NULL, $action = NULL)
|
||||||
|
return civicrm_api3_create_success($returnValues, $params, 'TwingleCampaign', 'Delete');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new API_Exception(/*error_message*/ 'Everyone knows that the magicword is "sesame"', /*error_code*/ 'magicword_incorrect');
|
||||||
|
}
|
||||||
|
}
|
45
api/v3/TwingleEvent/Delete.php
Normal file
45
api/v3/TwingleEvent/Delete.php
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
use CRM_TwingleCampaign_ExtensionUtil as E;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TwingleEvent.Delete API specification (optional)
|
||||||
|
* This is used for documentation and validation.
|
||||||
|
*
|
||||||
|
* @param array $spec description of fields supported by this API call
|
||||||
|
*
|
||||||
|
* @see https://docs.civicrm.org/dev/en/latest/framework/api-architecture/
|
||||||
|
*/
|
||||||
|
function _civicrm_api3_twingle_event_Delete_spec(&$spec) {
|
||||||
|
$spec['magicword']['api.required'] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TwingleEvent.Delete API
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* API result descriptor
|
||||||
|
*
|
||||||
|
* @see civicrm_api3_create_success
|
||||||
|
*
|
||||||
|
* @throws API_Exception
|
||||||
|
*/
|
||||||
|
function civicrm_api3_twingle_event_Delete($params) {
|
||||||
|
if (array_key_exists('magicword', $params) && $params['magicword'] == 'sesame') {
|
||||||
|
$returnValues = array(
|
||||||
|
// OK, return several data rows
|
||||||
|
12 => ['id' => 12, 'name' => 'Twelve'],
|
||||||
|
34 => ['id' => 34, 'name' => 'Thirty four'],
|
||||||
|
56 => ['id' => 56, 'name' => 'Fifty six'],
|
||||||
|
);
|
||||||
|
// ALTERNATIVE: $returnValues = []; // OK, success
|
||||||
|
// ALTERNATIVE: $returnValues = ["Some value"]; // OK, return a single value
|
||||||
|
|
||||||
|
// Spec: civicrm_api3_create_success($values = 1, $params = [], $entity = NULL, $action = NULL)
|
||||||
|
return civicrm_api3_create_success($returnValues, $params, 'TwingleEvent', 'Delete');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new API_Exception(/*error_message*/ 'Everyone knows that the magicword is "sesame"', /*error_code*/ 'magicword_incorrect');
|
||||||
|
}
|
||||||
|
}
|
45
api/v3/TwingleProject/Delete.php
Normal file
45
api/v3/TwingleProject/Delete.php
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
use CRM_TwingleCampaign_ExtensionUtil as E;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TwingleProject.Delete API specification (optional)
|
||||||
|
* This is used for documentation and validation.
|
||||||
|
*
|
||||||
|
* @param array $spec description of fields supported by this API call
|
||||||
|
*
|
||||||
|
* @see https://docs.civicrm.org/dev/en/latest/framework/api-architecture/
|
||||||
|
*/
|
||||||
|
function _civicrm_api3_twingle_project_Delete_spec(&$spec) {
|
||||||
|
$spec['magicword']['api.required'] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TwingleProject.Delete API
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* API result descriptor
|
||||||
|
*
|
||||||
|
* @see civicrm_api3_create_success
|
||||||
|
*
|
||||||
|
* @throws API_Exception
|
||||||
|
*/
|
||||||
|
function civicrm_api3_twingle_project_Delete($params) {
|
||||||
|
if (array_key_exists('magicword', $params) && $params['magicword'] == 'sesame') {
|
||||||
|
$returnValues = array(
|
||||||
|
// OK, return several data rows
|
||||||
|
12 => ['id' => 12, 'name' => 'Twelve'],
|
||||||
|
34 => ['id' => 34, 'name' => 'Thirty four'],
|
||||||
|
56 => ['id' => 56, 'name' => 'Fifty six'],
|
||||||
|
);
|
||||||
|
// ALTERNATIVE: $returnValues = []; // OK, success
|
||||||
|
// ALTERNATIVE: $returnValues = ["Some value"]; // OK, return a single value
|
||||||
|
|
||||||
|
// Spec: civicrm_api3_create_success($values = 1, $params = [], $entity = NULL, $action = NULL)
|
||||||
|
return civicrm_api3_create_success($returnValues, $params, 'TwingleProject', 'Delete');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new API_Exception(/*error_message*/ 'Everyone knows that the magicword is "sesame"', /*error_code*/ 'magicword_incorrect');
|
||||||
|
}
|
||||||
|
}
|
53
tests/phpunit/api/v3/TwingleCampaign/DeleteTest.php
Normal file
53
tests/phpunit/api/v3/TwingleCampaign/DeleteTest.php
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Civi\Test\HeadlessInterface;
|
||||||
|
use Civi\Test\HookInterface;
|
||||||
|
use Civi\Test\TransactionalInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TwingleCampaign.Delete API Test Case
|
||||||
|
* This is a generic test class implemented with PHPUnit.
|
||||||
|
* @group headless
|
||||||
|
*/
|
||||||
|
class api_v3_TwingleCampaign_DeleteTest extends \PHPUnit\Framework\TestCase implements HeadlessInterface, HookInterface, TransactionalInterface {
|
||||||
|
use \Civi\Test\Api3TestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up for headless tests.
|
||||||
|
*
|
||||||
|
* Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile().
|
||||||
|
*
|
||||||
|
* See: https://docs.civicrm.org/dev/en/latest/testing/phpunit/#civitest
|
||||||
|
*/
|
||||||
|
public function setUpHeadless() {
|
||||||
|
return \Civi\Test::headless()
|
||||||
|
->installMe(__DIR__)
|
||||||
|
->apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The setup() method is executed before the test is executed (optional).
|
||||||
|
*/
|
||||||
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The tearDown() method is executed after the test was executed (optional)
|
||||||
|
* This can be used for cleanup.
|
||||||
|
*/
|
||||||
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple example test case.
|
||||||
|
*
|
||||||
|
* Note how the function name begins with the word "test".
|
||||||
|
*/
|
||||||
|
public function testApiExample() {
|
||||||
|
$result = civicrm_api3('TwingleCampaign', 'Delete', array('magicword' => 'sesame'));
|
||||||
|
$this->assertEquals('Twelve', $result['values'][12]['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
53
tests/phpunit/api/v3/TwingleEvent/DeleteTest.php
Normal file
53
tests/phpunit/api/v3/TwingleEvent/DeleteTest.php
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Civi\Test\HeadlessInterface;
|
||||||
|
use Civi\Test\HookInterface;
|
||||||
|
use Civi\Test\TransactionalInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TwingleEvent.Delete API Test Case
|
||||||
|
* This is a generic test class implemented with PHPUnit.
|
||||||
|
* @group headless
|
||||||
|
*/
|
||||||
|
class api_v3_TwingleEvent_DeleteTest extends \PHPUnit\Framework\TestCase implements HeadlessInterface, HookInterface, TransactionalInterface {
|
||||||
|
use \Civi\Test\Api3TestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up for headless tests.
|
||||||
|
*
|
||||||
|
* Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile().
|
||||||
|
*
|
||||||
|
* See: https://docs.civicrm.org/dev/en/latest/testing/phpunit/#civitest
|
||||||
|
*/
|
||||||
|
public function setUpHeadless() {
|
||||||
|
return \Civi\Test::headless()
|
||||||
|
->installMe(__DIR__)
|
||||||
|
->apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The setup() method is executed before the test is executed (optional).
|
||||||
|
*/
|
||||||
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The tearDown() method is executed after the test was executed (optional)
|
||||||
|
* This can be used for cleanup.
|
||||||
|
*/
|
||||||
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple example test case.
|
||||||
|
*
|
||||||
|
* Note how the function name begins with the word "test".
|
||||||
|
*/
|
||||||
|
public function testApiExample() {
|
||||||
|
$result = civicrm_api3('TwingleEvent', 'Delete', array('magicword' => 'sesame'));
|
||||||
|
$this->assertEquals('Twelve', $result['values'][12]['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
53
tests/phpunit/api/v3/TwingleProject/DeleteTest.php
Normal file
53
tests/phpunit/api/v3/TwingleProject/DeleteTest.php
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Civi\Test\HeadlessInterface;
|
||||||
|
use Civi\Test\HookInterface;
|
||||||
|
use Civi\Test\TransactionalInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TwingleProject.Delete API Test Case
|
||||||
|
* This is a generic test class implemented with PHPUnit.
|
||||||
|
* @group headless
|
||||||
|
*/
|
||||||
|
class api_v3_TwingleProject_DeleteTest extends \PHPUnit\Framework\TestCase implements HeadlessInterface, HookInterface, TransactionalInterface {
|
||||||
|
use \Civi\Test\Api3TestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up for headless tests.
|
||||||
|
*
|
||||||
|
* Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile().
|
||||||
|
*
|
||||||
|
* See: https://docs.civicrm.org/dev/en/latest/testing/phpunit/#civitest
|
||||||
|
*/
|
||||||
|
public function setUpHeadless() {
|
||||||
|
return \Civi\Test::headless()
|
||||||
|
->installMe(__DIR__)
|
||||||
|
->apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The setup() method is executed before the test is executed (optional).
|
||||||
|
*/
|
||||||
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The tearDown() method is executed after the test was executed (optional)
|
||||||
|
* This can be used for cleanup.
|
||||||
|
*/
|
||||||
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple example test case.
|
||||||
|
*
|
||||||
|
* Note how the function name begins with the word "test".
|
||||||
|
*/
|
||||||
|
public function testApiExample() {
|
||||||
|
$result = civicrm_api3('TwingleProject', 'Delete', array('magicword' => 'sesame'));
|
||||||
|
$this->assertEquals('Twelve', $result['values'][12]['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue