diff --git a/api/v3/TwingleEvent/Getsingle.php b/api/v3/TwingleEvent/Getsingle.php new file mode 100644 index 0000000..61f1987 --- /dev/null +++ b/api/v3/TwingleEvent/Getsingle.php @@ -0,0 +1,106 @@ + 'id', + 'title' => E::ts('Campaign ID'), + 'type' => CRM_Utils_Type::T_INT, + 'api.required' => 0, + 'description' => E::ts('Unique Campaign ID'), + ]; + $spec['name'] = [ + 'name' => 'name', + 'title' => E::ts('Campaign Name'), + 'type' => CRM_Utils_Type::T_STRING, + 'api.required' => 0, + 'description' => E::ts('Name of the Campaign'), + ]; + $spec['title'] = [ + 'name' => 'title', + 'title' => E::ts('Campaign Title'), + 'type' => CRM_Utils_Type::T_STRING, + 'api.required' => 0, + 'description' => E::ts('Title of the Campaign'), + ]; + $spec['start_date'] = [ + 'name' => 'start_date', + 'title' => E::ts('Campaign Start Date'), + 'type' => CRM_Utils_Type::T_STRING, + 'api.required' => 0, + 'description' => E::ts('Date and Time that Campaign starts.'), + ]; + $spec['project_id'] = [ + 'name' => 'project_id', + 'title' => E::ts('Twingle Project ID'), + 'type' => CRM_Utils_Type::T_INT, + 'api.required' => 0, + 'description' => E::ts('Parent Project ID for this Event'), + ]; + $spec['event_id'] = [ + 'name' => 'event_id', + 'title' => E::ts('Twingle Event ID'), + 'type' => CRM_Utils_Type::T_INT, + 'api.required' => 0, + 'description' => E::ts('Twingle ID for this Event'), + ]; + $spec['last_modified_id'] = [ + 'name' => 'last_modified_id', + 'title' => E::ts('Campaign Modified By'), + 'type' => CRM_Utils_Type::T_INT, + 'api.required' => 0, + 'description' => E::ts('FK ti civicrm_contact, who recently edited this campaign'), + 'FKClassName' => 'CRM_Contact_DAO_Contact', + ]; + $spec['last_modified_date'] = [ + 'name' => 'last_modified_date', + 'title' => E::ts('Campaign Modified Date'), + 'type' => CRM_Utils_Type::T_STRING, + 'api.required' => 0, + 'description' => E::ts('FK ti civicrm_contact, who recently edited this campaign'), + ]; + $spec['is_active'] = [ + 'name' => 'is_active', + 'title' => E::ts('Campaign is active'), + 'type' => CRM_Utils_Type::T_BOOLEAN, + 'api.required' => 0, + 'description' => E::ts('Is this Campaign enabled or disabled/cancelled?'), + ]; + $spec['confirmed_at'] = [ + 'name' => 'confirmed_at', + 'title' => E::ts('Confirmed at'), + 'type' => CRM_Utils_Type::T_BOOLEAN, + 'api.required' => 0, + 'description' => E::ts('When the Event was confirmed by its initiator'), + ]; +} + +/** + * TwingleEvent.Getsingle API + * + * @param array $params + * + * @return array + * API result descriptor + * + * @throws CiviCRM_API3_Exception + * @see civicrm_api3_create_success + */ +function civicrm_api3_twingle_event_Getsingle(array $params): array { + $returnValues = civicrm_api3('TwingleEvent', 'get', $params); + $count = $returnValues['count']; + + if ($count != 1) { + return civicrm_api3_create_error("Expected one TwingleEvent but found $count"); + } + return civicrm_api3_create_success($returnValues, $params, 'TwingleEvent', 'Getsingle'); +} diff --git a/api/v3/TwingleForm/Getsingle.php b/api/v3/TwingleForm/Getsingle.php new file mode 100644 index 0000000..55ca9a5 --- /dev/null +++ b/api/v3/TwingleForm/Getsingle.php @@ -0,0 +1,63 @@ + 'id', + 'title' => E::ts('TwingleProject ID'), + 'type' => CRM_Utils_Type::T_INT, + 'api.required' => 0, + 'description' => E::ts('ID of the TwingleProject campaign'), + ]; + $spec['name'] = [ + 'name' => 'name', + 'title' => E::ts('TwingleProject name'), + 'type' => CRM_Utils_Type::T_STRING, + 'api.required' => 0, + 'description' => E::ts('Name of the TwingleProject campaign'), + ]; + $spec['title'] = [ + 'name' => 'title', + 'title' => E::ts('TwingleProject title'), + 'type' => CRM_Utils_Type::T_STRING, + 'api.required' => 0, + 'description' => E::ts('Title of the TwingleProject campaign'), + ]; + $spec['twingle_project_type'] = [ + 'name' => 'twingle_project_type', + 'title' => E::ts('TwingleProject type'), + 'type' => CRM_Utils_Type::T_STRING, + 'api.required' => 0, + 'description' => E::ts('Project type can be default, event or membership'), + ]; +} + +/** + * TwingleForm.Getsingle API + * + * @param array $params + * + * @return array + * API result descriptor + * + * @throws \API_Exception + * @throws \CiviCRM_API3_Exception + * @see civicrm_api3_create_success + */ +function civicrm_api3_twingle_form_Getsingle(array $params): array { + $returnValues = civicrm_api3('TwingleForm', 'get', $params); + $count = $returnValues['count']; + + if ($count != 1){ + return civicrm_api3_create_error("Expected one TwingleForm but found $count"); + } + return civicrm_api3_create_success($returnValues, $params, 'TwingleForm', 'Getsingle'); +} diff --git a/api/v3/TwingleProject/Getsingle.php b/api/v3/TwingleProject/Getsingle.php new file mode 100644 index 0000000..a5aca01 --- /dev/null +++ b/api/v3/TwingleProject/Getsingle.php @@ -0,0 +1,113 @@ + 'id', + 'title' => E::ts('Campaign ID'), + 'type' => CRM_Utils_Type::T_INT, + 'api.required' => 0, + 'description' => E::ts('Unique Campaign ID'), + ]; + $spec['name'] = [ + 'name' => 'name', + 'title' => E::ts('Campaign Name'), + 'type' => CRM_Utils_Type::T_STRING, + 'api.required' => 0, + 'description' => E::ts('Name of the Campaign'), + ]; + $spec['title'] = [ + 'name' => 'title', + 'title' => E::ts('Campaign Title'), + 'type' => CRM_Utils_Type::T_STRING, + 'api.required' => 0, + 'description' => E::ts('Title of the Campaign'), + ]; + $spec['start_date'] = [ + 'name' => 'start_date', + 'title' => E::ts('Campaign Start Date'), + 'type' => CRM_Utils_Type::T_STRING, + 'api.required' => 0, + 'description' => E::ts('Date and Time that Campaign starts.'), + ]; + $spec['project_id'] = [ + 'name' => 'project_id', + 'title' => E::ts('Twingle Project ID'), + 'type' => CRM_Utils_Type::T_INT, + 'api.required' => 0, + 'description' => E::ts('Twingle ID for this project'), + ]; + $spec['last_modified_id'] = [ + 'name' => 'last_modified_id', + 'title' => E::ts('Campaign Modified By'), + 'type' => CRM_Utils_Type::T_INT, + 'api.required' => 0, + 'description' => E::ts('FK ti civicrm_contact, who recently edited this campaign'), + 'FKClassName' => 'CRM_Contact_DAO_Contact', + ]; + $spec['last_modified_date'] = [ + 'name' => 'last_modified_date', + 'title' => E::ts('Campaign Modified Date'), + 'type' => CRM_Utils_Type::T_STRING, + 'api.required' => 0, + 'description' => E::ts('FK ti civicrm_contact, who recently edited this campaign'), + ]; + $spec['type'] = [ + 'name' => 'type', + 'title' => E::ts('Twingle Project Type'), + 'type' => CRM_Utils_Type::T_STRING, + 'api.required' => 0, + 'description' => E::ts('The type of the Twingle Project'), + ]; + $spec['allow_more'] = [ + 'name' => 'allow_more', + 'title' => E::ts('Allow more'), + 'type' => CRM_Utils_Type::T_BOOLEAN, + 'api.required' => 0, + 'description' => E::ts('Allow to donate more than is defined in the target'), + ]; + $spec['organisation_id'] = [ + 'name' => 'organisation_id', + 'title' => E::ts('Twingle Organisation ID'), + 'type' => CRM_Utils_Type::T_INT, + 'api.required' => 0, + 'description' => E::ts('Your Twingle Organisation ID'), + ]; + $spec['is_active'] = [ + 'name' => 'is_active', + 'title' => E::ts('Campaign is active'), + 'type' => CRM_Utils_Type::T_BOOLEAN, + 'api.required' => 0, + 'description' => E::ts('Is this Campaign enabled or disabled/cancelled?'), + ]; +} + +/** + * TwingleProject.Getsingle API + * + * @param array $params + * + * @return array + * API result descriptor + * + * @throws CiviCRM_API3_Exception + * @see civicrm_api3_create_success + */ +function civicrm_api3_twingle_project_Getsingle(array $params): array { + $returnValues = civicrm_api3('TwingleProject', 'get', $params); + $count = $returnValues['count']; + + if ($count != 1) { + return civicrm_api3_create_error("Expected one TwingleProject but found $count"); + } + return civicrm_api3_create_success($returnValues, $params, 'TwingleProject', 'Getsingle'); +} diff --git a/tests/phpunit/api/v3/TwingleEvent/GetsingleTest.php b/tests/phpunit/api/v3/TwingleEvent/GetsingleTest.php new file mode 100644 index 0000000..48ea476 --- /dev/null +++ b/tests/phpunit/api/v3/TwingleEvent/GetsingleTest.php @@ -0,0 +1,53 @@ +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', 'Getsingle', array('magicword' => 'sesame')); + $this->assertEquals('Twelve', $result['values'][12]['name']); + } + +} diff --git a/tests/phpunit/api/v3/TwingleForm/GetsingleTest.php b/tests/phpunit/api/v3/TwingleForm/GetsingleTest.php new file mode 100644 index 0000000..de76920 --- /dev/null +++ b/tests/phpunit/api/v3/TwingleForm/GetsingleTest.php @@ -0,0 +1,53 @@ +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('TwingleForm', 'Getsingle', array('magicword' => 'sesame')); + $this->assertEquals('Twelve', $result['values'][12]['name']); + } + +} diff --git a/tests/phpunit/api/v3/TwingleProject/GetsingleTest.php b/tests/phpunit/api/v3/TwingleProject/GetsingleTest.php new file mode 100644 index 0000000..87c6882 --- /dev/null +++ b/tests/phpunit/api/v3/TwingleProject/GetsingleTest.php @@ -0,0 +1,53 @@ +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', 'Getsingle', array('magicword' => 'sesame')); + $this->assertEquals('Twelve', $result['values'][12]['name']); + } + +}