First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.create API.
|
||||
*
|
||||
* Demonstrates create with Contact Reference Custom Field.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_create_example() {
|
||||
$params = array(
|
||||
'source_contact_id' => 1,
|
||||
'activity_type_id' => 'Test activity type',
|
||||
'subject' => 'test activity type id',
|
||||
'activity_date_time' => '2011-06-02 14:36:13',
|
||||
'status_id' => 2,
|
||||
'priority_id' => 1,
|
||||
'duration' => 120,
|
||||
'location' => 'Pennsylvania',
|
||||
'details' => 'a test activity',
|
||||
'custom_2' => '1',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'source_record_id' => '',
|
||||
'activity_type_id' => '9999',
|
||||
'subject' => 'test activity type id',
|
||||
'activity_date_time' => '20110602143613',
|
||||
'duration' => '120',
|
||||
'location' => 'Pennsylvania',
|
||||
'phone_id' => '',
|
||||
'phone_number' => '',
|
||||
'details' => 'a test activity',
|
||||
'status_id' => '2',
|
||||
'priority_id' => '1',
|
||||
'parent_id' => '',
|
||||
'is_test' => '',
|
||||
'medium_id' => '',
|
||||
'is_auto' => '',
|
||||
'relationship_id' => '',
|
||||
'is_current_revision' => '',
|
||||
'original_id' => '',
|
||||
'result' => '',
|
||||
'is_deleted' => '',
|
||||
'campaign_id' => '',
|
||||
'engagement_level' => '',
|
||||
'weight' => '',
|
||||
'is_star' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testActivityCreateCustomContactRefField"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.get API.
|
||||
*
|
||||
* Get with Contact Ref Custom Field
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_example() {
|
||||
$params = array(
|
||||
'return.custom_2' => 1,
|
||||
'id' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'activity_type_id' => '9999',
|
||||
'subject' => 'test activity type id',
|
||||
'activity_date_time' => '2011-06-02 14:36:13',
|
||||
'duration' => '120',
|
||||
'location' => 'Pennsylvania',
|
||||
'details' => 'a test activity',
|
||||
'status_id' => '2',
|
||||
'priority_id' => '1',
|
||||
'is_test' => 0,
|
||||
'is_auto' => 0,
|
||||
'is_current_revision' => '1',
|
||||
'is_deleted' => 0,
|
||||
'is_star' => 0,
|
||||
'custom_1' => 'defaultValue',
|
||||
'custom_2_id' => '1',
|
||||
'custom_2' => 'Anderson, Anthony',
|
||||
'source_contact_id' => '1',
|
||||
'custom_1_1' => 'defaultValue',
|
||||
'custom_2_1' => 'Anderson, Anthony',
|
||||
'custom_2_1_id' => '1',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testActivityCreateCustomContactRefField"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
108
sites/all/modules/civicrm/api/v3/examples/Activity/Create.php
Normal file
108
sites/all/modules/civicrm/api/v3/examples/Activity/Create.php
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.create API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_create_example() {
|
||||
$params = array(
|
||||
'source_contact_id' => 1,
|
||||
'activity_type_id' => 'Test activity type',
|
||||
'subject' => 'test activity type id',
|
||||
'activity_date_time' => '2011-06-02 14:36:13',
|
||||
'status_id' => 2,
|
||||
'priority_id' => 1,
|
||||
'duration' => 120,
|
||||
'location' => 'Pennsylvania',
|
||||
'details' => 'a test activity',
|
||||
'custom_1' => 'custom string',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'source_record_id' => '',
|
||||
'activity_type_id' => '9999',
|
||||
'subject' => 'test activity type id',
|
||||
'activity_date_time' => '20110602143613',
|
||||
'duration' => '120',
|
||||
'location' => 'Pennsylvania',
|
||||
'phone_id' => '',
|
||||
'phone_number' => '',
|
||||
'details' => 'a test activity',
|
||||
'status_id' => '2',
|
||||
'priority_id' => '1',
|
||||
'parent_id' => '',
|
||||
'is_test' => '',
|
||||
'medium_id' => '',
|
||||
'is_auto' => '',
|
||||
'relationship_id' => '',
|
||||
'is_current_revision' => '',
|
||||
'original_id' => '',
|
||||
'result' => '',
|
||||
'is_deleted' => '',
|
||||
'campaign_id' => '',
|
||||
'engagement_level' => '',
|
||||
'weight' => '',
|
||||
'is_star' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testActivityCreateCustomSubType"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.get API.
|
||||
*
|
||||
* Demonstrates _high filter (at time of writing doesn't work if contact_id is set.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_example() {
|
||||
$params = array(
|
||||
'source_contact_id' => 1,
|
||||
'filter.activity_date_time_high' => '20120101000000',
|
||||
'sequential' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '1',
|
||||
'activity_type_id' => '9999',
|
||||
'subject' => 'Make-it-Happen Meeting',
|
||||
'activity_date_time' => '2011-01-01 00:00:00',
|
||||
'duration' => '120',
|
||||
'location' => 'Pennsylvania',
|
||||
'details' => 'a test activity',
|
||||
'status_id' => '1',
|
||||
'priority_id' => '1',
|
||||
'is_test' => 0,
|
||||
'is_auto' => 0,
|
||||
'is_current_revision' => '1',
|
||||
'is_deleted' => 0,
|
||||
'is_star' => 0,
|
||||
'source_contact_id' => '1',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetFilterMaxDate"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.get API.
|
||||
*
|
||||
* Demonstrates _low filter (at time of writing doesn't work if contact_id is set.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_example() {
|
||||
$params = array(
|
||||
'filter.activity_date_time_low' => '20120101000000',
|
||||
'sequential' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 2,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '2',
|
||||
'activity_type_id' => '9999',
|
||||
'subject' => 'Make-it-Happen Meeting',
|
||||
'activity_date_time' => '2012-02-16 00:00:00',
|
||||
'duration' => '120',
|
||||
'location' => 'Pennsylvania',
|
||||
'details' => 'a test activity',
|
||||
'status_id' => '1',
|
||||
'priority_id' => '1',
|
||||
'is_test' => 0,
|
||||
'is_auto' => 0,
|
||||
'is_current_revision' => '1',
|
||||
'is_deleted' => 0,
|
||||
'is_star' => 0,
|
||||
'source_contact_id' => '1',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetFilterMaxDate"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.delete API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_delete_example() {
|
||||
$params = array(
|
||||
'id' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'delete', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_delete_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'values' => 1,
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testDeleteActivity"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
96
sites/all/modules/civicrm/api/v3/examples/Activity/Get.php
Normal file
96
sites/all/modules/civicrm/api/v3/examples/Activity/Get.php
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.get API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_example() {
|
||||
$params = array(
|
||||
'contact_id' => 1,
|
||||
'activity_type_id' => 9999,
|
||||
'sequential' => 1,
|
||||
'return.custom_1' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '1',
|
||||
'activity_type_id' => '9999',
|
||||
'subject' => 'test activity type id',
|
||||
'activity_date_time' => '2011-06-02 14:36:13',
|
||||
'duration' => '120',
|
||||
'location' => 'Pennsylvania',
|
||||
'details' => 'a test activity',
|
||||
'status_id' => '2',
|
||||
'priority_id' => '1',
|
||||
'is_test' => 0,
|
||||
'is_auto' => 0,
|
||||
'is_current_revision' => '1',
|
||||
'is_deleted' => 0,
|
||||
'is_star' => 0,
|
||||
'custom_1' => 'custom string',
|
||||
'source_contact_id' => '1',
|
||||
'status' => 'Completed',
|
||||
'activity_name' => 'Test activity type',
|
||||
'custom_1_1' => 'custom string',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testActivityGetContact_idCustom"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
526
sites/all/modules/civicrm/api/v3/examples/Activity/GetFields.php
Normal file
526
sites/all/modules/civicrm/api/v3/examples/Activity/GetFields.php
Normal file
|
@ -0,0 +1,526 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.getfields API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_getfields_example() {
|
||||
$params = array(
|
||||
'action' => 'create',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'getfields', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_getfields_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 29,
|
||||
'values' => array(
|
||||
'source_record_id' => array(
|
||||
'name' => 'source_record_id',
|
||||
'type' => 1,
|
||||
'title' => 'Source Record',
|
||||
'description' => 'Artificial FK to original transaction (e.g. contribution) IF it is not an Activity. Table can be figured out through activity_type_id, and further through component registry.',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
),
|
||||
'activity_type_id' => array(
|
||||
'name' => 'activity_type_id',
|
||||
'type' => 1,
|
||||
'title' => 'Activity Type ID',
|
||||
'description' => 'FK to civicrm_option_value.id, that has to be valid, registered activity type.',
|
||||
'required' => TRUE,
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.activity_type_id',
|
||||
'headerPattern' => '/(activity.)?type(.id$)/i',
|
||||
'export' => TRUE,
|
||||
'default' => '1',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
'size' => 6,
|
||||
'maxlength' => 14,
|
||||
),
|
||||
'pseudoconstant' => array(
|
||||
'optionGroupName' => 'activity_type',
|
||||
'optionEditPath' => 'civicrm/admin/options/activity_type',
|
||||
),
|
||||
),
|
||||
'activity_date_time' => array(
|
||||
'name' => 'activity_date_time',
|
||||
'type' => 12,
|
||||
'title' => 'Activity Date',
|
||||
'description' => 'Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.activity_date_time',
|
||||
'headerPattern' => '/(activity.)?date(.time$)?/i',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Select Date',
|
||||
'format' => 'activityDateTime',
|
||||
),
|
||||
),
|
||||
'phone_id' => array(
|
||||
'name' => 'phone_id',
|
||||
'type' => 1,
|
||||
'title' => 'Phone (called) ID',
|
||||
'description' => 'Phone ID of the number called (optional - used if an existing phone number is selected).',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'FKClassName' => 'CRM_Core_DAO_Phone',
|
||||
'html' => array(
|
||||
'type' => 'EntityRef',
|
||||
'size' => 6,
|
||||
'maxlength' => 14,
|
||||
),
|
||||
'FKApiName' => 'Phone',
|
||||
),
|
||||
'phone_number' => array(
|
||||
'name' => 'phone_number',
|
||||
'type' => 2,
|
||||
'title' => 'Phone (called) Number',
|
||||
'description' => 'Phone number in case the number does not exist in the civicrm_phone table.',
|
||||
'maxlength' => 64,
|
||||
'size' => 30,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
'maxlength' => 64,
|
||||
'size' => 30,
|
||||
),
|
||||
),
|
||||
'priority_id' => array(
|
||||
'name' => 'priority_id',
|
||||
'type' => 1,
|
||||
'title' => 'Priority',
|
||||
'description' => 'ID of the priority given to this activity. Foreign key to civicrm_option_value.',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
'size' => 6,
|
||||
'maxlength' => 14,
|
||||
),
|
||||
'pseudoconstant' => array(
|
||||
'optionGroupName' => 'priority',
|
||||
'optionEditPath' => 'civicrm/admin/options/priority',
|
||||
),
|
||||
),
|
||||
'parent_id' => array(
|
||||
'name' => 'parent_id',
|
||||
'type' => 1,
|
||||
'title' => 'Parent Activity Id',
|
||||
'description' => 'Parent meeting ID (if this is a follow-up item). This is not currently implemented',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'FKClassName' => 'CRM_Activity_DAO_Activity',
|
||||
'FKApiName' => 'Activity',
|
||||
),
|
||||
'is_auto' => array(
|
||||
'name' => 'is_auto',
|
||||
'type' => 16,
|
||||
'title' => 'Auto',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
),
|
||||
'relationship_id' => array(
|
||||
'name' => 'relationship_id',
|
||||
'type' => 1,
|
||||
'title' => 'Relationship Id',
|
||||
'description' => 'FK to Relationship ID',
|
||||
'default' => 'NULL',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'FKClassName' => 'CRM_Contact_DAO_Relationship',
|
||||
'FKApiName' => 'Relationship',
|
||||
),
|
||||
'is_current_revision' => array(
|
||||
'name' => 'is_current_revision',
|
||||
'type' => 16,
|
||||
'title' => 'Is this activity a current revision in versioning chain?',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.is_current_revision',
|
||||
'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
|
||||
'export' => TRUE,
|
||||
'default' => '1',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'CheckBox',
|
||||
),
|
||||
),
|
||||
'original_id' => array(
|
||||
'name' => 'original_id',
|
||||
'type' => 1,
|
||||
'title' => 'Original Activity ID ',
|
||||
'description' => 'Activity ID of the first activity record in versioning chain.',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'FKClassName' => 'CRM_Activity_DAO_Activity',
|
||||
'FKApiName' => 'Activity',
|
||||
),
|
||||
'weight' => array(
|
||||
'name' => 'weight',
|
||||
'type' => 1,
|
||||
'title' => 'Order',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
'size' => 6,
|
||||
'maxlength' => 14,
|
||||
),
|
||||
),
|
||||
'is_star' => array(
|
||||
'name' => 'is_star',
|
||||
'type' => 16,
|
||||
'title' => 'Is Starred',
|
||||
'description' => 'Activity marked as favorite.',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.is_star',
|
||||
'headerPattern' => '/(activity.)?(star|favorite)/i',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
),
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => 1,
|
||||
'title' => 'Activity ID',
|
||||
'description' => 'Unique Other Activity ID',
|
||||
'required' => TRUE,
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.id',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'uniqueName' => 'activity_id',
|
||||
'api.aliases' => array(
|
||||
'0' => 'activity_id',
|
||||
),
|
||||
),
|
||||
'subject' => array(
|
||||
'name' => 'subject',
|
||||
'type' => 2,
|
||||
'title' => 'Subject',
|
||||
'description' => 'The subject/purpose/short description of the activity.',
|
||||
'maxlength' => 255,
|
||||
'size' => 45,
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.subject',
|
||||
'headerPattern' => '/(activity.)?subject/i',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
'maxlength' => 255,
|
||||
'size' => 45,
|
||||
),
|
||||
'uniqueName' => 'activity_subject',
|
||||
),
|
||||
'duration' => array(
|
||||
'name' => 'duration',
|
||||
'type' => 1,
|
||||
'title' => 'Duration',
|
||||
'description' => 'Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.duration',
|
||||
'headerPattern' => '/(activity.)?duration(s)?$/i',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
'size' => 6,
|
||||
'maxlength' => 14,
|
||||
),
|
||||
'uniqueName' => 'activity_duration',
|
||||
),
|
||||
'location' => array(
|
||||
'name' => 'location',
|
||||
'type' => 2,
|
||||
'title' => 'Location',
|
||||
'description' => 'Location of the activity (optional, open text).',
|
||||
'maxlength' => 255,
|
||||
'size' => 45,
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.location',
|
||||
'headerPattern' => '/(activity.)?location$/i',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
'maxlength' => 255,
|
||||
'size' => 45,
|
||||
),
|
||||
'uniqueName' => 'activity_location',
|
||||
),
|
||||
'details' => array(
|
||||
'name' => 'details',
|
||||
'type' => 32,
|
||||
'title' => 'Details',
|
||||
'description' => 'Details about the activity (agenda, notes, etc).',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.details',
|
||||
'headerPattern' => '/(activity.)?detail(s)?$/i',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'RichTextEditor',
|
||||
'rows' => 2,
|
||||
'cols' => 80,
|
||||
),
|
||||
'uniqueName' => 'activity_details',
|
||||
),
|
||||
'status_id' => array(
|
||||
'name' => 'status_id',
|
||||
'type' => 1,
|
||||
'title' => 'Activity Status',
|
||||
'description' => 'ID of the status this activity is currently in. Foreign key to civicrm_option_value.',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.status_id',
|
||||
'headerPattern' => '/(activity.)?status(.label$)?/i',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
'size' => 6,
|
||||
'maxlength' => 14,
|
||||
),
|
||||
'pseudoconstant' => array(
|
||||
'optionGroupName' => 'activity_status',
|
||||
'optionEditPath' => 'civicrm/admin/options/activity_status',
|
||||
),
|
||||
'uniqueName' => 'activity_status_id',
|
||||
'api.aliases' => array(
|
||||
'0' => 'activity_status',
|
||||
),
|
||||
),
|
||||
'is_test' => array(
|
||||
'name' => 'is_test',
|
||||
'type' => 16,
|
||||
'title' => 'Test',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.is_test',
|
||||
'headerPattern' => '/(is.)?test(.activity)?/i',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
),
|
||||
'uniqueName' => 'activity_is_test',
|
||||
),
|
||||
'medium_id' => array(
|
||||
'name' => 'medium_id',
|
||||
'type' => 1,
|
||||
'title' => 'Activity Medium',
|
||||
'description' => 'Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.',
|
||||
'default' => 'NULL',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
'size' => 6,
|
||||
'maxlength' => 14,
|
||||
),
|
||||
'pseudoconstant' => array(
|
||||
'optionGroupName' => 'encounter_medium',
|
||||
'optionEditPath' => 'civicrm/admin/options/encounter_medium',
|
||||
),
|
||||
'uniqueName' => 'activity_medium_id',
|
||||
),
|
||||
'result' => array(
|
||||
'name' => 'result',
|
||||
'type' => 2,
|
||||
'title' => 'Result',
|
||||
'description' => 'Currently being used to store result id for survey activity, FK to option value.',
|
||||
'maxlength' => 255,
|
||||
'size' => 45,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
'maxlength' => 255,
|
||||
'size' => 45,
|
||||
),
|
||||
'uniqueName' => 'activity_result',
|
||||
),
|
||||
'is_deleted' => array(
|
||||
'name' => 'is_deleted',
|
||||
'type' => 16,
|
||||
'title' => 'Activity is in the Trash',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.is_deleted',
|
||||
'headerPattern' => '/(activity.)?(trash|deleted)/i',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
),
|
||||
'uniqueName' => 'activity_is_deleted',
|
||||
),
|
||||
'campaign_id' => array(
|
||||
'name' => 'campaign_id',
|
||||
'type' => 1,
|
||||
'title' => 'Campaign',
|
||||
'description' => 'The campaign for which this activity has been triggered.',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.campaign_id',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'FKClassName' => 'CRM_Campaign_DAO_Campaign',
|
||||
'html' => array(
|
||||
'type' => 'CheckBox',
|
||||
'size' => 6,
|
||||
'maxlength' => 14,
|
||||
),
|
||||
'pseudoconstant' => array(
|
||||
'table' => 'civicrm_campaign',
|
||||
'keyColumn' => 'id',
|
||||
'labelColumn' => 'title',
|
||||
),
|
||||
'uniqueName' => 'activity_campaign_id',
|
||||
'FKApiName' => 'Campaign',
|
||||
),
|
||||
'engagement_level' => array(
|
||||
'name' => 'engagement_level',
|
||||
'type' => 1,
|
||||
'title' => 'Engagement Index',
|
||||
'description' => 'Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.engagement_level',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
'size' => 6,
|
||||
'maxlength' => 14,
|
||||
),
|
||||
'pseudoconstant' => array(
|
||||
'optionGroupName' => 'engagement_index',
|
||||
'optionEditPath' => 'civicrm/admin/options/engagement_index',
|
||||
),
|
||||
'uniqueName' => 'activity_engagement_level',
|
||||
),
|
||||
'source_contact_id' => array(
|
||||
'name' => 'source_contact_id',
|
||||
'title' => 'Activity Source Contact',
|
||||
'description' => 'Person who created this activity. Defaults to current user.',
|
||||
'type' => 1,
|
||||
'FKClassName' => 'CRM_Contact_DAO_Contact',
|
||||
'api.default' => 'user_contact_id',
|
||||
'FKApiName' => 'Contact',
|
||||
),
|
||||
'assignee_contact_id' => array(
|
||||
'name' => 'assignee_id',
|
||||
'title' => 'Activity Assignee',
|
||||
'description' => 'Contact(s) assigned to this activity.',
|
||||
'type' => 1,
|
||||
'FKClassName' => 'CRM_Contact_DAO_Contact',
|
||||
'FKApiName' => 'Contact',
|
||||
),
|
||||
'target_contact_id' => array(
|
||||
'name' => 'target_id',
|
||||
'title' => 'Activity Target',
|
||||
'description' => 'Contact(s) participating in this activity.',
|
||||
'type' => 1,
|
||||
'FKClassName' => 'CRM_Contact_DAO_Contact',
|
||||
'FKApiName' => 'Contact',
|
||||
),
|
||||
'case_id' => array(
|
||||
'name' => 'case_id',
|
||||
'title' => 'Case ID',
|
||||
'description' => 'For creating an activity as part of a case.',
|
||||
'type' => 1,
|
||||
'FKClassName' => 'CRM_Case_DAO_Case',
|
||||
'FKApiName' => 'Case',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetFields"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.create API.
|
||||
*
|
||||
* Demonstrates setting & retrieving activity target & source.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_create_example() {
|
||||
$params = array(
|
||||
'source_contact_id' => 1,
|
||||
'subject' => 'Make-it-Happen Meeting',
|
||||
'activity_date_time' => '20110316',
|
||||
'duration' => 120,
|
||||
'location' => 'Pennsylvania',
|
||||
'details' => 'a test activity',
|
||||
'status_id' => 1,
|
||||
'activity_type_id' => 1,
|
||||
'priority_id' => 1,
|
||||
'target_contact_id' => 1,
|
||||
'assignee_contact_id' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'source_record_id' => '',
|
||||
'activity_type_id' => '1',
|
||||
'subject' => 'Make-it-Happen Meeting',
|
||||
'activity_date_time' => '20110316000000',
|
||||
'duration' => '120',
|
||||
'location' => 'Pennsylvania',
|
||||
'phone_id' => '',
|
||||
'phone_number' => '',
|
||||
'details' => 'a test activity',
|
||||
'status_id' => '1',
|
||||
'priority_id' => '1',
|
||||
'parent_id' => '',
|
||||
'is_test' => '',
|
||||
'medium_id' => '',
|
||||
'is_auto' => '',
|
||||
'relationship_id' => '',
|
||||
'is_current_revision' => '',
|
||||
'original_id' => '',
|
||||
'result' => '',
|
||||
'is_deleted' => '',
|
||||
'campaign_id' => '',
|
||||
'engagement_level' => '',
|
||||
'weight' => '',
|
||||
'is_star' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testActivityReturnTargetAssignee"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.getsingle API.
|
||||
*
|
||||
* Demonstrates retrieving activity target & source contact names.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_getsingle_example() {
|
||||
$params = array(
|
||||
'id' => 1,
|
||||
'return' => array(
|
||||
'0' => 'source_contact_name',
|
||||
'1' => 'target_contact_name',
|
||||
'2' => 'assignee_contact_name',
|
||||
'3' => 'subject',
|
||||
),
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'getsingle', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_getsingle_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'id' => '1',
|
||||
'subject' => 'Make-it-Happen Meeting',
|
||||
'source_contact_id' => '6',
|
||||
'source_contact_name' => 'D Bug',
|
||||
'target_contact_id' => array(
|
||||
'1' => '4',
|
||||
),
|
||||
'target_contact_name' => array(
|
||||
'3' => 'A Cat',
|
||||
'4' => 'B Good',
|
||||
),
|
||||
'assignee_contact_id' => array(),
|
||||
'assignee_contact_name' => array(
|
||||
'5' => 'C Shore',
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testActivityReturnTargetAssigneeName"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,177 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.get API.
|
||||
*
|
||||
* Demonstrates getting assignee_contact_id & using it to get the contact.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_example() {
|
||||
$params = array(
|
||||
'activity_id' => 1,
|
||||
'sequential' => 1,
|
||||
'return.assignee_contact_id' => 1,
|
||||
'api.contact.get' => array(
|
||||
'id' => '$value.source_contact_id',
|
||||
),
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '1',
|
||||
'activity_type_id' => '9999',
|
||||
'subject' => 'test activity type id',
|
||||
'activity_date_time' => '2011-06-02 14:36:13',
|
||||
'duration' => '120',
|
||||
'location' => 'Pennsylvania',
|
||||
'details' => 'a test activity',
|
||||
'status_id' => '2',
|
||||
'priority_id' => '1',
|
||||
'is_test' => 0,
|
||||
'is_auto' => 0,
|
||||
'is_current_revision' => '1',
|
||||
'is_deleted' => 0,
|
||||
'is_star' => 0,
|
||||
'assignee_contact_id' => array(
|
||||
'0' => '3',
|
||||
),
|
||||
'source_contact_id' => '1',
|
||||
'api.contact.get' => array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'contact_id' => '1',
|
||||
'contact_type' => 'Individual',
|
||||
'contact_sub_type' => '',
|
||||
'sort_name' => 'Anderson, Anthony',
|
||||
'display_name' => 'Mr. Anthony Anderson II',
|
||||
'do_not_email' => 0,
|
||||
'do_not_phone' => 0,
|
||||
'do_not_mail' => 0,
|
||||
'do_not_sms' => 0,
|
||||
'do_not_trade' => 0,
|
||||
'is_opt_out' => 0,
|
||||
'legal_identifier' => '',
|
||||
'external_identifier' => '',
|
||||
'nick_name' => '',
|
||||
'legal_name' => '',
|
||||
'image_URL' => '',
|
||||
'preferred_communication_method' => '',
|
||||
'preferred_language' => 'en_US',
|
||||
'preferred_mail_format' => 'Both',
|
||||
'first_name' => 'Anthony',
|
||||
'middle_name' => 'J.',
|
||||
'last_name' => 'Anderson',
|
||||
'prefix_id' => '3',
|
||||
'suffix_id' => '3',
|
||||
'formal_title' => '',
|
||||
'communication_style_id' => '',
|
||||
'job_title' => '',
|
||||
'gender_id' => '',
|
||||
'birth_date' => '',
|
||||
'is_deceased' => 0,
|
||||
'deceased_date' => '',
|
||||
'household_name' => '',
|
||||
'organization_name' => '',
|
||||
'sic_code' => '',
|
||||
'contact_is_deleted' => 0,
|
||||
'current_employer' => '',
|
||||
'address_id' => '',
|
||||
'street_address' => '',
|
||||
'supplemental_address_1' => '',
|
||||
'supplemental_address_2' => '',
|
||||
'supplemental_address_3' => '',
|
||||
'city' => '',
|
||||
'postal_code_suffix' => '',
|
||||
'postal_code' => '',
|
||||
'geo_code_1' => '',
|
||||
'geo_code_2' => '',
|
||||
'state_province_id' => '',
|
||||
'country_id' => '',
|
||||
'phone_id' => '',
|
||||
'phone_type_id' => '',
|
||||
'phone' => '',
|
||||
'email_id' => '1',
|
||||
'email' => 'anthony_anderson@civicrm.org',
|
||||
'on_hold' => 0,
|
||||
'im_id' => '',
|
||||
'provider_id' => '',
|
||||
'im' => '',
|
||||
'worldregion_id' => '',
|
||||
'world_region' => '',
|
||||
'languages' => 'English (United States)',
|
||||
'individual_prefix' => 'Mr.',
|
||||
'individual_suffix' => 'II',
|
||||
'communication_style' => '',
|
||||
'gender' => '',
|
||||
'state_province_name' => '',
|
||||
'state_province' => '',
|
||||
'country' => '',
|
||||
'id' => '1',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testActivityGetGoodID1"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the ActivityContact.create API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_contact_create_example() {
|
||||
$params = array(
|
||||
'contact_id' => 3,
|
||||
'activity_id' => 1,
|
||||
'record_type_id' => 2,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('ActivityContact', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_contact_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 4,
|
||||
'values' => array(
|
||||
'4' => array(
|
||||
'id' => '4',
|
||||
'activity_id' => '1',
|
||||
'contact_id' => '3',
|
||||
'record_type_id' => '2',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateActivityContact"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the ActivityContact.delete API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_contact_delete_example() {
|
||||
$params = array(
|
||||
'id' => 8,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('ActivityContact', 'delete', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_contact_delete_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'values' => 1,
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testDeleteActivityContact"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the ActivityType.create API.
|
||||
*
|
||||
* @deprecated
|
||||
* The ActivityType api is deprecated. Please use the OptionValue api instead.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_type_create_example() {
|
||||
$params = array(
|
||||
'weight' => '2',
|
||||
'label' => 'send out letters',
|
||||
'filter' => 0,
|
||||
'is_active' => 1,
|
||||
'is_optgroup' => 1,
|
||||
'is_default' => 0,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('ActivityType', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_type_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 849,
|
||||
'values' => array(
|
||||
'849' => array(
|
||||
'id' => '849',
|
||||
'option_group_id' => '2',
|
||||
'label' => 'send out letters',
|
||||
'value' => '55',
|
||||
'name' => 'send out letters',
|
||||
'grouping' => '',
|
||||
'filter' => 0,
|
||||
'is_default' => 0,
|
||||
'weight' => '2',
|
||||
'description' => '',
|
||||
'is_optgroup' => '1',
|
||||
'is_reserved' => '',
|
||||
'is_active' => '1',
|
||||
'component_id' => '',
|
||||
'domain_id' => '',
|
||||
'visibility_id' => '',
|
||||
'icon' => '',
|
||||
'color' => '',
|
||||
),
|
||||
),
|
||||
'deprecated' => 'The ActivityType api is deprecated. Please use the OptionValue api instead.',
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testActivityTypeCreate"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTypeTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
127
sites/all/modules/civicrm/api/v3/examples/ActivityType/Get.php
Normal file
127
sites/all/modules/civicrm/api/v3/examples/ActivityType/Get.php
Normal file
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the ActivityType.get API.
|
||||
*
|
||||
* @deprecated
|
||||
* The ActivityType api is deprecated. Please use the OptionValue api instead.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_type_get_example() {
|
||||
$params = array();
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('ActivityType', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_type_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 54,
|
||||
'values' => array(
|
||||
'1' => 'Meeting',
|
||||
'2' => 'Phone Call',
|
||||
'3' => 'Email',
|
||||
'4' => 'Outbound SMS',
|
||||
'5' => 'Event Registration',
|
||||
'6' => 'Contribution',
|
||||
'7' => 'Membership Signup',
|
||||
'8' => 'Membership Renewal',
|
||||
'9' => 'Tell a Friend',
|
||||
'10' => 'Pledge Acknowledgment',
|
||||
'11' => 'Pledge Reminder',
|
||||
'12' => 'Inbound Email',
|
||||
'13' => 'Open Case',
|
||||
'14' => 'Follow up',
|
||||
'15' => 'Change Case Type',
|
||||
'16' => 'Change Case Status',
|
||||
'17' => 'Membership Renewal Reminder',
|
||||
'18' => 'Change Case Start Date',
|
||||
'19' => 'Bulk Email',
|
||||
'20' => 'Assign Case Role',
|
||||
'21' => 'Remove Case Role',
|
||||
'22' => 'Print/Merge Document',
|
||||
'23' => 'Merge Case',
|
||||
'24' => 'Reassigned Case',
|
||||
'25' => 'Link Cases',
|
||||
'26' => 'Change Case Tags',
|
||||
'27' => 'Add Client To Case',
|
||||
'28' => 'Survey',
|
||||
'29' => 'Canvass',
|
||||
'30' => 'PhoneBank',
|
||||
'31' => 'WalkList',
|
||||
'32' => 'Petition Signature',
|
||||
'33' => 'Change Custom Data',
|
||||
'34' => 'Mass SMS',
|
||||
'35' => 'Change Membership Status',
|
||||
'36' => 'Change Membership Type',
|
||||
'37' => 'Cancel Recurring Contribution',
|
||||
'38' => 'Update Recurring Contribution Billing Details',
|
||||
'39' => 'Update Recurring Contribution',
|
||||
'40' => 'Reminder Sent',
|
||||
'41' => 'Export Accounting Batch',
|
||||
'42' => 'Create Batch',
|
||||
'43' => 'Edit Batch',
|
||||
'44' => 'SMS delivery',
|
||||
'45' => 'Inbound SMS',
|
||||
'46' => 'Payment',
|
||||
'47' => 'Refund',
|
||||
'48' => 'Change Registration',
|
||||
'49' => 'Downloaded Invoice',
|
||||
'50' => 'Emailed Invoice',
|
||||
'51' => 'Contact Merged',
|
||||
'52' => 'Contact Deleted by Merge',
|
||||
'53' => 'Failed Payment',
|
||||
'54' => 'Close Accounting Period',
|
||||
),
|
||||
'deprecated' => 'The ActivityType api is deprecated. Please use the OptionValue api instead.',
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testActivityTypeGet"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTypeTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Address.get API.
|
||||
*
|
||||
* Demonstrates Use of Like.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function address_get_example() {
|
||||
$params = array(
|
||||
'street_address' => array(
|
||||
'LIKE' => '%mb%',
|
||||
),
|
||||
'sequential' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Address', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function address_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '1',
|
||||
'contact_id' => '20',
|
||||
'location_type_id' => '18',
|
||||
'is_primary' => '1',
|
||||
'is_billing' => 0,
|
||||
'street_address' => 'Ambachtstraat 23',
|
||||
'street_number' => '23',
|
||||
'street_name' => 'Ambachtstraat',
|
||||
'city' => 'Brummen',
|
||||
'postal_code' => '6971 BN',
|
||||
'country_id' => '1152',
|
||||
'manual_geo_code' => 0,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetAddressLikeSuccess"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/AddressTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Address.create API.
|
||||
*
|
||||
* Demonstrates Use of address parsing param.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function address_create_example() {
|
||||
$params = array(
|
||||
'street_parsing' => 1,
|
||||
'street_address' => '54A Excelsior Ave. Apt 1C',
|
||||
'location_type_id' => 7,
|
||||
'contact_id' => 4,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Address', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function address_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'contact_id' => '4',
|
||||
'location_type_id' => '7',
|
||||
'is_primary' => '1',
|
||||
'is_billing' => 0,
|
||||
'street_address' => '54A Excelsior Ave. Apt 1C',
|
||||
'street_number' => '54',
|
||||
'street_number_suffix' => 'A',
|
||||
'street_name' => 'Excelsior Ave.',
|
||||
'street_unit' => 'Apt 1C',
|
||||
'manual_geo_code' => 0,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateAddressParsing"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/AddressTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Address.get API.
|
||||
*
|
||||
* Demonstrates Use of sort filter.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function address_get_example() {
|
||||
$params = array(
|
||||
'options' => array(
|
||||
'sort' => 'street_address DESC',
|
||||
'limit' => 2,
|
||||
),
|
||||
'sequential' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Address', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function address_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 2,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '2',
|
||||
'contact_id' => '19',
|
||||
'location_type_id' => '17',
|
||||
'is_primary' => '1',
|
||||
'is_billing' => 0,
|
||||
'street_address' => 'yzy',
|
||||
'street_number' => '23',
|
||||
'street_name' => 'Ambachtstraat',
|
||||
'city' => 'Brummen',
|
||||
'postal_code' => '6971 BN',
|
||||
'country_id' => '1152',
|
||||
'manual_geo_code' => 0,
|
||||
),
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'contact_id' => '19',
|
||||
'location_type_id' => '17',
|
||||
'is_primary' => 0,
|
||||
'is_billing' => 0,
|
||||
'street_address' => 'Ambachtstraat 23',
|
||||
'street_number' => '23',
|
||||
'street_name' => 'Ambachtstraat',
|
||||
'city' => 'Brummen',
|
||||
'postal_code' => '6971 BN',
|
||||
'country_id' => '1152',
|
||||
'manual_geo_code' => 0,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetAddressSort"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/AddressTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
94
sites/all/modules/civicrm/api/v3/examples/Address/Create.php
Normal file
94
sites/all/modules/civicrm/api/v3/examples/Address/Create.php
Normal file
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Address.create API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function address_create_example() {
|
||||
$params = array(
|
||||
'contact_id' => 3,
|
||||
'location_type_id' => 6,
|
||||
'street_name' => 'Ambachtstraat',
|
||||
'street_number' => '23',
|
||||
'street_address' => 'Ambachtstraat 23',
|
||||
'postal_code' => '6971 BN',
|
||||
'country_id' => '1152',
|
||||
'city' => 'Brummen',
|
||||
'is_primary' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Address', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function address_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 2,
|
||||
'values' => array(
|
||||
'2' => array(
|
||||
'id' => '2',
|
||||
'contact_id' => '3',
|
||||
'location_type_id' => '6',
|
||||
'is_primary' => '1',
|
||||
'is_billing' => 0,
|
||||
'street_address' => 'Ambachtstraat 23',
|
||||
'street_number' => '23',
|
||||
'street_name' => 'Ambachtstraat',
|
||||
'city' => 'Brummen',
|
||||
'postal_code' => '6971 BN',
|
||||
'country_id' => '1152',
|
||||
'manual_geo_code' => 0,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateAddress"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/AddressTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
70
sites/all/modules/civicrm/api/v3/examples/Address/Delete.php
Normal file
70
sites/all/modules/civicrm/api/v3/examples/Address/Delete.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Address.delete API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function address_delete_example() {
|
||||
$params = array(
|
||||
'id' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Address', 'delete', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function address_delete_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'values' => 1,
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testDeleteAddress"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/AddressTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
87
sites/all/modules/civicrm/api/v3/examples/Address/Get.php
Normal file
87
sites/all/modules/civicrm/api/v3/examples/Address/Get.php
Normal file
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Address.get API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function address_get_example() {
|
||||
$params = array(
|
||||
'contact_id' => 17,
|
||||
'street_name' => 'Ambachtstraat',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Address', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function address_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'contact_id' => '17',
|
||||
'location_type_id' => '15',
|
||||
'is_primary' => '1',
|
||||
'is_billing' => 0,
|
||||
'street_address' => 'Ambachtstraat 23',
|
||||
'street_number' => '23',
|
||||
'street_name' => 'Ambachtstraat',
|
||||
'city' => 'Brummen',
|
||||
'postal_code' => '6971 BN',
|
||||
'country_id' => '1152',
|
||||
'manual_geo_code' => 0,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetAddress"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/AddressTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Address.getoptions API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function address_getoptions_example() {
|
||||
$params = array(
|
||||
'field' => 'location_type_id',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Address', 'getoptions', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function address_getoptions_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 5,
|
||||
'values' => array(
|
||||
'5' => 'Billing',
|
||||
'1' => 'Home',
|
||||
'3' => 'Main',
|
||||
'4' => 'Other',
|
||||
'2' => 'Work',
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testLocationTypeGet"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ConstantTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
96
sites/all/modules/civicrm/api/v3/examples/Batch/Create.php
Normal file
96
sites/all/modules/civicrm/api/v3/examples/Batch/Create.php
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Batch.create API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function batch_create_example() {
|
||||
$params = array(
|
||||
'name' => 'New_Batch_04',
|
||||
'title' => 'New Batch 04',
|
||||
'description' => 'This is description for New Batch 04',
|
||||
'total' => '400.44',
|
||||
'item_count' => 4,
|
||||
'id' => 3,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Batch', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function batch_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 3,
|
||||
'values' => array(
|
||||
'3' => array(
|
||||
'id' => '3',
|
||||
'name' => 'New_Batch_04',
|
||||
'title' => 'New Batch 04',
|
||||
'description' => 'This is description for New Batch 04',
|
||||
'created_id' => '',
|
||||
'created_date' => '',
|
||||
'modified_id' => '',
|
||||
'modified_date' => '',
|
||||
'saved_search_id' => '',
|
||||
'status_id' => '',
|
||||
'type_id' => '',
|
||||
'mode_id' => '',
|
||||
'total' => '400.44',
|
||||
'item_count' => '4',
|
||||
'payment_instrument_id' => '',
|
||||
'exported_date' => '',
|
||||
'data' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testUpdate"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/BatchTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
70
sites/all/modules/civicrm/api/v3/examples/Batch/Delete.php
Normal file
70
sites/all/modules/civicrm/api/v3/examples/Batch/Delete.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Batch.delete API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function batch_delete_example() {
|
||||
$params = array(
|
||||
'id' => 5,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Batch', 'delete', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function batch_delete_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'values' => 1,
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testBatchDeleteCorrectSyntax"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/BatchTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
79
sites/all/modules/civicrm/api/v3/examples/Batch/Get.php
Normal file
79
sites/all/modules/civicrm/api/v3/examples/Batch/Get.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Batch.get API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function batch_get_example() {
|
||||
$params = array(
|
||||
'id' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Batch', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function batch_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'name' => 'Batch_433397',
|
||||
'title' => 'Batch_433397',
|
||||
'modified_date' => '2012-11-14 16:02:35',
|
||||
'status_id' => '1',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGet"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/BatchTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
96
sites/all/modules/civicrm/api/v3/examples/Batch/Update.php
Normal file
96
sites/all/modules/civicrm/api/v3/examples/Batch/Update.php
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example of using batch update API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function batch_update_example() {
|
||||
$params = array(
|
||||
'name' => 'New_Batch_04',
|
||||
'title' => 'New Batch 04',
|
||||
'description' => 'This is description for New Batch 04',
|
||||
'total' => '400.44',
|
||||
'item_count' => 4,
|
||||
'id' => 3,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('batch', 'update', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'error' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function batch_update_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 3,
|
||||
'values' => array(
|
||||
'3' => array(
|
||||
'id' => '3',
|
||||
'name' => 'New_Batch_04',
|
||||
'title' => 'New Batch 04',
|
||||
'description' => 'This is description for New Batch 04',
|
||||
'created_id' => '',
|
||||
'created_date' => '',
|
||||
'modified_id' => '',
|
||||
'modified_date' => '',
|
||||
'saved_search_id' => '',
|
||||
'status_id' => '',
|
||||
'type_id' => '',
|
||||
'mode_id' => '',
|
||||
'total' => '400.44',
|
||||
'item_count' => '4',
|
||||
'payment_instrument_id' => '',
|
||||
'exported_date' => '',
|
||||
'data' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called
|
||||
* testUpdate
|
||||
* and can be found in
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/BatchTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Campaign.create API.
|
||||
*
|
||||
* Create a campaign - Note use of relative dates here:
|
||||
* @link http://www.php.net/manual/en/datetime.formats.relative.php.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function campaign_create_example() {
|
||||
$params = array(
|
||||
'title' => 'campaign title',
|
||||
'description' => 'Call people, ask for money',
|
||||
'created_date' => 'first sat of July 2008',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Campaign', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function campaign_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'name' => 'campaign_title',
|
||||
'title' => 'campaign title',
|
||||
'description' => 'Call people, ask for money',
|
||||
'start_date' => '',
|
||||
'end_date' => '',
|
||||
'campaign_type_id' => '',
|
||||
'status_id' => '',
|
||||
'external_identifier' => '',
|
||||
'parent_id' => '',
|
||||
'is_active' => '',
|
||||
'created_id' => '',
|
||||
'created_date' => '2013-07-28 08:49:19',
|
||||
'last_modified_id' => '',
|
||||
'last_modified_date' => '',
|
||||
'goal_general' => '',
|
||||
'goal_revenue' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateCampaign"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CampaignTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Campaign.delete API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function campaign_delete_example() {
|
||||
$params = array(
|
||||
'id' => 3,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Campaign', 'delete', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function campaign_delete_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'values' => 1,
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testDeleteCampaign"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CampaignTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
82
sites/all/modules/civicrm/api/v3/examples/Campaign/Get.php
Normal file
82
sites/all/modules/civicrm/api/v3/examples/Campaign/Get.php
Normal file
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Campaign.get API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function campaign_get_example() {
|
||||
$params = array(
|
||||
'title' => 'campaign title',
|
||||
'description' => 'Call people, ask for money',
|
||||
'created_date' => 'first sat of July 2008',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Campaign', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function campaign_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 2,
|
||||
'values' => array(
|
||||
'2' => array(
|
||||
'id' => '2',
|
||||
'name' => 'campaign_title',
|
||||
'title' => 'campaign title',
|
||||
'description' => 'Call people, ask for money',
|
||||
'is_active' => '1',
|
||||
'created_date' => '2013-07-28 08:49:19',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetCampaign"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CampaignTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
84
sites/all/modules/civicrm/api/v3/examples/Case/Create.php
Normal file
84
sites/all/modules/civicrm/api/v3/examples/Case/Create.php
Normal file
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Case.create API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function case_create_example() {
|
||||
$params = array(
|
||||
'subject' => 'Test case',
|
||||
'contact_id' => 17,
|
||||
'case_type' => 'housing_support',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Case', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function case_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 2,
|
||||
'values' => array(
|
||||
'2' => array(
|
||||
'id' => '2',
|
||||
'case_type_id' => '1',
|
||||
'subject' => 'Test case',
|
||||
'start_date' => '2013-07-29 00:00:00',
|
||||
'end_date' => '',
|
||||
'details' => '',
|
||||
'status_id' => '1',
|
||||
'is_deleted' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCaseCreate"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CaseTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the CaseContact.get API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function case_contact_get_example() {
|
||||
$params = array(
|
||||
'contact_id' => 19,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('CaseContact', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function case_contact_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 2,
|
||||
'values' => array(
|
||||
'2' => array(
|
||||
'id' => '2',
|
||||
'case_id' => '2',
|
||||
'contact_id' => '19',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCaseContactGet"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CaseContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
111
sites/all/modules/civicrm/api/v3/examples/Constant/Get.php
Normal file
111
sites/all/modules/civicrm/api/v3/examples/Constant/Get.php
Normal file
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Constant.get API.
|
||||
*
|
||||
* @deprecated
|
||||
* The Constant api is deprecated as of CiviCRM 4.4. Please use the getoptions api action instead.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function constant_get_example() {
|
||||
$params = array(
|
||||
'name' => 'activityType',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Constant', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function constant_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 36,
|
||||
'values' => array(
|
||||
'1' => 'Meeting',
|
||||
'2' => 'Phone Call',
|
||||
'3' => 'Email',
|
||||
'4' => 'Outbound SMS',
|
||||
'5' => 'Event Registration',
|
||||
'6' => 'Contribution',
|
||||
'7' => 'Membership Signup',
|
||||
'8' => 'Membership Renewal',
|
||||
'9' => 'Tell a Friend',
|
||||
'10' => 'Pledge Acknowledgment',
|
||||
'11' => 'Pledge Reminder',
|
||||
'12' => 'Inbound Email',
|
||||
'17' => 'Membership Renewal Reminder',
|
||||
'19' => 'Bulk Email',
|
||||
'22' => 'Print/Merge Document',
|
||||
'34' => 'Mass SMS',
|
||||
'35' => 'Change Membership Status',
|
||||
'36' => 'Change Membership Type',
|
||||
'37' => 'Cancel Recurring Contribution',
|
||||
'38' => 'Update Recurring Contribution Billing Details',
|
||||
'39' => 'Update Recurring Contribution',
|
||||
'40' => 'Reminder Sent',
|
||||
'41' => 'Export Accounting Batch',
|
||||
'42' => 'Create Batch',
|
||||
'43' => 'Edit Batch',
|
||||
'44' => 'SMS delivery',
|
||||
'45' => 'Inbound SMS',
|
||||
'46' => 'Payment',
|
||||
'47' => 'Refund',
|
||||
'48' => 'Change Registration',
|
||||
'49' => 'Downloaded Invoice',
|
||||
'50' => 'Emailed Invoice',
|
||||
'51' => 'Contact Merged',
|
||||
'52' => 'Contact Deleted by Merge',
|
||||
'53' => 'Failed Payment',
|
||||
'54' => 'Close Accounting Period',
|
||||
),
|
||||
'deprecated' => 'The Constant api is deprecated as of CiviCRM 4.4. Please use the getoptions api action instead.',
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testActivityType"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ConstantTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,235 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.get API.
|
||||
*
|
||||
* This demonstrates the usage of chained api functions.
|
||||
* In this case no notes or custom fields have been created.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_example() {
|
||||
$params = array(
|
||||
'id' => 3,
|
||||
'api.website.get' => array(),
|
||||
'api.Contribution.get' => array(
|
||||
'total_amount' => '120.00',
|
||||
),
|
||||
'api.CustomValue.get' => 1,
|
||||
'api.Note.get' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 3,
|
||||
'values' => array(
|
||||
'3' => array(
|
||||
'contact_id' => '3',
|
||||
'contact_type' => 'Individual',
|
||||
'contact_sub_type' => '',
|
||||
'sort_name' => 'xyz3, abc3',
|
||||
'display_name' => 'abc3 xyz3',
|
||||
'do_not_email' => 0,
|
||||
'do_not_phone' => 0,
|
||||
'do_not_mail' => 0,
|
||||
'do_not_sms' => 0,
|
||||
'do_not_trade' => 0,
|
||||
'is_opt_out' => 0,
|
||||
'legal_identifier' => '',
|
||||
'external_identifier' => '',
|
||||
'nick_name' => '',
|
||||
'legal_name' => '',
|
||||
'image_URL' => '',
|
||||
'preferred_communication_method' => '',
|
||||
'preferred_language' => 'en_US',
|
||||
'preferred_mail_format' => 'Both',
|
||||
'first_name' => 'abc3',
|
||||
'middle_name' => '',
|
||||
'last_name' => 'xyz3',
|
||||
'prefix_id' => '',
|
||||
'suffix_id' => '',
|
||||
'formal_title' => '',
|
||||
'communication_style_id' => '',
|
||||
'job_title' => '',
|
||||
'gender_id' => '',
|
||||
'birth_date' => '',
|
||||
'is_deceased' => 0,
|
||||
'deceased_date' => '',
|
||||
'household_name' => '',
|
||||
'organization_name' => '',
|
||||
'sic_code' => '',
|
||||
'contact_is_deleted' => 0,
|
||||
'current_employer' => '',
|
||||
'address_id' => '',
|
||||
'street_address' => '',
|
||||
'supplemental_address_1' => '',
|
||||
'supplemental_address_2' => '',
|
||||
'supplemental_address_3' => '',
|
||||
'city' => '',
|
||||
'postal_code_suffix' => '',
|
||||
'postal_code' => '',
|
||||
'geo_code_1' => '',
|
||||
'geo_code_2' => '',
|
||||
'state_province_id' => '',
|
||||
'country_id' => '',
|
||||
'phone_id' => '',
|
||||
'phone_type_id' => '',
|
||||
'phone' => '',
|
||||
'email_id' => '1',
|
||||
'email' => 'man3@yahoo.com',
|
||||
'on_hold' => 0,
|
||||
'im_id' => '',
|
||||
'provider_id' => '',
|
||||
'im' => '',
|
||||
'worldregion_id' => '',
|
||||
'world_region' => '',
|
||||
'languages' => 'English (United States)',
|
||||
'individual_prefix' => '',
|
||||
'individual_suffix' => '',
|
||||
'communication_style' => '',
|
||||
'gender' => '',
|
||||
'state_province_name' => '',
|
||||
'state_province' => '',
|
||||
'country' => '',
|
||||
'id' => '3',
|
||||
'api.website.get' => array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '1',
|
||||
'contact_id' => '3',
|
||||
'url' => 'http://civicrm.org',
|
||||
),
|
||||
),
|
||||
),
|
||||
'api.Contribution.get' => array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 2,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'contact_id' => '3',
|
||||
'contact_type' => 'Individual',
|
||||
'contact_sub_type' => '',
|
||||
'sort_name' => 'xyz3, abc3',
|
||||
'display_name' => 'abc3 xyz3',
|
||||
'contribution_id' => '2',
|
||||
'currency' => 'USD',
|
||||
'payment_instrument' => 'Credit Card',
|
||||
'payment_instrument_id' => '1',
|
||||
'receive_date' => '2011-01-01 00:00:00',
|
||||
'non_deductible_amount' => '10.00',
|
||||
'total_amount' => '120.00',
|
||||
'fee_amount' => '50.00',
|
||||
'net_amount' => '90.00',
|
||||
'trxn_id' => '12335',
|
||||
'invoice_id' => '67830',
|
||||
'cancel_date' => '',
|
||||
'cancel_reason' => '',
|
||||
'receipt_date' => '',
|
||||
'thankyou_date' => '',
|
||||
'contribution_source' => 'SSF',
|
||||
'amount_level' => '',
|
||||
'contribution_recur_id' => '',
|
||||
'is_test' => 0,
|
||||
'is_pay_later' => 0,
|
||||
'contribution_status' => 'Completed',
|
||||
'contribution_status_id' => '1',
|
||||
'contribution_check_number' => '',
|
||||
'contribution_campaign_id' => '',
|
||||
'financial_type_id' => '1',
|
||||
'financial_type' => 'Donation',
|
||||
'product_id' => '',
|
||||
'product_name' => '',
|
||||
'sku' => '',
|
||||
'contribution_product_id' => '',
|
||||
'product_option' => '',
|
||||
'fulfilled_date' => '',
|
||||
'contribution_start_date' => '',
|
||||
'contribution_end_date' => '',
|
||||
'financial_account_id' => '1',
|
||||
'accounting_code' => '4200',
|
||||
'campaign_id' => '',
|
||||
'contribution_campaign_title' => '',
|
||||
'contribution_note' => '',
|
||||
'contribution_batch' => '',
|
||||
'check_number' => '',
|
||||
'instrument_id' => '1',
|
||||
'id' => '2',
|
||||
'contribution_type_id' => '1',
|
||||
),
|
||||
),
|
||||
),
|
||||
'api.CustomValue.get' => array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 0,
|
||||
'values' => array(),
|
||||
),
|
||||
'api.Note.get' => array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 0,
|
||||
'values' => array(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetIndividualWithChainedArrays"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.get API.
|
||||
*
|
||||
* This demonstrates the usage of chained api functions.
|
||||
* In this case no notes or custom fields have been created.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_example() {
|
||||
$params = array(
|
||||
'id' => 3,
|
||||
'api.website.getValue' => array(
|
||||
'return' => 'url',
|
||||
),
|
||||
'api.Contribution.getCount' => array(),
|
||||
'api.CustomValue.get' => 1,
|
||||
'api.Note.get' => 1,
|
||||
'api.Membership.getCount' => array(),
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 3,
|
||||
'values' => array(
|
||||
'3' => array(
|
||||
'contact_id' => '3',
|
||||
'contact_type' => 'Individual',
|
||||
'contact_sub_type' => '',
|
||||
'sort_name' => 'xyz3, abc3',
|
||||
'display_name' => 'abc3 xyz3',
|
||||
'do_not_email' => 0,
|
||||
'do_not_phone' => 0,
|
||||
'do_not_mail' => 0,
|
||||
'do_not_sms' => 0,
|
||||
'do_not_trade' => 0,
|
||||
'is_opt_out' => 0,
|
||||
'legal_identifier' => '',
|
||||
'external_identifier' => '',
|
||||
'nick_name' => '',
|
||||
'legal_name' => '',
|
||||
'image_URL' => '',
|
||||
'preferred_communication_method' => '',
|
||||
'preferred_language' => 'en_US',
|
||||
'preferred_mail_format' => 'Both',
|
||||
'first_name' => 'abc3',
|
||||
'middle_name' => '',
|
||||
'last_name' => 'xyz3',
|
||||
'prefix_id' => '',
|
||||
'suffix_id' => '',
|
||||
'formal_title' => '',
|
||||
'communication_style_id' => '',
|
||||
'job_title' => '',
|
||||
'gender_id' => '',
|
||||
'birth_date' => '',
|
||||
'is_deceased' => 0,
|
||||
'deceased_date' => '',
|
||||
'household_name' => '',
|
||||
'organization_name' => '',
|
||||
'sic_code' => '',
|
||||
'contact_is_deleted' => 0,
|
||||
'current_employer' => '',
|
||||
'address_id' => '',
|
||||
'street_address' => '',
|
||||
'supplemental_address_1' => '',
|
||||
'supplemental_address_2' => '',
|
||||
'supplemental_address_3' => '',
|
||||
'city' => '',
|
||||
'postal_code_suffix' => '',
|
||||
'postal_code' => '',
|
||||
'geo_code_1' => '',
|
||||
'geo_code_2' => '',
|
||||
'state_province_id' => '',
|
||||
'country_id' => '',
|
||||
'phone_id' => '',
|
||||
'phone_type_id' => '',
|
||||
'phone' => '',
|
||||
'email_id' => '1',
|
||||
'email' => 'man3@yahoo.com',
|
||||
'on_hold' => 0,
|
||||
'im_id' => '',
|
||||
'provider_id' => '',
|
||||
'im' => '',
|
||||
'worldregion_id' => '',
|
||||
'world_region' => '',
|
||||
'languages' => 'English (United States)',
|
||||
'individual_prefix' => '',
|
||||
'individual_suffix' => '',
|
||||
'communication_style' => '',
|
||||
'gender' => '',
|
||||
'state_province_name' => '',
|
||||
'state_province' => '',
|
||||
'country' => '',
|
||||
'id' => '3',
|
||||
'api.website.getValue' => 'http://civicrm.org',
|
||||
'api.Contribution.getCount' => 2,
|
||||
'api.CustomValue.get' => array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 0,
|
||||
'values' => array(),
|
||||
),
|
||||
'api.Note.get' => array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 0,
|
||||
'values' => array(),
|
||||
),
|
||||
'api.Membership.getCount' => 0,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetIndividualWithChainedArraysFormats"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,209 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.get API.
|
||||
*
|
||||
* This demonstrates the usage of chained api functions with multiple custom fields.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_example() {
|
||||
$params = array(
|
||||
'id' => 3,
|
||||
'api.website.getValue' => array(
|
||||
'return' => 'url',
|
||||
),
|
||||
'api.Contribution.getCount' => array(),
|
||||
'api.CustomValue.get' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 3,
|
||||
'values' => array(
|
||||
'3' => array(
|
||||
'contact_id' => '3',
|
||||
'contact_type' => 'Individual',
|
||||
'contact_sub_type' => '',
|
||||
'sort_name' => 'xyz3, abc3',
|
||||
'display_name' => 'abc3 xyz3',
|
||||
'do_not_email' => 0,
|
||||
'do_not_phone' => 0,
|
||||
'do_not_mail' => 0,
|
||||
'do_not_sms' => 0,
|
||||
'do_not_trade' => 0,
|
||||
'is_opt_out' => 0,
|
||||
'legal_identifier' => '',
|
||||
'external_identifier' => '',
|
||||
'nick_name' => '',
|
||||
'legal_name' => '',
|
||||
'image_URL' => '',
|
||||
'preferred_communication_method' => '',
|
||||
'preferred_language' => 'en_US',
|
||||
'preferred_mail_format' => 'Both',
|
||||
'first_name' => 'abc3',
|
||||
'middle_name' => '',
|
||||
'last_name' => 'xyz3',
|
||||
'prefix_id' => '',
|
||||
'suffix_id' => '',
|
||||
'formal_title' => '',
|
||||
'communication_style_id' => '',
|
||||
'job_title' => '',
|
||||
'gender_id' => '',
|
||||
'birth_date' => '',
|
||||
'is_deceased' => 0,
|
||||
'deceased_date' => '',
|
||||
'household_name' => '',
|
||||
'organization_name' => '',
|
||||
'sic_code' => '',
|
||||
'contact_is_deleted' => 0,
|
||||
'current_employer' => '',
|
||||
'address_id' => '',
|
||||
'street_address' => '',
|
||||
'supplemental_address_1' => '',
|
||||
'supplemental_address_2' => '',
|
||||
'supplemental_address_3' => '',
|
||||
'city' => '',
|
||||
'postal_code_suffix' => '',
|
||||
'postal_code' => '',
|
||||
'geo_code_1' => '',
|
||||
'geo_code_2' => '',
|
||||
'state_province_id' => '',
|
||||
'country_id' => '',
|
||||
'phone_id' => '',
|
||||
'phone_type_id' => '',
|
||||
'phone' => '',
|
||||
'email_id' => '1',
|
||||
'email' => 'man3@yahoo.com',
|
||||
'on_hold' => 0,
|
||||
'im_id' => '',
|
||||
'provider_id' => '',
|
||||
'im' => '',
|
||||
'worldregion_id' => '',
|
||||
'world_region' => '',
|
||||
'languages' => 'English (United States)',
|
||||
'individual_prefix' => '',
|
||||
'individual_suffix' => '',
|
||||
'communication_style' => '',
|
||||
'gender' => '',
|
||||
'state_province_name' => '',
|
||||
'state_province' => '',
|
||||
'country' => '',
|
||||
'id' => '3',
|
||||
'api.website.getValue' => 'http://civicrm.org',
|
||||
'api.Contribution.getCount' => 2,
|
||||
'api.CustomValue.get' => array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 7,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'entity_id' => '3',
|
||||
'entity_table' => 'Contact',
|
||||
'latest' => 'value 4',
|
||||
'id' => '1',
|
||||
),
|
||||
'1' => array(
|
||||
'entity_id' => '3',
|
||||
'entity_table' => 'Contact',
|
||||
'latest' => 'value 3',
|
||||
'id' => '2',
|
||||
'1' => 'value 2',
|
||||
'2' => 'value 3',
|
||||
),
|
||||
'2' => array(
|
||||
'entity_id' => '3',
|
||||
'entity_table' => 'Contact',
|
||||
'latest' => '',
|
||||
'id' => '3',
|
||||
'1' => 'warm beer',
|
||||
'2' => '',
|
||||
),
|
||||
'3' => array(
|
||||
'entity_id' => '3',
|
||||
'entity_table' => 'Contact',
|
||||
'latest' => '',
|
||||
'id' => '4',
|
||||
'1' => '',
|
||||
'2' => '',
|
||||
),
|
||||
'4' => array(
|
||||
'entity_id' => '3',
|
||||
'entity_table' => 'Contact',
|
||||
'latest' => 'defaultValue',
|
||||
'id' => '5',
|
||||
'1' => 'defaultValue',
|
||||
),
|
||||
'5' => array(
|
||||
'entity_id' => '3',
|
||||
'entity_table' => 'Contact',
|
||||
'latest' => 'vegemite',
|
||||
'id' => '6',
|
||||
'1' => 'vegemite',
|
||||
),
|
||||
'6' => array(
|
||||
'entity_id' => '3',
|
||||
'entity_table' => 'Contact',
|
||||
'latest' => '',
|
||||
'id' => '7',
|
||||
'1' => '',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetIndividualWithChainedArraysAndMultipleCustom"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.create API.
|
||||
*
|
||||
* This demonstrates the usage of chained api functions. Specifically it has one 'parent function' &
|
||||
* 2 child functions - one receives values from the parent (Contact) and the other child (Tag).
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_create_example() {
|
||||
$params = array(
|
||||
'display_name' => 'batman',
|
||||
'contact_type' => 'Individual',
|
||||
'api.tag.create' => array(
|
||||
'name' => '$value.id',
|
||||
'description' => '$value.display_name',
|
||||
'format.only_id' => 1,
|
||||
),
|
||||
'api.entity_tag.create' => array(
|
||||
'tag_id' => '$value.api.tag.create',
|
||||
),
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 3,
|
||||
'values' => array(
|
||||
'3' => array(
|
||||
'id' => '3',
|
||||
'contact_type' => 'Individual',
|
||||
'contact_sub_type' => '',
|
||||
'do_not_email' => 0,
|
||||
'do_not_phone' => 0,
|
||||
'do_not_mail' => 0,
|
||||
'do_not_sms' => 0,
|
||||
'do_not_trade' => 0,
|
||||
'is_opt_out' => 0,
|
||||
'legal_identifier' => '',
|
||||
'external_identifier' => '',
|
||||
'sort_name' => 'batman',
|
||||
'display_name' => 'batman',
|
||||
'nick_name' => '',
|
||||
'legal_name' => '',
|
||||
'image_URL' => '',
|
||||
'preferred_communication_method' => '',
|
||||
'preferred_language' => 'en_US',
|
||||
'preferred_mail_format' => 'Both',
|
||||
'hash' => '67eac7789eaee00',
|
||||
'api_key' => '',
|
||||
'first_name' => '',
|
||||
'middle_name' => '',
|
||||
'last_name' => '',
|
||||
'prefix_id' => '',
|
||||
'suffix_id' => '',
|
||||
'formal_title' => '',
|
||||
'communication_style_id' => '',
|
||||
'email_greeting_id' => '1',
|
||||
'email_greeting_custom' => '',
|
||||
'email_greeting_display' => '',
|
||||
'postal_greeting_id' => '1',
|
||||
'postal_greeting_custom' => '',
|
||||
'postal_greeting_display' => '',
|
||||
'addressee_id' => '1',
|
||||
'addressee_custom' => '',
|
||||
'addressee_display' => '',
|
||||
'job_title' => '',
|
||||
'gender_id' => '',
|
||||
'birth_date' => '',
|
||||
'is_deceased' => 0,
|
||||
'deceased_date' => '',
|
||||
'household_name' => '',
|
||||
'primary_contact_id' => '',
|
||||
'organization_name' => '',
|
||||
'sic_code' => '',
|
||||
'user_unique_id' => '',
|
||||
'created_date' => '2013-07-28 08:49:19',
|
||||
'modified_date' => '2012-11-14 16:02:35',
|
||||
'api.tag.create' => 6,
|
||||
'api.entity_tag.create' => array(
|
||||
'is_error' => 0,
|
||||
'not_added' => 1,
|
||||
'added' => 1,
|
||||
'total_count' => 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testChainingValuesCreate"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,215 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.create API.
|
||||
*
|
||||
* This demonstrates the syntax to create 2 chained entities.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_create_example() {
|
||||
$params = array(
|
||||
'first_name' => 'abc3',
|
||||
'last_name' => 'xyz3',
|
||||
'contact_type' => 'Individual',
|
||||
'email' => 'man3@yahoo.com',
|
||||
'api.contribution.create' => array(
|
||||
'receive_date' => '2010-01-01',
|
||||
'total_amount' => '100',
|
||||
'financial_type_id' => 1,
|
||||
'payment_instrument_id' => 1,
|
||||
'non_deductible_amount' => '10',
|
||||
'fee_amount' => '50',
|
||||
'net_amount' => '90',
|
||||
'trxn_id' => 15345,
|
||||
'invoice_id' => 67990,
|
||||
'source' => 'SSF',
|
||||
'contribution_status_id' => 1,
|
||||
),
|
||||
'api.website.create' => array(
|
||||
'url' => 'http://civicrm.org',
|
||||
),
|
||||
'api.website.create.2' => array(
|
||||
'url' => 'http://chained.org',
|
||||
),
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 3,
|
||||
'values' => array(
|
||||
'3' => array(
|
||||
'id' => '3',
|
||||
'contact_type' => 'Individual',
|
||||
'contact_sub_type' => '',
|
||||
'do_not_email' => 0,
|
||||
'do_not_phone' => 0,
|
||||
'do_not_mail' => 0,
|
||||
'do_not_sms' => 0,
|
||||
'do_not_trade' => 0,
|
||||
'is_opt_out' => 0,
|
||||
'legal_identifier' => '',
|
||||
'external_identifier' => '',
|
||||
'sort_name' => 'xyz3, abc3',
|
||||
'display_name' => 'abc3 xyz3',
|
||||
'nick_name' => '',
|
||||
'legal_name' => '',
|
||||
'image_URL' => '',
|
||||
'preferred_communication_method' => '',
|
||||
'preferred_language' => 'en_US',
|
||||
'preferred_mail_format' => 'Both',
|
||||
'hash' => '67eac7789eaee00',
|
||||
'api_key' => '',
|
||||
'first_name' => 'abc3',
|
||||
'middle_name' => '',
|
||||
'last_name' => 'xyz3',
|
||||
'prefix_id' => '',
|
||||
'suffix_id' => '',
|
||||
'formal_title' => '',
|
||||
'communication_style_id' => '',
|
||||
'email_greeting_id' => '1',
|
||||
'email_greeting_custom' => '',
|
||||
'email_greeting_display' => '',
|
||||
'postal_greeting_id' => '1',
|
||||
'postal_greeting_custom' => '',
|
||||
'postal_greeting_display' => '',
|
||||
'addressee_id' => '1',
|
||||
'addressee_custom' => '',
|
||||
'addressee_display' => '',
|
||||
'job_title' => '',
|
||||
'gender_id' => '',
|
||||
'birth_date' => '',
|
||||
'is_deceased' => 0,
|
||||
'deceased_date' => '',
|
||||
'household_name' => '',
|
||||
'primary_contact_id' => '',
|
||||
'organization_name' => '',
|
||||
'sic_code' => '',
|
||||
'user_unique_id' => '',
|
||||
'created_date' => '2013-07-28 08:49:19',
|
||||
'modified_date' => '2012-11-14 16:02:35',
|
||||
'api.contribution.create' => array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '1',
|
||||
'contact_id' => '3',
|
||||
'financial_type_id' => '1',
|
||||
'contribution_page_id' => '',
|
||||
'payment_instrument_id' => '1',
|
||||
'receive_date' => '20100101000000',
|
||||
'non_deductible_amount' => '10',
|
||||
'total_amount' => '100',
|
||||
'fee_amount' => '50',
|
||||
'net_amount' => '90',
|
||||
'trxn_id' => '15345',
|
||||
'invoice_id' => '67990',
|
||||
'currency' => 'USD',
|
||||
'cancel_date' => '',
|
||||
'cancel_reason' => '',
|
||||
'receipt_date' => '',
|
||||
'thankyou_date' => '',
|
||||
'source' => 'SSF',
|
||||
'amount_level' => '',
|
||||
'contribution_recur_id' => '',
|
||||
'is_test' => '',
|
||||
'is_pay_later' => '',
|
||||
'contribution_status_id' => '1',
|
||||
'address_id' => '',
|
||||
'check_number' => '',
|
||||
'campaign_id' => '',
|
||||
'creditnote_id' => '',
|
||||
'tax_amount' => '',
|
||||
'revenue_recognition_date' => '',
|
||||
'contribution_type_id' => '1',
|
||||
),
|
||||
),
|
||||
),
|
||||
'api.website.create' => array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '1',
|
||||
'contact_id' => '3',
|
||||
'url' => 'http://civicrm.org',
|
||||
'website_type_id' => '',
|
||||
),
|
||||
),
|
||||
),
|
||||
'api.website.create.2' => array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 2,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '2',
|
||||
'contact_id' => '3',
|
||||
'url' => 'http://chained.org',
|
||||
'website_type_id' => '',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateIndividualWithContributionDottedSyntax"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,220 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.create API.
|
||||
*
|
||||
* Demonstrates creating two websites as an array.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_create_example() {
|
||||
$params = array(
|
||||
'first_name' => 'abc3',
|
||||
'last_name' => 'xyz3',
|
||||
'contact_type' => 'Individual',
|
||||
'email' => 'man3@yahoo.com',
|
||||
'api.contribution.create' => array(
|
||||
'receive_date' => '2010-01-01',
|
||||
'total_amount' => '100',
|
||||
'financial_type_id' => 1,
|
||||
'payment_instrument_id' => 1,
|
||||
'non_deductible_amount' => '10',
|
||||
'fee_amount' => '50',
|
||||
'net_amount' => '90',
|
||||
'trxn_id' => 12345,
|
||||
'invoice_id' => 67890,
|
||||
'source' => 'SSF',
|
||||
'contribution_status_id' => 1,
|
||||
),
|
||||
'api.website.create' => array(
|
||||
'0' => array(
|
||||
'url' => 'http://civicrm.org',
|
||||
),
|
||||
'1' => array(
|
||||
'url' => 'http://chained.org',
|
||||
'website_type_id' => 2,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 3,
|
||||
'values' => array(
|
||||
'3' => array(
|
||||
'id' => '3',
|
||||
'contact_type' => 'Individual',
|
||||
'contact_sub_type' => '',
|
||||
'do_not_email' => 0,
|
||||
'do_not_phone' => 0,
|
||||
'do_not_mail' => 0,
|
||||
'do_not_sms' => 0,
|
||||
'do_not_trade' => 0,
|
||||
'is_opt_out' => 0,
|
||||
'legal_identifier' => '',
|
||||
'external_identifier' => '',
|
||||
'sort_name' => 'xyz3, abc3',
|
||||
'display_name' => 'abc3 xyz3',
|
||||
'nick_name' => '',
|
||||
'legal_name' => '',
|
||||
'image_URL' => '',
|
||||
'preferred_communication_method' => '',
|
||||
'preferred_language' => 'en_US',
|
||||
'preferred_mail_format' => 'Both',
|
||||
'hash' => '67eac7789eaee00',
|
||||
'api_key' => '',
|
||||
'first_name' => 'abc3',
|
||||
'middle_name' => '',
|
||||
'last_name' => 'xyz3',
|
||||
'prefix_id' => '',
|
||||
'suffix_id' => '',
|
||||
'formal_title' => '',
|
||||
'communication_style_id' => '',
|
||||
'email_greeting_id' => '1',
|
||||
'email_greeting_custom' => '',
|
||||
'email_greeting_display' => '',
|
||||
'postal_greeting_id' => '1',
|
||||
'postal_greeting_custom' => '',
|
||||
'postal_greeting_display' => '',
|
||||
'addressee_id' => '1',
|
||||
'addressee_custom' => '',
|
||||
'addressee_display' => '',
|
||||
'job_title' => '',
|
||||
'gender_id' => '',
|
||||
'birth_date' => '',
|
||||
'is_deceased' => 0,
|
||||
'deceased_date' => '',
|
||||
'household_name' => '',
|
||||
'primary_contact_id' => '',
|
||||
'organization_name' => '',
|
||||
'sic_code' => '',
|
||||
'user_unique_id' => '',
|
||||
'created_date' => '2013-07-28 08:49:19',
|
||||
'modified_date' => '2012-11-14 16:02:35',
|
||||
'api.contribution.create' => array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '1',
|
||||
'contact_id' => '3',
|
||||
'financial_type_id' => '1',
|
||||
'contribution_page_id' => '',
|
||||
'payment_instrument_id' => '1',
|
||||
'receive_date' => '20100101000000',
|
||||
'non_deductible_amount' => '10',
|
||||
'total_amount' => '100',
|
||||
'fee_amount' => '50',
|
||||
'net_amount' => '90',
|
||||
'trxn_id' => '12345',
|
||||
'invoice_id' => '67890',
|
||||
'currency' => 'USD',
|
||||
'cancel_date' => '',
|
||||
'cancel_reason' => '',
|
||||
'receipt_date' => '',
|
||||
'thankyou_date' => '',
|
||||
'source' => 'SSF',
|
||||
'amount_level' => '',
|
||||
'contribution_recur_id' => '',
|
||||
'is_test' => '',
|
||||
'is_pay_later' => '',
|
||||
'contribution_status_id' => '1',
|
||||
'address_id' => '',
|
||||
'check_number' => '',
|
||||
'campaign_id' => '',
|
||||
'creditnote_id' => '',
|
||||
'tax_amount' => '',
|
||||
'revenue_recognition_date' => '',
|
||||
'contribution_type_id' => '1',
|
||||
),
|
||||
),
|
||||
),
|
||||
'api.website.create' => array(
|
||||
'0' => array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '1',
|
||||
'contact_id' => '3',
|
||||
'url' => 'http://civicrm.org',
|
||||
'website_type_id' => '',
|
||||
),
|
||||
),
|
||||
),
|
||||
'1' => array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 2,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '2',
|
||||
'contact_id' => '3',
|
||||
'url' => 'http://chained.org',
|
||||
'website_type_id' => '2',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateIndividualWithContributionChainedArrays"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.get API.
|
||||
*
|
||||
* Get contact id of the current logged in user
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_example() {
|
||||
$params = array(
|
||||
'id' => 'user_contact_id',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 3,
|
||||
'values' => array(
|
||||
'3' => array(
|
||||
'contact_id' => '3',
|
||||
'contact_type' => 'Individual',
|
||||
'contact_sub_type' => '',
|
||||
'sort_name' => 'User 412074113, Logged In',
|
||||
'display_name' => 'Mr. Logged In User 412074113 II',
|
||||
'do_not_email' => 0,
|
||||
'do_not_phone' => 0,
|
||||
'do_not_mail' => 0,
|
||||
'do_not_sms' => 0,
|
||||
'do_not_trade' => 0,
|
||||
'is_opt_out' => 0,
|
||||
'legal_identifier' => '',
|
||||
'external_identifier' => '',
|
||||
'nick_name' => '',
|
||||
'legal_name' => '',
|
||||
'image_URL' => '',
|
||||
'preferred_communication_method' => '',
|
||||
'preferred_language' => 'en_US',
|
||||
'preferred_mail_format' => 'Both',
|
||||
'first_name' => 'Logged In',
|
||||
'middle_name' => 'J.',
|
||||
'last_name' => 'User 412074113',
|
||||
'prefix_id' => '3',
|
||||
'suffix_id' => '3',
|
||||
'formal_title' => '',
|
||||
'communication_style_id' => '',
|
||||
'job_title' => '',
|
||||
'gender_id' => '',
|
||||
'birth_date' => '',
|
||||
'is_deceased' => 0,
|
||||
'deceased_date' => '',
|
||||
'household_name' => '',
|
||||
'organization_name' => '',
|
||||
'sic_code' => '',
|
||||
'contact_is_deleted' => 0,
|
||||
'current_employer' => '',
|
||||
'address_id' => '',
|
||||
'street_address' => '',
|
||||
'supplemental_address_1' => '',
|
||||
'supplemental_address_2' => '',
|
||||
'city' => '',
|
||||
'postal_code_suffix' => '',
|
||||
'postal_code' => '',
|
||||
'geo_code_1' => '',
|
||||
'geo_code_2' => '',
|
||||
'state_province_id' => '',
|
||||
'country_id' => '',
|
||||
'phone_id' => '',
|
||||
'phone_type_id' => '',
|
||||
'phone' => '',
|
||||
'email_id' => '1',
|
||||
'email' => 'anthony_anderson@civicrm.org',
|
||||
'on_hold' => 0,
|
||||
'im_id' => '',
|
||||
'provider_id' => '',
|
||||
'im' => '',
|
||||
'worldregion_id' => '',
|
||||
'world_region' => '',
|
||||
'languages' => 'English (United States)',
|
||||
'individual_prefix' => 'Mr.',
|
||||
'individual_suffix' => 'II',
|
||||
'communication_style' => '',
|
||||
'gender' => '',
|
||||
'state_province_name' => '',
|
||||
'state_province' => '',
|
||||
'country' => '',
|
||||
'id' => '3',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testLoggedInUserAPISupportToken"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
128
sites/all/modules/civicrm/api/v3/examples/Contact/Create.php
Normal file
128
sites/all/modules/civicrm/api/v3/examples/Contact/Create.php
Normal file
|
@ -0,0 +1,128 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.create API.
|
||||
*
|
||||
* This demonstrates setting a custom field through the API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_create_example() {
|
||||
$params = array(
|
||||
'first_name' => 'abc1',
|
||||
'contact_type' => 'Individual',
|
||||
'last_name' => 'xyz1',
|
||||
'custom_1' => 'custom string',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 3,
|
||||
'values' => array(
|
||||
'3' => array(
|
||||
'id' => '3',
|
||||
'contact_type' => 'Individual',
|
||||
'contact_sub_type' => '',
|
||||
'do_not_email' => 0,
|
||||
'do_not_phone' => 0,
|
||||
'do_not_mail' => 0,
|
||||
'do_not_sms' => 0,
|
||||
'do_not_trade' => 0,
|
||||
'is_opt_out' => 0,
|
||||
'legal_identifier' => '',
|
||||
'external_identifier' => '',
|
||||
'sort_name' => 'xyz1, abc1',
|
||||
'display_name' => 'abc1 xyz1',
|
||||
'nick_name' => '',
|
||||
'legal_name' => '',
|
||||
'image_URL' => '',
|
||||
'preferred_communication_method' => '',
|
||||
'preferred_language' => 'en_US',
|
||||
'preferred_mail_format' => 'Both',
|
||||
'hash' => '67eac7789eaee00',
|
||||
'api_key' => '',
|
||||
'first_name' => 'abc1',
|
||||
'middle_name' => '',
|
||||
'last_name' => 'xyz1',
|
||||
'prefix_id' => '',
|
||||
'suffix_id' => '',
|
||||
'formal_title' => '',
|
||||
'communication_style_id' => '',
|
||||
'email_greeting_id' => '1',
|
||||
'email_greeting_custom' => '',
|
||||
'email_greeting_display' => '',
|
||||
'postal_greeting_id' => '1',
|
||||
'postal_greeting_custom' => '',
|
||||
'postal_greeting_display' => '',
|
||||
'addressee_id' => '1',
|
||||
'addressee_custom' => '',
|
||||
'addressee_display' => '',
|
||||
'job_title' => '',
|
||||
'gender_id' => '',
|
||||
'birth_date' => '',
|
||||
'is_deceased' => 0,
|
||||
'deceased_date' => '',
|
||||
'household_name' => '',
|
||||
'primary_contact_id' => '',
|
||||
'organization_name' => '',
|
||||
'sic_code' => '',
|
||||
'user_unique_id' => '',
|
||||
'created_date' => '2013-07-28 08:49:19',
|
||||
'modified_date' => '2012-11-14 16:02:35',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateWithCustom"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,157 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.create API.
|
||||
*
|
||||
* Single function to create contact with partipation & contribution.
|
||||
* Note that in the case of 'contribution' the 'create' is implied (api.contribution.create)
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_create_example() {
|
||||
$params = array(
|
||||
'contact_type' => 'Individual',
|
||||
'display_name' => 'dlobo',
|
||||
'api.participant' => array(
|
||||
'event_id' => 42,
|
||||
'status_id' => 1,
|
||||
'role_id' => 1,
|
||||
'format.only_id' => 1,
|
||||
),
|
||||
'api.contribution.create' => array(
|
||||
'financial_type_id' => 1,
|
||||
'total_amount' => 100,
|
||||
'format.only_id' => 1,
|
||||
),
|
||||
'api.participant_payment.create' => array(
|
||||
'contribution_id' => '$value.api.contribution.create',
|
||||
'participant_id' => '$value.api.participant',
|
||||
),
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 5,
|
||||
'values' => array(
|
||||
'5' => array(
|
||||
'id' => '5',
|
||||
'contact_type' => 'Individual',
|
||||
'contact_sub_type' => '',
|
||||
'do_not_email' => 0,
|
||||
'do_not_phone' => 0,
|
||||
'do_not_mail' => 0,
|
||||
'do_not_sms' => 0,
|
||||
'do_not_trade' => 0,
|
||||
'is_opt_out' => 0,
|
||||
'legal_identifier' => '',
|
||||
'external_identifier' => '',
|
||||
'sort_name' => 'dlobo',
|
||||
'display_name' => 'dlobo',
|
||||
'nick_name' => '',
|
||||
'legal_name' => '',
|
||||
'image_URL' => '',
|
||||
'preferred_communication_method' => '',
|
||||
'preferred_language' => 'en_US',
|
||||
'preferred_mail_format' => 'Both',
|
||||
'hash' => '67eac7789eaee00',
|
||||
'api_key' => '',
|
||||
'first_name' => '',
|
||||
'middle_name' => '',
|
||||
'last_name' => '',
|
||||
'prefix_id' => '',
|
||||
'suffix_id' => '',
|
||||
'formal_title' => '',
|
||||
'communication_style_id' => '',
|
||||
'email_greeting_id' => '1',
|
||||
'email_greeting_custom' => '',
|
||||
'email_greeting_display' => '',
|
||||
'postal_greeting_id' => '1',
|
||||
'postal_greeting_custom' => '',
|
||||
'postal_greeting_display' => '',
|
||||
'addressee_id' => '1',
|
||||
'addressee_custom' => '',
|
||||
'addressee_display' => '',
|
||||
'job_title' => '',
|
||||
'gender_id' => '',
|
||||
'birth_date' => '',
|
||||
'is_deceased' => 0,
|
||||
'deceased_date' => '',
|
||||
'household_name' => '',
|
||||
'primary_contact_id' => '',
|
||||
'organization_name' => '',
|
||||
'sic_code' => '',
|
||||
'user_unique_id' => '',
|
||||
'created_date' => '2013-07-28 08:49:19',
|
||||
'modified_date' => '2012-11-14 16:02:35',
|
||||
'api.participant' => 4,
|
||||
'api.contribution.create' => 1,
|
||||
'api.participant_payment.create' => array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '1',
|
||||
'participant_id' => '4',
|
||||
'contribution_id' => '1',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateParticipantWithPayment"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ParticipantTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.get API.
|
||||
*
|
||||
* This demonstrates setting a custom field through the API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_example() {
|
||||
$params = array(
|
||||
'return.custom_1' => 1,
|
||||
'id' => 3,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 3,
|
||||
'values' => array(
|
||||
'3' => array(
|
||||
'contact_id' => '3',
|
||||
'civicrm_value_testgetwithcu_1_id' => '1',
|
||||
'custom_1' => 'custom string',
|
||||
'id' => '3',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetWithCustom"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.get API.
|
||||
*
|
||||
* This demonstrates setting a custom field through the API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_example() {
|
||||
$params = array(
|
||||
'return' => 'custom_1',
|
||||
'id' => 3,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 3,
|
||||
'values' => array(
|
||||
'3' => array(
|
||||
'contact_id' => '3',
|
||||
'civicrm_value_testgetwithcu_1_id' => '1',
|
||||
'custom_1' => 'custom string',
|
||||
'id' => '3',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetWithCustomReturnSyntax"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
70
sites/all/modules/civicrm/api/v3/examples/Contact/Delete.php
Normal file
70
sites/all/modules/civicrm/api/v3/examples/Contact/Delete.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.delete API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_delete_example() {
|
||||
$params = array(
|
||||
'id' => 3,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'delete', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_delete_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'values' => 1,
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testContactDelete"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.create API.
|
||||
*
|
||||
* This demonstrates use of the 'format.is_success' param.
|
||||
* This param causes only the success or otherwise of the function to be returned as BOOLEAN
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_create_example() {
|
||||
$params = array(
|
||||
'id' => 500,
|
||||
'format.is_success' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_create_expectedresult() {
|
||||
|
||||
$expectedResult = 0;
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testContactCreateFormatIsSuccessFalse"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.get API.
|
||||
*
|
||||
* This demonstrates use of the 'format.is_success' param.
|
||||
* This param causes only the success or otherwise of the function to be returned as BOOLEAN
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_example() {
|
||||
$params = array(
|
||||
'id' => 17,
|
||||
'format.is_success' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_expectedresult() {
|
||||
|
||||
$expectedResult = 1;
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testContactGetFormatIsSuccessTrue"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.get API.
|
||||
*
|
||||
* This demonstrates use of the 'format.id_only' param.
|
||||
* This param causes the id of the only entity to be returned as an integer.
|
||||
* It will be ignored if there is not exactly 1 result
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_example() {
|
||||
$params = array(
|
||||
'id' => 17,
|
||||
'format.only_id' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_expectedresult() {
|
||||
|
||||
$expectedResult = 17;
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testContactGetFormatIDOnly"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.getvalue API.
|
||||
*
|
||||
* This demonstrates use of the 'format.single_value' param.
|
||||
* This param causes only a single value of the only entity to be returned as an string.
|
||||
* It will be ignored if there is not exactly 1 result
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_getvalue_example() {
|
||||
$params = array(
|
||||
'id' => 17,
|
||||
'return' => 'display_name',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'getvalue', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_getvalue_expectedresult() {
|
||||
|
||||
$expectedResult = 'Test Contact';
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testContactGetFormatSingleValue"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
142
sites/all/modules/civicrm/api/v3/examples/Contact/Get.php
Normal file
142
sites/all/modules/civicrm/api/v3/examples/Contact/Get.php
Normal file
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.get API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_example() {
|
||||
$params = array(
|
||||
'email' => 'man2@yahoo.com',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 3,
|
||||
'values' => array(
|
||||
'3' => array(
|
||||
'contact_id' => '3',
|
||||
'contact_type' => 'Individual',
|
||||
'contact_sub_type' => '',
|
||||
'sort_name' => 'man2@yahoo.com',
|
||||
'display_name' => 'man2@yahoo.com',
|
||||
'do_not_email' => 0,
|
||||
'do_not_phone' => 0,
|
||||
'do_not_mail' => 0,
|
||||
'do_not_sms' => 0,
|
||||
'do_not_trade' => 0,
|
||||
'is_opt_out' => 0,
|
||||
'legal_identifier' => '',
|
||||
'external_identifier' => '',
|
||||
'nick_name' => '',
|
||||
'legal_name' => '',
|
||||
'image_URL' => '',
|
||||
'preferred_communication_method' => '',
|
||||
'preferred_language' => 'en_US',
|
||||
'preferred_mail_format' => 'Both',
|
||||
'first_name' => '',
|
||||
'middle_name' => '',
|
||||
'last_name' => '',
|
||||
'prefix_id' => '',
|
||||
'suffix_id' => '',
|
||||
'formal_title' => '',
|
||||
'communication_style_id' => '',
|
||||
'job_title' => '',
|
||||
'gender_id' => '',
|
||||
'birth_date' => '',
|
||||
'is_deceased' => 0,
|
||||
'deceased_date' => '',
|
||||
'household_name' => '',
|
||||
'organization_name' => '',
|
||||
'sic_code' => '',
|
||||
'contact_is_deleted' => 0,
|
||||
'current_employer' => '',
|
||||
'address_id' => '',
|
||||
'street_address' => '',
|
||||
'supplemental_address_1' => '',
|
||||
'supplemental_address_2' => '',
|
||||
'supplemental_address_3' => '',
|
||||
'city' => '',
|
||||
'postal_code_suffix' => '',
|
||||
'postal_code' => '',
|
||||
'geo_code_1' => '',
|
||||
'geo_code_2' => '',
|
||||
'state_province_id' => '',
|
||||
'country_id' => '',
|
||||
'phone_id' => '',
|
||||
'phone_type_id' => '',
|
||||
'phone' => '',
|
||||
'email_id' => '1',
|
||||
'email' => 'man2@yahoo.com',
|
||||
'on_hold' => 0,
|
||||
'im_id' => '',
|
||||
'provider_id' => '',
|
||||
'im' => '',
|
||||
'worldregion_id' => '',
|
||||
'world_region' => '',
|
||||
'languages' => 'English (United States)',
|
||||
'individual_prefix' => '',
|
||||
'individual_suffix' => '',
|
||||
'communication_style' => '',
|
||||
'gender' => '',
|
||||
'state_province_name' => '',
|
||||
'state_province' => '',
|
||||
'country' => '',
|
||||
'id' => '3',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testContactGetEmail"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.getactions API.
|
||||
*
|
||||
* Getting the available actions for an entity.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_getactions_example() {
|
||||
$params = array();
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'getactions', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_getactions_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 20,
|
||||
'values' => array(
|
||||
'0' => 'create',
|
||||
'1' => 'delete',
|
||||
'2' => 'duplicatecheck',
|
||||
'3' => 'get',
|
||||
'4' => 'getactions',
|
||||
'5' => 'getcount',
|
||||
'6' => 'getfield',
|
||||
'7' => 'getfields',
|
||||
'8' => 'getlist',
|
||||
'9' => 'getoptions',
|
||||
'10' => 'getquick',
|
||||
'11' => 'getrefcount',
|
||||
'12' => 'getsingle',
|
||||
'13' => 'getvalue',
|
||||
'14' => 'merge',
|
||||
'15' => 'proximity',
|
||||
'16' => 'replace',
|
||||
'17' => 'setvalue',
|
||||
'18' => 'update',
|
||||
'19' => 'validate',
|
||||
),
|
||||
'deprecated' => array(
|
||||
'getquick' => 'The "getquick" action is deprecated in favor of "getlist".',
|
||||
'setvalue' => 'The "setvalue" action is deprecated. Use "create" with an id instead.',
|
||||
'update' => 'The "update" action is deprecated. Use "create" with an id instead.',
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetActions"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.getcount API.
|
||||
*
|
||||
* This demonstrates use of the 'getCount' action.
|
||||
* This param causes the count of the only function to be returned as an integer.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_getcount_example() {
|
||||
$params = array(
|
||||
'id' => 17,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'getcount', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_getcount_expectedresult() {
|
||||
|
||||
$expectedResult = 1;
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testContactGetFormatCountOnly"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.getoptions API.
|
||||
*
|
||||
* Demonstrates retrieving options for a custom field.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_getoptions_example() {
|
||||
$params = array(
|
||||
'field' => 'custom_1',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'getoptions', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_getoptions_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 2,
|
||||
'values' => array(
|
||||
'1' => 'Label1',
|
||||
'2' => 'Label2',
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCustomFieldCreateWithOptionValues"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.getsingle API.
|
||||
*
|
||||
* This demonstrates use of the 'format.single_entity_array' param.
|
||||
* This param causes the only contact to be returned as an array without the other levels.
|
||||
* It will be ignored if there is not exactly 1 result
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_getsingle_example() {
|
||||
$params = array(
|
||||
'id' => 17,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'getsingle', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_getsingle_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'contact_id' => '17',
|
||||
'contact_type' => 'Individual',
|
||||
'contact_sub_type' => '',
|
||||
'sort_name' => '',
|
||||
'display_name' => 'Test Contact',
|
||||
'do_not_email' => '',
|
||||
'do_not_phone' => '',
|
||||
'do_not_mail' => '',
|
||||
'do_not_sms' => '',
|
||||
'do_not_trade' => '',
|
||||
'is_opt_out' => 0,
|
||||
'legal_identifier' => '',
|
||||
'external_identifier' => '',
|
||||
'nick_name' => '',
|
||||
'legal_name' => '',
|
||||
'image_URL' => '',
|
||||
'preferred_communication_method' => '',
|
||||
'preferred_language' => '',
|
||||
'preferred_mail_format' => '',
|
||||
'first_name' => 'Test',
|
||||
'middle_name' => '',
|
||||
'last_name' => 'Contact',
|
||||
'prefix_id' => '',
|
||||
'suffix_id' => '',
|
||||
'formal_title' => '',
|
||||
'communication_style_id' => '',
|
||||
'job_title' => '',
|
||||
'gender_id' => '',
|
||||
'birth_date' => '',
|
||||
'is_deceased' => 0,
|
||||
'deceased_date' => '',
|
||||
'household_name' => '',
|
||||
'organization_name' => '',
|
||||
'sic_code' => '',
|
||||
'contact_is_deleted' => 0,
|
||||
'current_employer' => '',
|
||||
'address_id' => '',
|
||||
'street_address' => '',
|
||||
'supplemental_address_1' => '',
|
||||
'supplemental_address_2' => '',
|
||||
'supplemental_address_3' => '',
|
||||
'city' => '',
|
||||
'postal_code_suffix' => '',
|
||||
'postal_code' => '',
|
||||
'geo_code_1' => '',
|
||||
'geo_code_2' => '',
|
||||
'state_province_id' => '',
|
||||
'country_id' => '',
|
||||
'phone_id' => '',
|
||||
'phone_type_id' => '',
|
||||
'phone' => '',
|
||||
'email_id' => '',
|
||||
'email' => '',
|
||||
'on_hold' => '',
|
||||
'im_id' => '',
|
||||
'provider_id' => '',
|
||||
'im' => '',
|
||||
'worldregion_id' => '',
|
||||
'world_region' => '',
|
||||
'languages' => '',
|
||||
'individual_prefix' => '',
|
||||
'individual_suffix' => '',
|
||||
'communication_style' => '',
|
||||
'gender' => '',
|
||||
'state_province_name' => '',
|
||||
'state_province' => '',
|
||||
'country' => '',
|
||||
'id' => '17',
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testContactGetSingleEntityArray"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,149 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.get API.
|
||||
*
|
||||
* Get all from group and display contacts.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_example() {
|
||||
$params = array(
|
||||
'group' => array(
|
||||
'IN' => array(
|
||||
'0' => 'Test group C',
|
||||
'1' => 'Test group D',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 3,
|
||||
'values' => array(
|
||||
'3' => array(
|
||||
'contact_id' => '3',
|
||||
'contact_type' => 'Individual',
|
||||
'contact_sub_type' => '',
|
||||
'sort_name' => 'Groupmember, Test2',
|
||||
'display_name' => 'Test2 Groupmember',
|
||||
'do_not_email' => 0,
|
||||
'do_not_phone' => 0,
|
||||
'do_not_mail' => 0,
|
||||
'do_not_sms' => 0,
|
||||
'do_not_trade' => 0,
|
||||
'is_opt_out' => 0,
|
||||
'legal_identifier' => '',
|
||||
'external_identifier' => '',
|
||||
'nick_name' => '',
|
||||
'legal_name' => '',
|
||||
'image_URL' => '',
|
||||
'preferred_communication_method' => '',
|
||||
'preferred_language' => 'en_US',
|
||||
'preferred_mail_format' => 'Both',
|
||||
'first_name' => 'Test2',
|
||||
'middle_name' => '',
|
||||
'last_name' => 'Groupmember',
|
||||
'prefix_id' => '',
|
||||
'suffix_id' => '',
|
||||
'formal_title' => '',
|
||||
'communication_style_id' => '',
|
||||
'job_title' => '',
|
||||
'gender_id' => '',
|
||||
'birth_date' => '',
|
||||
'is_deceased' => 0,
|
||||
'deceased_date' => '',
|
||||
'household_name' => '',
|
||||
'organization_name' => '',
|
||||
'sic_code' => '',
|
||||
'contact_is_deleted' => 0,
|
||||
'current_employer' => '',
|
||||
'address_id' => '',
|
||||
'street_address' => '',
|
||||
'supplemental_address_1' => '',
|
||||
'supplemental_address_2' => '',
|
||||
'supplemental_address_3' => '',
|
||||
'city' => '',
|
||||
'postal_code_suffix' => '',
|
||||
'postal_code' => '',
|
||||
'geo_code_1' => '',
|
||||
'geo_code_2' => '',
|
||||
'state_province_id' => '',
|
||||
'country_id' => '',
|
||||
'phone_id' => '',
|
||||
'phone_type_id' => '',
|
||||
'phone' => '',
|
||||
'email_id' => '1',
|
||||
'email' => 'test@example.org',
|
||||
'on_hold' => 0,
|
||||
'im_id' => '',
|
||||
'provider_id' => '',
|
||||
'im' => '',
|
||||
'worldregion_id' => '',
|
||||
'world_region' => '',
|
||||
'languages' => 'English (United States)',
|
||||
'individual_prefix' => '',
|
||||
'individual_suffix' => '',
|
||||
'communication_style' => '',
|
||||
'gender' => '',
|
||||
'state_province_name' => '',
|
||||
'state_province' => '',
|
||||
'country' => '',
|
||||
'id' => '3',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testContactGetWithGroupTitleMultipleGroups"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,249 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contact.get API.
|
||||
*
|
||||
* Demonstrates use of Replace in a nested API call.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_example() {
|
||||
$params = array(
|
||||
'id' => 10,
|
||||
'api.email.replace' => array(
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'location_type_id' => 20,
|
||||
'email' => '1-1@example.com',
|
||||
'is_primary' => 1,
|
||||
),
|
||||
'1' => array(
|
||||
'location_type_id' => 20,
|
||||
'email' => '1-2@example.com',
|
||||
'is_primary' => 0,
|
||||
),
|
||||
'2' => array(
|
||||
'location_type_id' => 20,
|
||||
'email' => '1-3@example.com',
|
||||
'is_primary' => 0,
|
||||
),
|
||||
'3' => array(
|
||||
'location_type_id' => 21,
|
||||
'email' => '2-1@example.com',
|
||||
'is_primary' => 0,
|
||||
),
|
||||
'4' => array(
|
||||
'location_type_id' => 21,
|
||||
'email' => '2-2@example.com',
|
||||
'is_primary' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contact', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contact_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 10,
|
||||
'values' => array(
|
||||
'10' => array(
|
||||
'contact_id' => '10',
|
||||
'contact_type' => 'Organization',
|
||||
'contact_sub_type' => '',
|
||||
'sort_name' => 'Unit Test Organization',
|
||||
'display_name' => 'Unit Test Organization',
|
||||
'do_not_email' => 0,
|
||||
'do_not_phone' => 0,
|
||||
'do_not_mail' => 0,
|
||||
'do_not_sms' => 0,
|
||||
'do_not_trade' => 0,
|
||||
'is_opt_out' => 0,
|
||||
'legal_identifier' => '',
|
||||
'external_identifier' => '',
|
||||
'nick_name' => '',
|
||||
'legal_name' => '',
|
||||
'image_URL' => '',
|
||||
'preferred_communication_method' => '',
|
||||
'preferred_language' => 'en_US',
|
||||
'preferred_mail_format' => 'Both',
|
||||
'first_name' => '',
|
||||
'middle_name' => '',
|
||||
'last_name' => '',
|
||||
'prefix_id' => '',
|
||||
'suffix_id' => '',
|
||||
'formal_title' => '',
|
||||
'communication_style_id' => '',
|
||||
'job_title' => '',
|
||||
'gender_id' => '',
|
||||
'birth_date' => '',
|
||||
'is_deceased' => 0,
|
||||
'deceased_date' => '',
|
||||
'household_name' => '',
|
||||
'organization_name' => 'Unit Test Organization',
|
||||
'sic_code' => '',
|
||||
'contact_is_deleted' => 0,
|
||||
'current_employer' => '',
|
||||
'address_id' => '',
|
||||
'street_address' => '',
|
||||
'supplemental_address_1' => '',
|
||||
'supplemental_address_2' => '',
|
||||
'supplemental_address_3' => '',
|
||||
'city' => '',
|
||||
'postal_code_suffix' => '',
|
||||
'postal_code' => '',
|
||||
'geo_code_1' => '',
|
||||
'geo_code_2' => '',
|
||||
'state_province_id' => '',
|
||||
'country_id' => '',
|
||||
'phone_id' => '',
|
||||
'phone_type_id' => '',
|
||||
'phone' => '',
|
||||
'email_id' => '',
|
||||
'email' => '',
|
||||
'on_hold' => '',
|
||||
'im_id' => '',
|
||||
'provider_id' => '',
|
||||
'im' => '',
|
||||
'worldregion_id' => '',
|
||||
'world_region' => '',
|
||||
'individual_prefix' => '',
|
||||
'individual_suffix' => '',
|
||||
'communication_style' => '',
|
||||
'gender' => '',
|
||||
'state_province_name' => '',
|
||||
'state_province' => '',
|
||||
'country' => '',
|
||||
'id' => '10',
|
||||
'api.email.replace' => array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 5,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '18',
|
||||
'contact_id' => '10',
|
||||
'location_type_id' => '20',
|
||||
'email' => '1-1@example.com',
|
||||
'is_primary' => '1',
|
||||
'is_billing' => '',
|
||||
'on_hold' => '',
|
||||
'is_bulkmail' => '',
|
||||
'hold_date' => '',
|
||||
'reset_date' => '',
|
||||
'signature_text' => '',
|
||||
'signature_html' => '',
|
||||
),
|
||||
'1' => array(
|
||||
'id' => '19',
|
||||
'contact_id' => '10',
|
||||
'location_type_id' => '20',
|
||||
'email' => '1-2@example.com',
|
||||
'is_primary' => 0,
|
||||
'is_billing' => '',
|
||||
'on_hold' => '',
|
||||
'is_bulkmail' => '',
|
||||
'hold_date' => '',
|
||||
'reset_date' => '',
|
||||
'signature_text' => '',
|
||||
'signature_html' => '',
|
||||
),
|
||||
'2' => array(
|
||||
'id' => '20',
|
||||
'contact_id' => '10',
|
||||
'location_type_id' => '20',
|
||||
'email' => '1-3@example.com',
|
||||
'is_primary' => 0,
|
||||
'is_billing' => '',
|
||||
'on_hold' => '',
|
||||
'is_bulkmail' => '',
|
||||
'hold_date' => '',
|
||||
'reset_date' => '',
|
||||
'signature_text' => '',
|
||||
'signature_html' => '',
|
||||
),
|
||||
'3' => array(
|
||||
'id' => '21',
|
||||
'contact_id' => '10',
|
||||
'location_type_id' => '21',
|
||||
'email' => '2-1@example.com',
|
||||
'is_primary' => 0,
|
||||
'is_billing' => '',
|
||||
'on_hold' => '',
|
||||
'is_bulkmail' => '',
|
||||
'hold_date' => '',
|
||||
'reset_date' => '',
|
||||
'signature_text' => '',
|
||||
'signature_html' => '',
|
||||
),
|
||||
'4' => array(
|
||||
'id' => '22',
|
||||
'contact_id' => '10',
|
||||
'location_type_id' => '21',
|
||||
'email' => '2-2@example.com',
|
||||
'is_primary' => 0,
|
||||
'is_billing' => '',
|
||||
'on_hold' => '',
|
||||
'is_bulkmail' => '',
|
||||
'hold_date' => '',
|
||||
'reset_date' => '',
|
||||
'signature_text' => '',
|
||||
'signature_html' => '',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testReplaceEmailsInChain"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EmailTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contribution.create API.
|
||||
*
|
||||
* Demonstrates creating contribution with Soft Credit by passing in honor_contact_id.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_create_example() {
|
||||
$params = array(
|
||||
'contact_id' => 28,
|
||||
'receive_date' => '20120511',
|
||||
'total_amount' => '100',
|
||||
'financial_type_id' => 1,
|
||||
'non_deductible_amount' => '10',
|
||||
'fee_amount' => '5',
|
||||
'net_amount' => '95',
|
||||
'source' => 'SSF',
|
||||
'contribution_status_id' => 1,
|
||||
'honor_contact_id' => 29,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contribution', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'contact_id' => '28',
|
||||
'financial_type_id' => '1',
|
||||
'contribution_page_id' => '',
|
||||
'payment_instrument_id' => '4',
|
||||
'receive_date' => '20120511000000',
|
||||
'non_deductible_amount' => '10',
|
||||
'total_amount' => '100',
|
||||
'fee_amount' => '5',
|
||||
'net_amount' => '95',
|
||||
'trxn_id' => '',
|
||||
'invoice_id' => '',
|
||||
'currency' => 'USD',
|
||||
'cancel_date' => '',
|
||||
'cancel_reason' => '',
|
||||
'receipt_date' => '',
|
||||
'thankyou_date' => '',
|
||||
'source' => 'SSF',
|
||||
'amount_level' => '',
|
||||
'contribution_recur_id' => '',
|
||||
'is_test' => '',
|
||||
'is_pay_later' => '',
|
||||
'contribution_status_id' => '1',
|
||||
'address_id' => '',
|
||||
'check_number' => '',
|
||||
'campaign_id' => '',
|
||||
'creditnote_id' => '',
|
||||
'tax_amount' => '',
|
||||
'revenue_recognition_date' => '',
|
||||
'contribution_type_id' => '1',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateContributionWithHonoreeContact"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contribution.create API.
|
||||
*
|
||||
* Demonstrates creating contribution with Note Entity.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_create_example() {
|
||||
$params = array(
|
||||
'contact_id' => 22,
|
||||
'receive_date' => '2012-01-01',
|
||||
'total_amount' => '100',
|
||||
'financial_type_id' => 1,
|
||||
'payment_instrument_id' => 1,
|
||||
'non_deductible_amount' => '10',
|
||||
'fee_amount' => '50',
|
||||
'net_amount' => '90',
|
||||
'trxn_id' => 12345,
|
||||
'invoice_id' => 67890,
|
||||
'source' => 'SSF',
|
||||
'contribution_status_id' => 1,
|
||||
'note' => 'my contribution note',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contribution', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'contact_id' => '22',
|
||||
'financial_type_id' => '1',
|
||||
'contribution_page_id' => '',
|
||||
'payment_instrument_id' => '1',
|
||||
'receive_date' => '20120101000000',
|
||||
'non_deductible_amount' => '10',
|
||||
'total_amount' => '100',
|
||||
'fee_amount' => '50',
|
||||
'net_amount' => '90',
|
||||
'trxn_id' => '12345',
|
||||
'invoice_id' => '67890',
|
||||
'currency' => 'USD',
|
||||
'cancel_date' => '',
|
||||
'cancel_reason' => '',
|
||||
'receipt_date' => '',
|
||||
'thankyou_date' => '',
|
||||
'source' => 'SSF',
|
||||
'amount_level' => '',
|
||||
'contribution_recur_id' => '',
|
||||
'is_test' => '',
|
||||
'is_pay_later' => '',
|
||||
'contribution_status_id' => '1',
|
||||
'address_id' => '',
|
||||
'check_number' => '',
|
||||
'campaign_id' => '',
|
||||
'creditnote_id' => '',
|
||||
'tax_amount' => '',
|
||||
'revenue_recognition_date' => '',
|
||||
'contribution_type_id' => '1',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateContributionWithNote"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,121 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contribution.create API.
|
||||
*
|
||||
* Demonstrates creating contribution with SoftCredit.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_create_example() {
|
||||
$params = array(
|
||||
'contact_id' => 24,
|
||||
'receive_date' => '20120511',
|
||||
'total_amount' => '100',
|
||||
'financial_type_id' => 1,
|
||||
'non_deductible_amount' => '10',
|
||||
'fee_amount' => '5',
|
||||
'net_amount' => '95',
|
||||
'source' => 'SSF',
|
||||
'contribution_status_id' => 1,
|
||||
'soft_credit' => array(
|
||||
'1' => array(
|
||||
'contact_id' => 25,
|
||||
'amount' => 50,
|
||||
'soft_credit_type_id' => 3,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contribution', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'contact_id' => '24',
|
||||
'financial_type_id' => '1',
|
||||
'contribution_page_id' => '',
|
||||
'payment_instrument_id' => '4',
|
||||
'receive_date' => '20120511000000',
|
||||
'non_deductible_amount' => '10',
|
||||
'total_amount' => '100',
|
||||
'fee_amount' => '5',
|
||||
'net_amount' => '95',
|
||||
'trxn_id' => '',
|
||||
'invoice_id' => '',
|
||||
'currency' => 'USD',
|
||||
'cancel_date' => '',
|
||||
'cancel_reason' => '',
|
||||
'receipt_date' => '',
|
||||
'thankyou_date' => '',
|
||||
'source' => 'SSF',
|
||||
'amount_level' => '',
|
||||
'contribution_recur_id' => '',
|
||||
'is_test' => '',
|
||||
'is_pay_later' => '',
|
||||
'contribution_status_id' => '1',
|
||||
'address_id' => '',
|
||||
'check_number' => '',
|
||||
'campaign_id' => '',
|
||||
'creditnote_id' => '',
|
||||
'tax_amount' => '',
|
||||
'revenue_recognition_date' => '',
|
||||
'contribution_type_id' => '1',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateContributionWithSoftCredit"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contribution.create API.
|
||||
*
|
||||
* Demonstrates creating contribution with Soft Credit defaults for amount and type.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_create_example() {
|
||||
$params = array(
|
||||
'contact_id' => 26,
|
||||
'receive_date' => '20120511',
|
||||
'total_amount' => '100',
|
||||
'financial_type_id' => 1,
|
||||
'non_deductible_amount' => '10',
|
||||
'fee_amount' => '5',
|
||||
'net_amount' => '95',
|
||||
'source' => 'SSF',
|
||||
'contribution_status_id' => 1,
|
||||
'soft_credit_to' => 27,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contribution', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'contact_id' => '26',
|
||||
'financial_type_id' => '1',
|
||||
'contribution_page_id' => '',
|
||||
'payment_instrument_id' => '4',
|
||||
'receive_date' => '20120511000000',
|
||||
'non_deductible_amount' => '10',
|
||||
'total_amount' => '100',
|
||||
'fee_amount' => '5',
|
||||
'net_amount' => '95',
|
||||
'trxn_id' => '',
|
||||
'invoice_id' => '',
|
||||
'currency' => 'USD',
|
||||
'cancel_date' => '',
|
||||
'cancel_reason' => '',
|
||||
'receipt_date' => '',
|
||||
'thankyou_date' => '',
|
||||
'source' => 'SSF',
|
||||
'amount_level' => '',
|
||||
'contribution_recur_id' => '',
|
||||
'is_test' => '',
|
||||
'is_pay_later' => '',
|
||||
'contribution_status_id' => '1',
|
||||
'address_id' => '',
|
||||
'check_number' => '',
|
||||
'campaign_id' => '',
|
||||
'creditnote_id' => '',
|
||||
'tax_amount' => '',
|
||||
'revenue_recognition_date' => '',
|
||||
'contribution_type_id' => '1',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateContributionWithSoftCreditDefaults"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contribution.create API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_create_example() {
|
||||
$params = array(
|
||||
'contact_id' => 1,
|
||||
'receive_date' => '20120511',
|
||||
'total_amount' => '100',
|
||||
'financial_type_id' => 1,
|
||||
'contribution_page_id' => 1,
|
||||
'trxn_id' => 12345,
|
||||
'is_pay_later' => 1,
|
||||
'invoice_id' => 67890,
|
||||
'source' => 'SSF',
|
||||
'contribution_status_id' => 2,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contribution', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'contact_id' => '1',
|
||||
'financial_type_id' => '1',
|
||||
'contribution_page_id' => '1',
|
||||
'payment_instrument_id' => '4',
|
||||
'receive_date' => '20120511000000',
|
||||
'non_deductible_amount' => '',
|
||||
'total_amount' => '100',
|
||||
'fee_amount' => 0,
|
||||
'net_amount' => '100',
|
||||
'trxn_id' => '12345',
|
||||
'invoice_id' => '67890',
|
||||
'currency' => 'USD',
|
||||
'cancel_date' => '',
|
||||
'cancel_reason' => '',
|
||||
'receipt_date' => '',
|
||||
'thankyou_date' => '',
|
||||
'source' => 'SSF',
|
||||
'amount_level' => '',
|
||||
'contribution_recur_id' => '',
|
||||
'is_test' => '',
|
||||
'is_pay_later' => '1',
|
||||
'contribution_status_id' => '2',
|
||||
'address_id' => '',
|
||||
'check_number' => '',
|
||||
'campaign_id' => '',
|
||||
'creditnote_id' => '',
|
||||
'tax_amount' => '',
|
||||
'revenue_recognition_date' => '',
|
||||
'contribution_type_id' => '1',
|
||||
'invoice_number' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateContributionPayLaterOnline"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,182 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contribution.create API.
|
||||
*
|
||||
* Create Contribution with Nested Line Items.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_create_example() {
|
||||
$params = array(
|
||||
'contact_id' => 11,
|
||||
'receive_date' => '20120511',
|
||||
'total_amount' => '100',
|
||||
'financial_type_id' => 1,
|
||||
'payment_instrument_id' => 1,
|
||||
'non_deductible_amount' => '10',
|
||||
'fee_amount' => '50',
|
||||
'net_amount' => '90',
|
||||
'trxn_id' => 12345,
|
||||
'invoice_id' => 67890,
|
||||
'source' => 'SSF',
|
||||
'contribution_status_id' => 1,
|
||||
'skipLineItem' => 1,
|
||||
'api.line_item.create' => array(
|
||||
'0' => array(
|
||||
'price_field_id' => 1,
|
||||
'qty' => 2,
|
||||
'line_total' => '20',
|
||||
'unit_price' => '10',
|
||||
),
|
||||
'1' => array(
|
||||
'price_field_id' => 1,
|
||||
'qty' => 1,
|
||||
'line_total' => '80',
|
||||
'unit_price' => '80',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contribution', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'contact_id' => '11',
|
||||
'financial_type_id' => '1',
|
||||
'contribution_page_id' => '',
|
||||
'payment_instrument_id' => '1',
|
||||
'receive_date' => '20120511000000',
|
||||
'non_deductible_amount' => '10',
|
||||
'total_amount' => '100',
|
||||
'fee_amount' => '50',
|
||||
'net_amount' => '90',
|
||||
'trxn_id' => '12345',
|
||||
'invoice_id' => '67890',
|
||||
'currency' => 'USD',
|
||||
'cancel_date' => '',
|
||||
'cancel_reason' => '',
|
||||
'receipt_date' => '',
|
||||
'thankyou_date' => '',
|
||||
'source' => 'SSF',
|
||||
'amount_level' => '',
|
||||
'contribution_recur_id' => '',
|
||||
'is_test' => '',
|
||||
'is_pay_later' => '',
|
||||
'contribution_status_id' => '1',
|
||||
'address_id' => '',
|
||||
'check_number' => '',
|
||||
'campaign_id' => '',
|
||||
'creditnote_id' => '',
|
||||
'tax_amount' => 0,
|
||||
'revenue_recognition_date' => '',
|
||||
'contribution_type_id' => '1',
|
||||
'api.line_item.create' => array(
|
||||
'0' => array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '1',
|
||||
'entity_table' => 'civicrm_contribution',
|
||||
'entity_id' => '1',
|
||||
'contribution_id' => '1',
|
||||
'price_field_id' => '1',
|
||||
'label' => 'line item',
|
||||
'qty' => '2',
|
||||
'unit_price' => '10',
|
||||
'line_total' => '20',
|
||||
'participant_count' => '',
|
||||
'price_field_value_id' => '',
|
||||
'financial_type_id' => '',
|
||||
'non_deductible_amount' => '',
|
||||
'tax_amount' => '',
|
||||
),
|
||||
),
|
||||
),
|
||||
'1' => array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 2,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '2',
|
||||
'entity_table' => 'civicrm_contribution',
|
||||
'entity_id' => '1',
|
||||
'contribution_id' => '1',
|
||||
'price_field_id' => '1',
|
||||
'label' => 'line item',
|
||||
'qty' => '1',
|
||||
'unit_price' => '80',
|
||||
'line_total' => '80',
|
||||
'participant_count' => '',
|
||||
'price_field_value_id' => '',
|
||||
'financial_type_id' => '',
|
||||
'non_deductible_amount' => '',
|
||||
'tax_amount' => '',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateContributionChainedLineItems"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contribution.delete API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_delete_example() {
|
||||
$params = array(
|
||||
'id' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contribution', 'delete', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_delete_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => 1,
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testDeleteContribution"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
123
sites/all/modules/civicrm/api/v3/examples/Contribution/Get.php
Normal file
123
sites/all/modules/civicrm/api/v3/examples/Contribution/Get.php
Normal file
|
@ -0,0 +1,123 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Contribution.get API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_get_example() {
|
||||
$params = array(
|
||||
'contribution_id' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Contribution', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'contact_id' => '3',
|
||||
'contact_type' => 'Individual',
|
||||
'contact_sub_type' => '',
|
||||
'sort_name' => 'Anderson, Anthony',
|
||||
'display_name' => 'Mr. Anthony Anderson II',
|
||||
'contribution_id' => '1',
|
||||
'currency' => 'USD',
|
||||
'receive_date' => '2010-01-20 00:00:00',
|
||||
'non_deductible_amount' => '10.00',
|
||||
'total_amount' => '100.00',
|
||||
'fee_amount' => '5.00',
|
||||
'net_amount' => '95.00',
|
||||
'trxn_id' => '23456',
|
||||
'invoice_id' => '78910',
|
||||
'cancel_date' => '',
|
||||
'cancel_reason' => '',
|
||||
'receipt_date' => '',
|
||||
'thankyou_date' => '',
|
||||
'contribution_source' => 'SSF',
|
||||
'amount_level' => '',
|
||||
'contribution_recur_id' => '',
|
||||
'is_test' => 0,
|
||||
'is_pay_later' => 0,
|
||||
'contribution_status_id' => '1',
|
||||
'contribution_check_number' => '',
|
||||
'contribution_campaign_id' => '',
|
||||
'financial_type_id' => '1',
|
||||
'financial_type' => 'Donation',
|
||||
'product_id' => '',
|
||||
'product_name' => '',
|
||||
'sku' => '',
|
||||
'contribution_product_id' => '',
|
||||
'product_option' => '',
|
||||
'fulfilled_date' => '',
|
||||
'contribution_start_date' => '',
|
||||
'contribution_end_date' => '',
|
||||
'financial_account_id' => '1',
|
||||
'accounting_code' => '4200',
|
||||
'campaign_id' => '',
|
||||
'contribution_campaign_title' => '',
|
||||
'contribution_note' => '',
|
||||
'contribution_batch' => '',
|
||||
'contribution_status' => 'Completed',
|
||||
'payment_instrument' => 'Check',
|
||||
'payment_instrument_id' => '4',
|
||||
'instrument_id' => '4',
|
||||
'check_number' => '',
|
||||
'id' => '1',
|
||||
'contribution_type_id' => '1',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetContribution"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the ContributionPage.create API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_page_create_example() {
|
||||
$params = array(
|
||||
'title' => 'Test Contribution Page',
|
||||
'financial_type_id' => 1,
|
||||
'currency' => 'NZD',
|
||||
'goal_amount' => 34567,
|
||||
'is_pay_later' => 1,
|
||||
'is_monetary' => TRUE,
|
||||
'is_email_receipt' => TRUE,
|
||||
'receipt_from_email' => 'yourconscience@donate.com',
|
||||
'receipt_from_name' => 'Ego Freud',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('ContributionPage', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_page_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'title' => 'Test Contribution Page',
|
||||
'intro_text' => '',
|
||||
'financial_type_id' => '1',
|
||||
'payment_processor' => '',
|
||||
'is_credit_card_only' => '',
|
||||
'is_monetary' => '1',
|
||||
'is_recur' => '',
|
||||
'is_confirm_enabled' => '',
|
||||
'recur_frequency_unit' => '',
|
||||
'is_recur_interval' => '',
|
||||
'is_recur_installments' => '',
|
||||
'adjust_recur_start_date' => '',
|
||||
'is_pay_later' => '1',
|
||||
'pay_later_text' => '',
|
||||
'pay_later_receipt' => '',
|
||||
'is_partial_payment' => '',
|
||||
'initial_amount_label' => '',
|
||||
'initial_amount_help_text' => '',
|
||||
'min_initial_amount' => '',
|
||||
'is_allow_other_amount' => '',
|
||||
'default_amount_id' => '',
|
||||
'min_amount' => '',
|
||||
'max_amount' => '',
|
||||
'goal_amount' => '34567',
|
||||
'thankyou_title' => '',
|
||||
'thankyou_text' => '',
|
||||
'thankyou_footer' => '',
|
||||
'is_email_receipt' => '1',
|
||||
'receipt_from_name' => 'Ego Freud',
|
||||
'receipt_from_email' => 'yourconscience@donate.com',
|
||||
'cc_receipt' => '',
|
||||
'bcc_receipt' => '',
|
||||
'receipt_text' => '',
|
||||
'is_active' => '1',
|
||||
'footer_text' => '',
|
||||
'amount_block_is_active' => '',
|
||||
'start_date' => '',
|
||||
'end_date' => '',
|
||||
'created_id' => '',
|
||||
'created_date' => '',
|
||||
'currency' => 'NZD',
|
||||
'campaign_id' => '',
|
||||
'is_share' => '',
|
||||
'is_billing_required' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateContributionPage"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionPageTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the ContributionPage.delete API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_page_delete_example() {
|
||||
$params = array(
|
||||
'id' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('ContributionPage', 'delete', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_page_delete_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'values' => 1,
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testDeleteContributionPage"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionPageTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the ContributionPage.get API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_page_get_example() {
|
||||
$params = array(
|
||||
'currency' => 'NZD',
|
||||
'financial_type_id' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('ContributionPage', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_page_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'title' => 'Test Contribution Page',
|
||||
'financial_type_id' => '1',
|
||||
'is_credit_card_only' => 0,
|
||||
'is_monetary' => '1',
|
||||
'is_recur' => 0,
|
||||
'is_confirm_enabled' => '1',
|
||||
'is_recur_interval' => 0,
|
||||
'is_recur_installments' => 0,
|
||||
'adjust_recur_start_date' => 0,
|
||||
'is_pay_later' => '1',
|
||||
'is_partial_payment' => 0,
|
||||
'is_allow_other_amount' => 0,
|
||||
'goal_amount' => '34567.00',
|
||||
'is_email_receipt' => '1',
|
||||
'receipt_from_name' => 'Ego Freud',
|
||||
'receipt_from_email' => 'yourconscience@donate.com',
|
||||
'is_active' => '1',
|
||||
'amount_block_is_active' => '1',
|
||||
'currency' => 'NZD',
|
||||
'is_share' => '1',
|
||||
'is_billing_required' => 0,
|
||||
'contribution_type_id' => '1',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetBasicContributionPage"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionPageTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the ContributionPage.submit API.
|
||||
*
|
||||
* submit contribution page
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_page_submit_example() {
|
||||
$params = array(
|
||||
'id' => 1,
|
||||
'pledge_amount' => array(
|
||||
'2' => 1,
|
||||
),
|
||||
'billing_first_name' => 'Billy',
|
||||
'billing_middle_name' => 'Goat',
|
||||
'billing_last_name' => 'Gruff',
|
||||
'email' => 'billy@goat.gruff',
|
||||
'payment_processor_id' => 1,
|
||||
'credit_card_number' => '4111111111111111',
|
||||
'credit_card_type' => 'Visa',
|
||||
'credit_card_exp_date' => array(
|
||||
'M' => 9,
|
||||
'Y' => 2040,
|
||||
),
|
||||
'cvv2' => 123,
|
||||
'pledge_id' => '1',
|
||||
'cid' => '77',
|
||||
'contact_id' => '77',
|
||||
'amount' => '100',
|
||||
'is_pledge' => TRUE,
|
||||
'pledge_block_id' => 2,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('ContributionPage', 'submit', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_page_submit_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 0,
|
||||
'values' => '',
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testSubmitPledgePayment"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionPageTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the ContributionRecur.create API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_recur_create_example() {
|
||||
$params = array(
|
||||
'contact_id' => 3,
|
||||
'installments' => '12',
|
||||
'frequency_interval' => '1',
|
||||
'amount' => '500',
|
||||
'contribution_status_id' => 1,
|
||||
'start_date' => '2012-01-01 00:00:00',
|
||||
'currency' => 'USD',
|
||||
'frequency_unit' => 'day',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('ContributionRecur', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_recur_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'contact_id' => '3',
|
||||
'amount' => '500',
|
||||
'currency' => 'USD',
|
||||
'frequency_unit' => 'day',
|
||||
'frequency_interval' => '1',
|
||||
'installments' => '12',
|
||||
'start_date' => '2013-07-29 00:00:00',
|
||||
'create_date' => '20120130621222105',
|
||||
'modified_date' => '2012-11-14 16:02:35',
|
||||
'cancel_date' => '',
|
||||
'end_date' => '',
|
||||
'processor_id' => '',
|
||||
'payment_token_id' => '',
|
||||
'trxn_id' => '',
|
||||
'invoice_id' => '',
|
||||
'contribution_status_id' => '1',
|
||||
'is_test' => '',
|
||||
'cycle_day' => '',
|
||||
'next_sched_contribution_date' => '',
|
||||
'failure_count' => '',
|
||||
'failure_retry_date' => '',
|
||||
'auto_renew' => '',
|
||||
'payment_processor_id' => '',
|
||||
'financial_type_id' => '',
|
||||
'payment_instrument_id' => '',
|
||||
'campaign_id' => '',
|
||||
'is_email_receipt' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateContributionRecur"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionRecurTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the ContributionRecur.delete API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_recur_delete_example() {
|
||||
$params = array(
|
||||
'id' => 4,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('ContributionRecur', 'delete', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_recur_delete_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'values' => 1,
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testDeleteContributionRecur"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionRecurTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the ContributionRecur.get API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_recur_get_example() {
|
||||
$params = array(
|
||||
'amount' => '500',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('ContributionRecur', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_recur_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 2,
|
||||
'values' => array(
|
||||
'2' => array(
|
||||
'id' => '2',
|
||||
'contact_id' => '4',
|
||||
'amount' => '500.00',
|
||||
'currency' => 'USD',
|
||||
'frequency_unit' => 'day',
|
||||
'frequency_interval' => '1',
|
||||
'installments' => '12',
|
||||
'start_date' => '2013-07-29 00:00:00',
|
||||
'create_date' => '20120130621222105',
|
||||
'modified_date' => '2012-11-14 16:02:35',
|
||||
'contribution_status_id' => '1',
|
||||
'is_test' => 0,
|
||||
'cycle_day' => '1',
|
||||
'failure_count' => 0,
|
||||
'auto_renew' => 0,
|
||||
'is_email_receipt' => '1',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetContributionRecur"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionRecurTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the ContributionSoft.create API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_soft_create_example() {
|
||||
$params = array(
|
||||
'contribution_id' => 6,
|
||||
'contact_id' => 19,
|
||||
'amount' => '10',
|
||||
'currency' => 'USD',
|
||||
'soft_credit_type_id' => 5,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('ContributionSoft', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_soft_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 5,
|
||||
'values' => array(
|
||||
'5' => array(
|
||||
'id' => '5',
|
||||
'contribution_id' => '6',
|
||||
'contact_id' => '19',
|
||||
'amount' => '10',
|
||||
'currency' => 'USD',
|
||||
'pcp_id' => '',
|
||||
'pcp_display_in_roll' => '',
|
||||
'pcp_roll_nickname' => '',
|
||||
'pcp_personal_note' => '',
|
||||
'soft_credit_type_id' => '5',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateContributionSoft"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionSoftTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the ContributionSoft.delete API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_soft_delete_example() {
|
||||
$params = array(
|
||||
'id' => 7,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('ContributionSoft', 'delete', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_soft_delete_expectedresult() {
|
||||
|
||||
$expectedResult = '';
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testDeleteContributionSoft"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionSoftTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the ContributionSoft.get API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_soft_get_example() {
|
||||
$params = array(
|
||||
'id' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('ContributionSoft', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function contribution_soft_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'contribution_id' => '1',
|
||||
'contact_id' => '4',
|
||||
'amount' => '10.00',
|
||||
'currency' => 'USD',
|
||||
'pcp_display_in_roll' => 0,
|
||||
'soft_credit_type_id' => '4',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetContributionSoft"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionSoftTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
85
sites/all/modules/civicrm/api/v3/examples/Country/Create.php
Normal file
85
sites/all/modules/civicrm/api/v3/examples/Country/Create.php
Normal file
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Country.create API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function country_create_example() {
|
||||
$params = array(
|
||||
'name' => 'Made Up Land',
|
||||
'iso_code' => 'ZZ',
|
||||
'region_id' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Country', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function country_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1254,
|
||||
'values' => array(
|
||||
'1254' => array(
|
||||
'id' => '1254',
|
||||
'name' => 'Made Up Land',
|
||||
'iso_code' => 'ZZ',
|
||||
'country_code' => '',
|
||||
'address_format_id' => '',
|
||||
'idd_prefix' => '',
|
||||
'ndd_prefix' => '',
|
||||
'region_id' => '1',
|
||||
'is_province_abbreviated' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateCountry"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CountryTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
70
sites/all/modules/civicrm/api/v3/examples/Country/Delete.php
Normal file
70
sites/all/modules/civicrm/api/v3/examples/Country/Delete.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Country.delete API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function country_delete_example() {
|
||||
$params = array(
|
||||
'id' => 1255,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Country', 'delete', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function country_delete_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'values' => 1,
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testDeleteCountry"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CountryTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
79
sites/all/modules/civicrm/api/v3/examples/Country/Get.php
Normal file
79
sites/all/modules/civicrm/api/v3/examples/Country/Get.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Country.get API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function country_get_example() {
|
||||
$params = array(
|
||||
'iso_code' => 'ZZ',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Country', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function country_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1256,
|
||||
'values' => array(
|
||||
'1256' => array(
|
||||
'id' => '1256',
|
||||
'name' => 'Made Up Land',
|
||||
'iso_code' => 'ZZ',
|
||||
'region_id' => '1',
|
||||
'is_province_abbreviated' => 0,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGet"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CountryTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
113
sites/all/modules/civicrm/api/v3/examples/CustomField/Create.php
Normal file
113
sites/all/modules/civicrm/api/v3/examples/CustomField/Create.php
Normal file
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the CustomField.create API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function custom_field_create_example() {
|
||||
$params = array(
|
||||
'custom_group_id' => 1,
|
||||
'name' => 'test_textfield2',
|
||||
'label' => 'Name1',
|
||||
'html_type' => 'Text',
|
||||
'data_type' => 'String',
|
||||
'default_value' => 'abc',
|
||||
'weight' => 4,
|
||||
'is_required' => 1,
|
||||
'is_searchable' => 0,
|
||||
'is_active' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('CustomField', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function custom_field_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'custom_group_id' => '1',
|
||||
'name' => 'test_textfield2',
|
||||
'label' => 'Name1',
|
||||
'data_type' => 'String',
|
||||
'html_type' => 'Text',
|
||||
'default_value' => 'abc',
|
||||
'is_required' => '1',
|
||||
'is_searchable' => 0,
|
||||
'is_search_range' => 0,
|
||||
'weight' => '4',
|
||||
'help_pre' => '',
|
||||
'help_post' => '',
|
||||
'mask' => '',
|
||||
'attributes' => '',
|
||||
'javascript' => '',
|
||||
'is_active' => '1',
|
||||
'is_view' => 0,
|
||||
'options_per_line' => '',
|
||||
'text_length' => '',
|
||||
'start_date_years' => '',
|
||||
'end_date_years' => '',
|
||||
'date_format' => '',
|
||||
'time_format' => '',
|
||||
'note_columns' => '',
|
||||
'note_rows' => '',
|
||||
'column_name' => 'name1_1',
|
||||
'option_group_id' => '',
|
||||
'filter' => '',
|
||||
'in_selector' => 0,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCustomFieldCreateWithEdit"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CustomFieldTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the CustomField.delete API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function custom_field_delete_example() {
|
||||
$params = array(
|
||||
'id' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('CustomField', 'delete', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function custom_field_delete_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'values' => 1,
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCustomFieldDelete"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CustomFieldTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
104
sites/all/modules/civicrm/api/v3/examples/CustomGroup/Create.php
Normal file
104
sites/all/modules/civicrm/api/v3/examples/CustomGroup/Create.php
Normal file
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the CustomGroup.create API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function custom_group_create_example() {
|
||||
$params = array(
|
||||
'title' => 'Test_Group_1',
|
||||
'name' => 'test_group_1',
|
||||
'extends' => array(
|
||||
'0' => 'Individual',
|
||||
),
|
||||
'weight' => 4,
|
||||
'collapse_display' => 1,
|
||||
'style' => 'Inline',
|
||||
'help_pre' => 'This is Pre Help For Test Group 1',
|
||||
'help_post' => 'This is Post Help For Test Group 1',
|
||||
'is_active' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('CustomGroup', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function custom_group_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'name' => 'test_group_1',
|
||||
'title' => 'Test_Group_1',
|
||||
'extends' => 'Individual',
|
||||
'extends_entity_column_id' => '',
|
||||
'extends_entity_column_value' => '',
|
||||
'style' => 'Inline',
|
||||
'collapse_display' => '1',
|
||||
'help_pre' => 'This is Pre Help For Test Group 1',
|
||||
'help_post' => 'This is Post Help For Test Group 1',
|
||||
'weight' => '2',
|
||||
'is_active' => '1',
|
||||
'table_name' => 'civicrm_value_test_group_1_1',
|
||||
'is_multiple' => '',
|
||||
'min_multiple' => '',
|
||||
'max_multiple' => '',
|
||||
'collapse_adv_display' => '',
|
||||
'created_id' => '',
|
||||
'created_date' => '',
|
||||
'is_reserved' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCustomGroupCreate"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CustomGroupTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the CustomGroup.delete API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function custom_group_delete_example() {
|
||||
$params = array(
|
||||
'id' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('CustomGroup', 'delete', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function custom_group_delete_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'values' => 1,
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCustomGroupDelete"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CustomGroupTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the CustomGroup.get API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function custom_group_get_example() {
|
||||
$params = array();
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('CustomGroup', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function custom_group_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'name' => 'test_group_1',
|
||||
'title' => 'Test_Group_1',
|
||||
'extends' => 'Individual',
|
||||
'style' => 'Inline',
|
||||
'collapse_display' => '1',
|
||||
'help_pre' => 'This is Pre Help For Test Group 1',
|
||||
'help_post' => 'This is Post Help For Test Group 1',
|
||||
'weight' => '2',
|
||||
'is_active' => '1',
|
||||
'table_name' => 'civicrm_value_test_group_1_1',
|
||||
'is_multiple' => 0,
|
||||
'collapse_adv_display' => 0,
|
||||
'is_reserved' => 0,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetCustomGroupSuccess"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CustomGroupTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the CustomValue.create API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function custom_value_create_example() {
|
||||
$params = array(
|
||||
'custom_1' => 'customString',
|
||||
'entity_id' => 3,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('CustomValue', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'error' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function custom_value_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'values' => TRUE,
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateCustomValue"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CustomValueTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,121 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the CustomValue.get API.
|
||||
*
|
||||
* utilises field names
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function custom_value_get_example() {
|
||||
$params = array(
|
||||
'id' => 2,
|
||||
'entity_id' => 2,
|
||||
'format.field_names' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('CustomValue', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'error' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function custom_value_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 7,
|
||||
'values' => array(
|
||||
'mySingleField' => array(
|
||||
'entity_id' => '2',
|
||||
'latest' => 'value 1',
|
||||
'id' => 'mySingleField',
|
||||
),
|
||||
'field_12' => array(
|
||||
'entity_id' => '2',
|
||||
'latest' => 'value 3',
|
||||
'id' => 'field_12',
|
||||
'1' => 'value 2',
|
||||
'2' => 'value 3',
|
||||
),
|
||||
'field_22' => array(
|
||||
'entity_id' => '2',
|
||||
'latest' => '',
|
||||
'id' => 'field_22',
|
||||
'1' => 'warm beer',
|
||||
'2' => '',
|
||||
),
|
||||
'field_32' => array(
|
||||
'entity_id' => '2',
|
||||
'latest' => '',
|
||||
'id' => 'field_32',
|
||||
'1' => 'fl* w*',
|
||||
'2' => '',
|
||||
),
|
||||
'field_13' => array(
|
||||
'entity_id' => '2',
|
||||
'latest' => 'coffee',
|
||||
'id' => 'field_13',
|
||||
'1' => 'defaultValue',
|
||||
'2' => 'coffee',
|
||||
),
|
||||
'field_23' => array(
|
||||
'entity_id' => '2',
|
||||
'latest' => 'value 4',
|
||||
'id' => 'field_23',
|
||||
'1' => '',
|
||||
'2' => 'value 4',
|
||||
),
|
||||
'field_33' => array(
|
||||
'entity_id' => '2',
|
||||
'latest' => '',
|
||||
'id' => 'field_33',
|
||||
'1' => 'vegemite',
|
||||
'2' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetMultipleCustomValues"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CustomValueTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
120
sites/all/modules/civicrm/api/v3/examples/CustomValue/Get.php
Normal file
120
sites/all/modules/civicrm/api/v3/examples/CustomValue/Get.php
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the CustomValue.get API.
|
||||
*
|
||||
* This demonstrates the use of CustomValue get to fetch single and multi-valued custom data.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function custom_value_get_example() {
|
||||
$params = array(
|
||||
'id' => 2,
|
||||
'entity_id' => 2,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('CustomValue', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'error' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function custom_value_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 7,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'entity_id' => '2',
|
||||
'latest' => 'value 1',
|
||||
'id' => '1',
|
||||
),
|
||||
'2' => array(
|
||||
'entity_id' => '2',
|
||||
'latest' => 'value 3',
|
||||
'id' => '2',
|
||||
'1' => 'value 2',
|
||||
'2' => 'value 3',
|
||||
),
|
||||
'3' => array(
|
||||
'entity_id' => '2',
|
||||
'latest' => '',
|
||||
'id' => '3',
|
||||
'1' => 'warm beer',
|
||||
'2' => '',
|
||||
),
|
||||
'4' => array(
|
||||
'entity_id' => '2',
|
||||
'latest' => '',
|
||||
'id' => '4',
|
||||
'1' => 'fl* w*',
|
||||
'2' => '',
|
||||
),
|
||||
'5' => array(
|
||||
'entity_id' => '2',
|
||||
'latest' => 'coffee',
|
||||
'id' => '5',
|
||||
'1' => 'defaultValue',
|
||||
'2' => 'coffee',
|
||||
),
|
||||
'6' => array(
|
||||
'entity_id' => '2',
|
||||
'latest' => 'value 4',
|
||||
'id' => '6',
|
||||
'1' => '',
|
||||
'2' => 'value 4',
|
||||
),
|
||||
'7' => array(
|
||||
'entity_id' => '2',
|
||||
'latest' => '',
|
||||
'id' => '7',
|
||||
'1' => 'vegemite',
|
||||
'2' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetMultipleCustomValues"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CustomValueTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
85
sites/all/modules/civicrm/api/v3/examples/Domain/Create.php
Normal file
85
sites/all/modules/civicrm/api/v3/examples/Domain/Create.php
Normal file
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Domain.create API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function domain_create_example() {
|
||||
$params = array(
|
||||
'name' => 'A-team domain',
|
||||
'description' => 'domain of chaos',
|
||||
'domain_version' => '4.2',
|
||||
'contact_id' => 6,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Domain', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function domain_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 3,
|
||||
'values' => array(
|
||||
'3' => array(
|
||||
'id' => '3',
|
||||
'name' => 'A-team domain',
|
||||
'description' => 'domain of chaos',
|
||||
'config_backend' => '',
|
||||
'contact_id' => '6',
|
||||
'locales' => '',
|
||||
'locale_custom_strings' => '',
|
||||
'domain_version' => '4.2',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreate"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/DomainTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
124
sites/all/modules/civicrm/api/v3/examples/Domain/Get.php
Normal file
124
sites/all/modules/civicrm/api/v3/examples/Domain/Get.php
Normal file
|
@ -0,0 +1,124 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Domain.get API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function domain_get_example() {
|
||||
$params = array(
|
||||
'sequential' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Domain', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function domain_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 2,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '1',
|
||||
'name' => 'Default Domain Name',
|
||||
'version' => '4.6.alpha1',
|
||||
'contact_id' => '3',
|
||||
'locale_custom_strings' => 'a:1:{s:5:\"en_US\";a:0:{}}',
|
||||
'domain_email' => 'my@email.com',
|
||||
'domain_phone' => array(
|
||||
'phone_type' => 'Phone',
|
||||
'phone' => '456-456',
|
||||
),
|
||||
'domain_address' => array(
|
||||
'street_address' => '45 Penny Lane',
|
||||
'supplemental_address_1' => '',
|
||||
'supplemental_address_2' => '',
|
||||
'supplemental_address_3' => '',
|
||||
'city' => '',
|
||||
'state_province_id' => '',
|
||||
'postal_code' => '',
|
||||
'country_id' => '',
|
||||
'geo_code_1' => '',
|
||||
'geo_code_2' => '',
|
||||
),
|
||||
'from_email' => 'info@EXAMPLE.ORG',
|
||||
'from_name' => 'FIXME',
|
||||
'domain_version' => '4.6.alpha1',
|
||||
),
|
||||
'1' => array(
|
||||
'id' => '2',
|
||||
'name' => 'Second Domain',
|
||||
'version' => '4.6.alpha1',
|
||||
'contact_id' => '2',
|
||||
'domain_email' => '\"Domain Email\" <domainemail2@example.org>',
|
||||
'domain_phone' => array(
|
||||
'phone_type' => 'Phone',
|
||||
'phone' => '204 555-1001',
|
||||
),
|
||||
'domain_address' => array(
|
||||
'street_address' => '15 Main St',
|
||||
'supplemental_address_1' => '',
|
||||
'supplemental_address_2' => '',
|
||||
'supplemental_address_3' => '',
|
||||
'city' => 'Collinsville',
|
||||
'state_province_id' => '1006',
|
||||
'postal_code' => '6022',
|
||||
'country_id' => '1228',
|
||||
'geo_code_1' => '41.8328',
|
||||
'geo_code_2' => '-72.9253',
|
||||
),
|
||||
'from_email' => 'info@EXAMPLE.ORG',
|
||||
'from_name' => 'FIXME',
|
||||
'domain_version' => '4.6.alpha1',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGet"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/DomainTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
89
sites/all/modules/civicrm/api/v3/examples/Email/Create.php
Normal file
89
sites/all/modules/civicrm/api/v3/examples/Email/Create.php
Normal file
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Email.create API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function email_create_example() {
|
||||
$params = array(
|
||||
'contact_id' => 3,
|
||||
'location_type_id' => 6,
|
||||
'email' => 'api@a-team.com',
|
||||
'is_primary' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Email', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function email_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 3,
|
||||
'values' => array(
|
||||
'3' => array(
|
||||
'id' => '3',
|
||||
'contact_id' => '3',
|
||||
'location_type_id' => '6',
|
||||
'email' => 'api@a-team.com',
|
||||
'is_primary' => '1',
|
||||
'is_billing' => '',
|
||||
'on_hold' => '',
|
||||
'is_bulkmail' => '',
|
||||
'hold_date' => '',
|
||||
'reset_date' => '',
|
||||
'signature_text' => '',
|
||||
'signature_html' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateEmail"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EmailTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
70
sites/all/modules/civicrm/api/v3/examples/Email/Delete.php
Normal file
70
sites/all/modules/civicrm/api/v3/examples/Email/Delete.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Email.delete API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function email_delete_example() {
|
||||
$params = array(
|
||||
'id' => 11,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Email', 'delete', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function email_delete_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'values' => 1,
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testDeleteEmail"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EmailTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
168
sites/all/modules/civicrm/api/v3/examples/Email/Replace.php
Normal file
168
sites/all/modules/civicrm/api/v3/examples/Email/Replace.php
Normal file
|
@ -0,0 +1,168 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Email.replace API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function email_replace_example() {
|
||||
$params = array(
|
||||
'contact_id' => 9,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'location_type_id' => 18,
|
||||
'email' => '1-1@example.com',
|
||||
'is_primary' => 1,
|
||||
),
|
||||
'1' => array(
|
||||
'location_type_id' => 18,
|
||||
'email' => '1-2@example.com',
|
||||
'is_primary' => 0,
|
||||
),
|
||||
'2' => array(
|
||||
'location_type_id' => 18,
|
||||
'email' => '1-3@example.com',
|
||||
'is_primary' => 0,
|
||||
),
|
||||
'3' => array(
|
||||
'location_type_id' => 19,
|
||||
'email' => '2-1@example.com',
|
||||
'is_primary' => 0,
|
||||
),
|
||||
'4' => array(
|
||||
'location_type_id' => 19,
|
||||
'email' => '2-2@example.com',
|
||||
'is_primary' => 0,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Email', 'replace', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function email_replace_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 5,
|
||||
'values' => array(
|
||||
'12' => array(
|
||||
'id' => '12',
|
||||
'contact_id' => '9',
|
||||
'location_type_id' => '18',
|
||||
'email' => '1-1@example.com',
|
||||
'is_primary' => '1',
|
||||
'is_billing' => '',
|
||||
'on_hold' => '',
|
||||
'is_bulkmail' => '',
|
||||
'hold_date' => '',
|
||||
'reset_date' => '',
|
||||
'signature_text' => '',
|
||||
'signature_html' => '',
|
||||
),
|
||||
'13' => array(
|
||||
'id' => '13',
|
||||
'contact_id' => '9',
|
||||
'location_type_id' => '18',
|
||||
'email' => '1-2@example.com',
|
||||
'is_primary' => 0,
|
||||
'is_billing' => '',
|
||||
'on_hold' => '',
|
||||
'is_bulkmail' => '',
|
||||
'hold_date' => '',
|
||||
'reset_date' => '',
|
||||
'signature_text' => '',
|
||||
'signature_html' => '',
|
||||
),
|
||||
'14' => array(
|
||||
'id' => '14',
|
||||
'contact_id' => '9',
|
||||
'location_type_id' => '18',
|
||||
'email' => '1-3@example.com',
|
||||
'is_primary' => 0,
|
||||
'is_billing' => '',
|
||||
'on_hold' => '',
|
||||
'is_bulkmail' => '',
|
||||
'hold_date' => '',
|
||||
'reset_date' => '',
|
||||
'signature_text' => '',
|
||||
'signature_html' => '',
|
||||
),
|
||||
'15' => array(
|
||||
'id' => '15',
|
||||
'contact_id' => '9',
|
||||
'location_type_id' => '19',
|
||||
'email' => '2-1@example.com',
|
||||
'is_primary' => 0,
|
||||
'is_billing' => '',
|
||||
'on_hold' => '',
|
||||
'is_bulkmail' => '',
|
||||
'hold_date' => '',
|
||||
'reset_date' => '',
|
||||
'signature_text' => '',
|
||||
'signature_html' => '',
|
||||
),
|
||||
'16' => array(
|
||||
'id' => '16',
|
||||
'contact_id' => '9',
|
||||
'location_type_id' => '19',
|
||||
'email' => '2-2@example.com',
|
||||
'is_primary' => 0,
|
||||
'is_billing' => '',
|
||||
'on_hold' => '',
|
||||
'is_bulkmail' => '',
|
||||
'hold_date' => '',
|
||||
'reset_date' => '',
|
||||
'signature_text' => '',
|
||||
'signature_html' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testReplaceEmail"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EmailTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the EntityBatch.create API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function entity_batch_create_example() {
|
||||
$params = array(
|
||||
'entity_id' => 1,
|
||||
'batch_id' => 1,
|
||||
'entity_table' => 'civicrm_financial_trxn',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('EntityBatch', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function entity_batch_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'entity_table' => 'civicrm_financial_trxn',
|
||||
'entity_id' => '1',
|
||||
'batch_id' => '1',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateEntityBatch"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EntityBatchTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the EntityBatch.delete API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function entity_batch_delete_example() {
|
||||
$params = array(
|
||||
'id' => 3,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('EntityBatch', 'delete', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function entity_batch_delete_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'values' => 1,
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testDeleteEntityBatch"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EntityBatchTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the EntityBatch.get API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function entity_batch_get_example() {
|
||||
$params = array(
|
||||
'entity_id' => 2,
|
||||
'batch_id' => 2,
|
||||
'entity_table' => 'civicrm_financial_trxn',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('EntityBatch', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function entity_batch_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 2,
|
||||
'values' => array(
|
||||
'2' => array(
|
||||
'id' => '2',
|
||||
'entity_table' => 'civicrm_financial_trxn',
|
||||
'entity_id' => '2',
|
||||
'batch_id' => '2',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetEntityBatch"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EntityBatchTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the EntityTag.create API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function entity_tag_create_example() {
|
||||
$params = array(
|
||||
'contact_id' => 3,
|
||||
'tag_id' => '6',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('EntityTag', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'error' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function entity_tag_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'not_added' => 0,
|
||||
'added' => 1,
|
||||
'total_count' => 1,
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testIndividualEntityTagGet"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EntityTagTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the EntityTag.delete API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function entity_tag_delete_example() {
|
||||
$params = array(
|
||||
'contact_id_h' => 31,
|
||||
'tag_id' => '15',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('EntityTag', 'delete', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function entity_tag_delete_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'not_removed' => 0,
|
||||
'removed' => 1,
|
||||
'total_count' => 1,
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testEntityTagDeleteHH"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EntityTagTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
78
sites/all/modules/civicrm/api/v3/examples/EntityTag/Get.php
Normal file
78
sites/all/modules/civicrm/api/v3/examples/EntityTag/Get.php
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the EntityTag.get API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function entity_tag_get_example() {
|
||||
$params = array(
|
||||
'contact_id' => 15,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('EntityTag', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function entity_tag_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 5,
|
||||
'values' => array(
|
||||
'5' => array(
|
||||
'id' => '5',
|
||||
'entity_table' => 'civicrm_contact',
|
||||
'entity_id' => '15',
|
||||
'tag_id' => '10',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testIndividualEntityTagGet"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EntityTagTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Event.get API.
|
||||
*
|
||||
* Demonstrates get with Contact Reference Custom Field.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function event_get_example() {
|
||||
$params = array(
|
||||
'return.custom_2' => 1,
|
||||
'custom_2' => 4,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Event', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function event_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 3,
|
||||
'values' => array(
|
||||
'3' => array(
|
||||
'id' => '3',
|
||||
'title' => 'My test event.',
|
||||
'event_title' => 'My test event.',
|
||||
'event_description' => '',
|
||||
'event_type_id' => '1',
|
||||
'participant_listing_id' => 0,
|
||||
'is_public' => '1',
|
||||
'start_date' => '2013-07-29 00:00:00',
|
||||
'event_start_date' => '2013-07-29 00:00:00',
|
||||
'event_end_date' => '',
|
||||
'is_online_registration' => 0,
|
||||
'is_monetary' => 0,
|
||||
'is_map' => 0,
|
||||
'is_active' => '1',
|
||||
'is_show_location' => '1',
|
||||
'default_role_id' => '1',
|
||||
'is_email_confirm' => 0,
|
||||
'is_pay_later' => 0,
|
||||
'is_partial_payment' => 0,
|
||||
'is_multiple_registrations' => 0,
|
||||
'max_additional_participants' => 0,
|
||||
'allow_same_participant_emails' => 0,
|
||||
'allow_selfcancelxfer' => 0,
|
||||
'selfcancelxfer_time' => 0,
|
||||
'is_template' => 0,
|
||||
'created_date' => '2013-07-28 08:49:19',
|
||||
'is_share' => '1',
|
||||
'is_confirm_enabled' => '1',
|
||||
'is_billing_required' => 0,
|
||||
'custom_1' => 'defaultValue',
|
||||
'custom_2_id' => '4',
|
||||
'custom_2' => 'Contact, Test',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testEventGetCustomContactRefFieldCRM16036"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EventTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
157
sites/all/modules/civicrm/api/v3/examples/Event/Create.php
Normal file
157
sites/all/modules/civicrm/api/v3/examples/Event/Create.php
Normal file
|
@ -0,0 +1,157 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Event.create API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function event_create_example() {
|
||||
$params = array(
|
||||
'title' => 'Annual CiviCRM meet',
|
||||
'summary' => 'If you have any CiviCRM realted issues or want to track where CiviCRM is heading, Sign up now',
|
||||
'description' => 'This event is intended to give brief idea about progess of CiviCRM and giving solutions to common user issues',
|
||||
'event_type_id' => 1,
|
||||
'is_public' => 1,
|
||||
'start_date' => 20081021,
|
||||
'end_date' => 20081023,
|
||||
'is_online_registration' => 1,
|
||||
'registration_start_date' => 20080601,
|
||||
'registration_end_date' => '2008-10-15',
|
||||
'max_participants' => 100,
|
||||
'event_full_text' => 'Sorry! We are already full',
|
||||
'is_monetary' => 0,
|
||||
'is_active' => 1,
|
||||
'is_show_location' => 0,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Event', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function event_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 3,
|
||||
'values' => array(
|
||||
'3' => array(
|
||||
'id' => '3',
|
||||
'title' => 'Annual CiviCRM meet',
|
||||
'summary' => 'If you have any CiviCRM realted issues or want to track where CiviCRM is heading, Sign up now',
|
||||
'description' => 'This event is intended to give brief idea about progess of CiviCRM and giving solutions to common user issues',
|
||||
'event_type_id' => '1',
|
||||
'participant_listing_id' => '',
|
||||
'is_public' => '1',
|
||||
'start_date' => '2013-07-29 00:00:00',
|
||||
'end_date' => '2013-08-04 00:00:00',
|
||||
'is_online_registration' => '1',
|
||||
'registration_link_text' => '',
|
||||
'registration_start_date' => '20080601000000',
|
||||
'registration_end_date' => '20081015000000',
|
||||
'max_participants' => '100',
|
||||
'event_full_text' => 'Sorry! We are already full',
|
||||
'is_monetary' => 0,
|
||||
'financial_type_id' => '',
|
||||
'payment_processor' => '',
|
||||
'is_map' => '',
|
||||
'is_active' => '1',
|
||||
'fee_label' => '',
|
||||
'is_show_location' => 0,
|
||||
'loc_block_id' => '',
|
||||
'default_role_id' => '',
|
||||
'intro_text' => '',
|
||||
'footer_text' => '',
|
||||
'confirm_title' => '',
|
||||
'confirm_text' => '',
|
||||
'confirm_footer_text' => '',
|
||||
'is_email_confirm' => '',
|
||||
'confirm_email_text' => '',
|
||||
'confirm_from_name' => '',
|
||||
'confirm_from_email' => '',
|
||||
'cc_confirm' => '',
|
||||
'bcc_confirm' => '',
|
||||
'default_fee_id' => '',
|
||||
'default_discount_fee_id' => '',
|
||||
'thankyou_title' => '',
|
||||
'thankyou_text' => '',
|
||||
'thankyou_footer_text' => '',
|
||||
'is_pay_later' => '',
|
||||
'pay_later_text' => '',
|
||||
'pay_later_receipt' => '',
|
||||
'is_partial_payment' => '',
|
||||
'initial_amount_label' => '',
|
||||
'initial_amount_help_text' => '',
|
||||
'min_initial_amount' => '',
|
||||
'is_multiple_registrations' => '',
|
||||
'max_additional_participants' => '',
|
||||
'allow_same_participant_emails' => '',
|
||||
'has_waitlist' => '',
|
||||
'requires_approval' => '',
|
||||
'expiration_time' => '',
|
||||
'allow_selfcancelxfer' => '',
|
||||
'selfcancelxfer_time' => '',
|
||||
'waitlist_text' => '',
|
||||
'approval_req_text' => '',
|
||||
'is_template' => 0,
|
||||
'template_title' => '',
|
||||
'created_id' => '',
|
||||
'created_date' => '2013-07-28 08:49:19',
|
||||
'currency' => '',
|
||||
'campaign_id' => '',
|
||||
'is_share' => '',
|
||||
'is_confirm_enabled' => '',
|
||||
'parent_event_id' => '',
|
||||
'slot_label_id' => '',
|
||||
'dedupe_rule_group_id' => '',
|
||||
'is_billing_required' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testCreateEventSuccess"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EventTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
70
sites/all/modules/civicrm/api/v3/examples/Event/Delete.php
Normal file
70
sites/all/modules/civicrm/api/v3/examples/Event/Delete.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Event.delete API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function event_delete_example() {
|
||||
$params = array(
|
||||
'id' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Event', 'delete', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function event_delete_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'values' => 1,
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testDelete"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EventTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
104
sites/all/modules/civicrm/api/v3/examples/Event/Get.php
Normal file
104
sites/all/modules/civicrm/api/v3/examples/Event/Get.php
Normal file
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Event.get API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function event_get_example() {
|
||||
$params = array(
|
||||
'event_title' => 'Annual CiviCRM meet',
|
||||
'sequential' => TRUE,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Event', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function event_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '1',
|
||||
'title' => 'Annual CiviCRM meet',
|
||||
'event_title' => 'Annual CiviCRM meet',
|
||||
'event_description' => '',
|
||||
'event_type_id' => '1',
|
||||
'participant_listing_id' => 0,
|
||||
'is_public' => '1',
|
||||
'start_date' => '2013-07-29 00:00:00',
|
||||
'event_start_date' => '2013-07-29 00:00:00',
|
||||
'event_end_date' => '',
|
||||
'is_online_registration' => 0,
|
||||
'is_monetary' => 0,
|
||||
'is_map' => 0,
|
||||
'is_active' => '1',
|
||||
'is_show_location' => '1',
|
||||
'default_role_id' => '1',
|
||||
'is_email_confirm' => 0,
|
||||
'is_pay_later' => 0,
|
||||
'is_partial_payment' => 0,
|
||||
'is_multiple_registrations' => 0,
|
||||
'max_additional_participants' => 0,
|
||||
'allow_same_participant_emails' => 0,
|
||||
'allow_selfcancelxfer' => 0,
|
||||
'selfcancelxfer_time' => 0,
|
||||
'is_template' => 0,
|
||||
'created_date' => '2013-07-28 08:49:19',
|
||||
'is_share' => '1',
|
||||
'is_confirm_enabled' => '1',
|
||||
'is_billing_required' => 0,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetEventByEventTitle"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EventTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue