First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
|
@ -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
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue