CRM-13072 Update examples
authoreileen <eileen@fuzion.co.nz>
Sun, 28 Jul 2013 09:58:02 +0000 (21:58 +1200)
committereileen <eileen@fuzion.co.nz>
Sun, 28 Jul 2013 09:58:02 +0000 (21:58 +1200)
233 files changed:
api/v3/examples/Activity/ContactRefCustomField.php
api/v3/examples/Activity/ContactRefCustomFieldGet.php
api/v3/examples/Activity/DateTimeHigh.php
api/v3/examples/Activity/DateTimeLow.php
api/v3/examples/Activity/GetTargetandAssignee.php
api/v3/examples/Activity/ReturnAssigneeContact.php
api/v3/examples/ActivityCreate.php
api/v3/examples/ActivityDelete.php
api/v3/examples/ActivityGet.php
api/v3/examples/ActivityGetfields.php
api/v3/examples/ActivityTypeCreate.php
api/v3/examples/ActivityTypeGet.php
api/v3/examples/Address/AddressLike.php
api/v3/examples/Address/AddressParse.php
api/v3/examples/Address/AddressSort.php
api/v3/examples/AddressCreate.php
api/v3/examples/AddressDelete.php
api/v3/examples/AddressGet.php
api/v3/examples/BatchCreate.php
api/v3/examples/BatchDelete.php
api/v3/examples/BatchGet.php
api/v3/examples/BatchUpdate.php
api/v3/examples/CampaignCreate.php
api/v3/examples/CampaignDelete.php
api/v3/examples/CampaignGet.php
api/v3/examples/ConstantGet.php
api/v3/examples/Contact/APIChainedArray.php
api/v3/examples/Contact/APIChainedArrayFormats.php
api/v3/examples/Contact/APIChainedArrayMultipleCustom.php
api/v3/examples/Contact/APIChainedArrayValuesFromSiblingFunction.php
api/v3/examples/Contact/ChainTwoWebsites.php
api/v3/examples/Contact/ChainTwoWebsitesSyntax2.php
api/v3/examples/Contact/CustomFieldCreate.php
api/v3/examples/Contact/CustomFieldGet.php
api/v3/examples/Contact/CustomFieldGetReturnSyntaxVariation.php
api/v3/examples/Contact/FormatIsSuccess_Fail.php
api/v3/examples/Contact/FormatIsSuccess_True.php
api/v3/examples/Contact/FormatOnlyID.php
api/v3/examples/Contact/FormatSingleValue.php
api/v3/examples/Contact/GetCountContact.php
api/v3/examples/Contact/GetFieldsOptions.php
api/v3/examples/Contact/GetSingleContact.php
api/v3/examples/Contact/GroupFilterUsingContactAPI.php
api/v3/examples/ContactCreate.php
api/v3/examples/ContactDelete.php
api/v3/examples/ContactGet.php
api/v3/examples/ContactGetoptions.php
api/v3/examples/Contribution/ContributionCreateWithNote.php
api/v3/examples/Contribution/ContributionCreateWithSoftCredit.php
api/v3/examples/Contribution/CreateWithNestedLineItems.php
api/v3/examples/ContributionCreate.php
api/v3/examples/ContributionDelete.php
api/v3/examples/ContributionGet.php
api/v3/examples/ContributionPageCreate.php
api/v3/examples/ContributionPageDelete.php
api/v3/examples/ContributionPageGet.php
api/v3/examples/ContributionRecurCreate.php
api/v3/examples/ContributionRecurDelete.php
api/v3/examples/ContributionRecurGet.php
api/v3/examples/ContributionSoftCreate.php
api/v3/examples/ContributionSoftDelete.php
api/v3/examples/ContributionSoftGet.php
api/v3/examples/CustomFieldCreate.php
api/v3/examples/CustomFieldDelete.php
api/v3/examples/CustomGroupCreate.php
api/v3/examples/CustomGroupDelete.php
api/v3/examples/CustomGroupGet.php
api/v3/examples/CustomValue/formatFieldName.php
api/v3/examples/CustomValueCreate.php
api/v3/examples/CustomValueGet.php
api/v3/examples/DomainCreate.php
api/v3/examples/DomainGet.php
api/v3/examples/Email/NestedReplaceEmail.php
api/v3/examples/EmailCreate.php
api/v3/examples/EmailDelete.php
api/v3/examples/EmailReplace.php
api/v3/examples/EntityTagCreate.php
api/v3/examples/EntityTagDelete.php
api/v3/examples/EntityTagGet.php
api/v3/examples/Event/IsCurrentOption.php
api/v3/examples/Event/IsFullOption.php
api/v3/examples/EventCreate.php
api/v3/examples/EventDelete.php
api/v3/examples/EventGet.php
api/v3/examples/EventUpdate.php [deleted file]
api/v3/examples/GrantCreate.php
api/v3/examples/GrantDelete.php
api/v3/examples/GrantGet.php
api/v3/examples/Group/getfields.php
api/v3/examples/GroupContact.php [deleted file]
api/v3/examples/GroupContact/GetWithGroupID.php
api/v3/examples/GroupContactCreate.php
api/v3/examples/GroupContactDelete.php
api/v3/examples/GroupContactGet.php
api/v3/examples/GroupGet.php
api/v3/examples/GroupNestingCreate.php
api/v3/examples/GroupNestingDelete.php
api/v3/examples/GroupNestingGet.php
api/v3/examples/GroupOrganizationCreate.php
api/v3/examples/GroupOrganizationDelete.php
api/v3/examples/GroupOrganizationGet.php
api/v3/examples/ImCreate.php
api/v3/examples/ImDelete.php
api/v3/examples/ImGet.php
api/v3/examples/JobCreate.php
api/v3/examples/JobDelete.php
api/v3/examples/LineItemCreate.php
api/v3/examples/LineItemDelete.php
api/v3/examples/LineItemGet.php
api/v3/examples/LocBlockCreate.php
api/v3/examples/LocBlockCreateEntities.php
api/v3/examples/LocBlockGet.php
api/v3/examples/MailSettings/ChainedGetDelete.php
api/v3/examples/MailSettingsCreate.php
api/v3/examples/MailSettingsDelete.php
api/v3/examples/MailSettingsGet.php
api/v3/examples/MailingCreate.php
api/v3/examples/MailingDelete.php [moved from api/v3/examples/ActivityTypeDelete.php with 55% similarity]
api/v3/examples/MailingGroupSubscribe.php
api/v3/examples/Membership/filterIsCurrent.php
api/v3/examples/MembershipCreate.php
api/v3/examples/MembershipDelete.php
api/v3/examples/MembershipGet.php
api/v3/examples/MembershipPaymentCreate.php
api/v3/examples/MembershipPaymentGet.php
api/v3/examples/MembershipStatusCreate.php
api/v3/examples/MembershipStatusGet.php
api/v3/examples/MembershipTypeCreate.php
api/v3/examples/MembershipTypeDelete.php
api/v3/examples/MembershipTypeGet.php
api/v3/examples/MembershipUpdate.php
api/v3/examples/NoteCreate.php
api/v3/examples/NoteDelete.php
api/v3/examples/NoteGet.php
api/v3/examples/OptionGroupCreate.php
api/v3/examples/OptionGroupDelete.php
api/v3/examples/OptionGroupGet.php
api/v3/examples/OptionValue/SortOption.php
api/v3/examples/OptionValueGet.php
api/v3/examples/Participant/CreateParticipantPayment.php
api/v3/examples/Participant/NestedDelete.php
api/v3/examples/Participant/NestedEventGet.php
api/v3/examples/ParticipantCreate.php
api/v3/examples/ParticipantGet.php
api/v3/examples/ParticipantPaymentCreate.php
api/v3/examples/ParticipantPaymentDelete.php
api/v3/examples/ParticipantPaymentGet.php
api/v3/examples/ParticipantStatusTypeCreate.php
api/v3/examples/ParticipantStatusTypeDelete.php
api/v3/examples/ParticipantStatusTypeGet.php
api/v3/examples/PaymentProcessorCreate.php
api/v3/examples/PaymentProcessorDelete.php
api/v3/examples/PaymentProcessorTypeCreate.php
api/v3/examples/PaymentProcessorTypeDelete.php
api/v3/examples/PhoneCreate.php
api/v3/examples/PhoneDelete.php
api/v3/examples/PhoneGet.php
api/v3/examples/Pledge/GetFilterHighDate.php
api/v3/examples/PledgeCreate.php
api/v3/examples/PledgeDelete.php
api/v3/examples/PledgeGet.php
api/v3/examples/PledgePaymentCreate.php
api/v3/examples/PledgePaymentDelete.php
api/v3/examples/PledgePaymentGet.php
api/v3/examples/PledgePaymentUpdate.php
api/v3/examples/PriceFieldCreate.php
api/v3/examples/PriceFieldDelete.php
api/v3/examples/PriceFieldGet.php
api/v3/examples/PriceFieldValueCreate.php
api/v3/examples/PriceFieldValueDelete.php
api/v3/examples/PriceFieldValueGet.php
api/v3/examples/PriceSetCreate.php
api/v3/examples/PriceSetDelete.php
api/v3/examples/PriceSetGet.php
api/v3/examples/PriceSetSet.php
api/v3/examples/ProfileApply.php
api/v3/examples/ProfileGet.php
api/v3/examples/ProfileSet.php
api/v3/examples/Relationship/BetweenRelationshipType.php
api/v3/examples/Relationship/INRelationshipType.php
api/v3/examples/Relationship/NotBetweenRelationshipType.php
api/v3/examples/Relationship/NotInRelationshipType.php
api/v3/examples/Relationship/filterIsCurrent.php
api/v3/examples/RelationshipCreate.php
api/v3/examples/RelationshipDelete.php
api/v3/examples/RelationshipGet.php
api/v3/examples/RelationshipTypeCreate.php
api/v3/examples/RelationshipTypeDelete.php
api/v3/examples/Setting/CreateAllDomains.php
api/v3/examples/Setting/CreateSettingCurrentDomain.php
api/v3/examples/Setting/CreateSpecifiedDomains.php
api/v3/examples/Setting/GetAllDomains.php
api/v3/examples/Setting/GetDefaults.php
api/v3/examples/Setting/GetSettingCurrentDomain.php
api/v3/examples/Setting/GetSpecifiedDomains.php
api/v3/examples/SettingCreate.php
api/v3/examples/SettingGet.php
api/v3/examples/SettingGetValue.php
api/v3/examples/SettingGetfields.php
api/v3/examples/SettingRevert.php
api/v3/examples/Survey/ChainedGetDelete.php
api/v3/examples/SurveyCreate.php
api/v3/examples/SurveyDelete.php
api/v3/examples/SurveyGet.php
api/v3/examples/SurveyRespondantGet.php
api/v3/examples/System/Flush.php
api/v3/examples/Tag/getReturnArray.php
api/v3/examples/TagCreate.php
api/v3/examples/TagDelete.php
api/v3/examples/TagGet.php
api/v3/examples/TagGetfields.php [new file with mode: 0644]
api/v3/examples/UFFieldCreate.php
api/v3/examples/UFFieldDelete.php
api/v3/examples/UFFieldGet.php
api/v3/examples/UFFieldReplace.php
api/v3/examples/UFGroupCreate.php
api/v3/examples/UFGroupDelete.php
api/v3/examples/UFGroupGet.php
api/v3/examples/UFJoinCreate.php
api/v3/examples/UFJoinGet.php
api/v3/examples/UFMatchGet.php
api/v3/examples/WebsiteCreate.php
api/v3/examples/WebsiteDelete.php
api/v3/examples/WebsiteGet.php
api/v3/utils.php
tests/phpunit/CiviTest/CiviUnitTestCase.php
tests/phpunit/api/v3/ContactTest.php
tests/phpunit/api/v3/CustomFieldTest.php
tests/phpunit/api/v3/CustomValueTest.php
tests/phpunit/api/v3/EntityTagTest.php
tests/phpunit/api/v3/EventTest.php
tests/phpunit/api/v3/TagTest.php
tests/templates/documentFunction.tpl

index 01df6b00ba09b64dbd205517fe83189f585bc2ae..812322f37b74e8edecbc5b9bbbad7d5b17ea8a63 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
- demonstrates create with Contact Reference Custom Field
+/**
+ * Test Generated example of using activity create API
+ * demonstrates create with Contact Reference Custom Field *
  */
 function activity_create_example(){
 $params = array(
@@ -14,16 +14,24 @@ $params = array(
   'duration' => 120,
   'location' => 'Pensulvania',
   'details' => 'a test activity',
-  'version' => 3,
   'custom_2' => '17',
 );
 
-  $result = civicrm_api( 'activity','create',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function activity_create_expectedresult(){
@@ -63,7 +71,7 @@ function activity_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index cb43f90574d6e02cd23befeb8320ea9e842e3ba7..fb684c699243abc5d2ffeca2edacba87ac77ca42 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
- Get with Contact Ref Custom Field
+/**
+ * Test Generated example of using activity create API
+ * Get with Contact Ref Custom Field *
  */
 function activity_create_example(){
 $params = array(
@@ -14,16 +14,24 @@ $params = array(
   'duration' => 120,
   'location' => 'Pensulvania',
   'details' => 'a test activity',
-  'version' => 3,
   'custom_2' => '17',
 );
 
-  $result = civicrm_api( 'activity','create',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function activity_create_expectedresult(){
@@ -57,7 +65,7 @@ function activity_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 31fa3ab788f09da0316f97c2035b744000180907..e5b1d9840281af75c0a7bac7d82746eb3fcc5131 100644 (file)
@@ -1,22 +1,30 @@
 <?php
-
-/*
- demonstrates _high filter (at time of writing doesn't work if contact_id is set
+/**
+ * Test Generated example of using activity get API
+ * demonstrates _high filter (at time of writing doesn't work if contact_id is set *
  */
 function activity_get_example(){
 $params = array(
   'source_contact_id' => 17,
-  'version' => 3,
   'filter.activity_date_time_high' => '20120101000000',
   'sequential' => 1,
 );
 
-  $result = civicrm_api( 'activity','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function activity_get_expectedresult(){
@@ -46,7 +54,7 @@ function activity_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index a15ded61827184fdb68be1a5853a7a51e8bca90d..06112d8e66d2416d4cdb1caa52634ba87b22e7c7 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
- demonstrates _low filter (at time of writing doesn't work if contact_id is set
+/**
+ * Test Generated example of using activity get API
+ * demonstrates _low filter (at time of writing doesn't work if contact_id is set *
  */
 function activity_get_example(){
 $params = array(
-  'version' => 3,
   'filter.activity_date_time_low' => '20120101000000',
   'sequential' => 1,
 );
 
-  $result = civicrm_api( 'activity','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function activity_get_expectedresult(){
@@ -45,7 +53,7 @@ function activity_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index f19a5719d9cf21bf0d1ac7378628230d4ccb88cd..8b83ea741d7b7ff1089015d8fbd5dbb9142a4ef6 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
- Example demonstrates setting & retrieving the target & source
+/**
+ * Test Generated example of using activity  API
+ * Example demonstrates setting & retrieving the target & source *
  */
 function activity__example(){
 $params = array(
@@ -13,18 +13,26 @@ $params = array(
   'details' => 'a test activity',
   'status_id' => 1,
   'activity_type_id' => 1,
-  'version' => 3,
   'priority_id' => 1,
   'target_contact_id' => 17,
   'assignee_contact_id' => 17,
 );
 
-  $result = civicrm_api( 'activity','',$params );
+try{
+  $result = civicrm_api3('activity', '', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function activity__expectedresult(){
@@ -64,7 +72,7 @@ function activity__expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index a69aea08ad7d7eafb6188bf99c75ee0d57cda5c8..dd5f9042398dce67d7450f58a744b56cd5f9a079 100644 (file)
@@ -1,12 +1,11 @@
 <?php
-
-/*
- Function demonstrates getting asignee_contact_id & using it to get the contact
+/**
+ * Test Generated example of using activity get API
+ * Function demonstrates getting asignee_contact_id & using it to get the contact *
  */
 function activity_get_example(){
 $params = array(
   'activity_id' => 1,
-  'version' => 3,
   'sequential' => 1,
   'return.assignee_contact_id' => 1,
   'api.contact.get' => array(
@@ -14,12 +13,21 @@ $params = array(
     ),
 );
 
-  $result = civicrm_api( 'activity','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function activity_get_expectedresult(){
@@ -117,7 +125,7 @@ function activity_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 3c58cdf409d07013fd61bbc32e8385c0f64b572c..38c3dd6ca1da43dff1063d14c929c5cdeef7f192 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using activity create API
+ * *
  */
 function activity_create_example(){
 $params = array(
@@ -14,16 +14,24 @@ $params = array(
   'duration' => 120,
   'location' => 'Pensulvania',
   'details' => 'a test activity',
-  'version' => 3,
   'custom_1' => 'custom string',
 );
 
-  $result = civicrm_api( 'activity','create',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function activity_create_expectedresult(){
@@ -63,7 +71,7 @@ function activity_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 1f01607de8a9719d359ce8b619a042364fff6dc5..19b198d1dc07615fb69d558805724cc75be38a46 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using activity delete API
+ * *
  */
 function activity_delete_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'activity','delete',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function activity_delete_expectedresult(){
@@ -26,7 +34,7 @@ function activity_delete_expectedresult(){
   'values' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 81f92c4e69a83fc91a4ad51d0fb2944c7f538204..ca2aec0e3000edff982ec6ada4cebb2e3c07c128 100644 (file)
@@ -1,23 +1,31 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using activity get API
+ * *
  */
 function activity_get_example(){
 $params = array(
   'contact_id' => 17,
   'activity_type_id' => '46',
-  'version' => 3,
   'sequential' => 1,
   'return.custom_1' => 1,
 );
 
-  $result = civicrm_api( 'activity','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function activity_get_expectedresult(){
@@ -45,7 +53,7 @@ function activity_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index ae9f6996ed6c9a47568974518795e5f9bff7cd80..7e493fb8cfe4b03b1e561fc7ef4828f6ae491605 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using activity getfields API
+ * *
  */
 function activity_getfields_example(){
 $params = array(
-  'version' => 3,
   'action' => 'create',
 );
 
-  $result = civicrm_api( 'activity','getfields',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function activity_getfields_expectedresult(){
@@ -262,7 +270,7 @@ function activity_getfields_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 9ae09772d13d4eba85965475afebe10d20612a42..1f06df0f0a774df767f69eab3460410c2084eab6 100644 (file)
@@ -1,25 +1,33 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using activity_type create API
+ * *
  */
 function activity_type_create_example(){
 $params = array(
   'weight' => '2',
   'label' => 'send out letters',
-  'version' => 3,
   'filter' => 0,
   'is_active' => 1,
   'is_optgroup' => 1,
   'is_default' => 0,
 );
 
-  $result = civicrm_api( 'activity_type','create',$params );
+try{
+  $result = civicrm_api3('activity_type', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function activity_type_create_expectedresult(){
@@ -51,7 +59,7 @@ function activity_type_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 250250e7f2bc9534824ee2f9a0c788e956cf1ff6..ea32e955cca3e0526bc48a1d1cd3eb47850a2faf 100644 (file)
@@ -1,19 +1,26 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using activity_type get API
+ * *
  */
 function activity_type_get_example(){
-$params = array(
-  'version' => 3,
-);
+$params = array();
 
-  $result = civicrm_api( 'activity_type','get',$params );
+try{
+  $result = civicrm_api3('activity_type', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function activity_type_get_expectedresult(){
@@ -71,7 +78,7 @@ function activity_type_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 26bfd074df36fe736733d97aacce7f0130593b30..33c263ee08b59ddd5cc2e08de3bcdb4fa86e59ff 100644 (file)
@@ -1,23 +1,31 @@
 <?php
-
-/*
- Demonstrates Use of Like
+/**
+ * Test Generated example of using address get API
+ * Demonstrates Use of Like *
  */
 function address_get_example(){
 $params = array(
   'street_address' => array(
       'LIKE' => '%mb%',
     ),
-  'version' => 3,
   'sequential' => 1,
 );
 
-  $result = civicrm_api( 'address','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function address_get_expectedresult(){
@@ -45,7 +53,7 @@ function address_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 192e08894fb1333b0de4299d4c4f32e083749592..8fe23d354e09b96f84bb4d671ef8b83af2efca29 100644 (file)
@@ -1,23 +1,31 @@
 <?php
-
-/*
- Demonstrates Use of address parsing param
+/**
+ * Test Generated example of using address create API
+ * Demonstrates Use of address parsing param *
  */
 function address_create_example(){
 $params = array(
-  'version' => 3,
   'street_parsing' => 1,
   'street_address' => '54A Excelsior Ave. Apt 1C',
   'location_type_id' => 7,
   'contact_id' => 4,
 );
 
-  $result = civicrm_api( 'address','create',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function address_create_expectedresult(){
@@ -44,7 +52,7 @@ function address_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 56e54f582c84f3b2937edca6f08b6f950ac0d09f..15a83157b46576f093d509eab8fd9a39883b5f1e 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
- Demonstrates Use of sort filter
+/**
+ * Test Generated example of using address get API
+ * Demonstrates Use of sort filter *
  */
 function address_get_example(){
 $params = array(
@@ -9,16 +9,24 @@ $params = array(
       'sort' => 'street_address DESC',
       'limit' => 2,
     ),
-  'version' => 3,
   'sequential' => 1,
 );
 
-  $result = civicrm_api( 'address','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function address_get_expectedresult(){
@@ -64,7 +72,7 @@ function address_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 4a5a6480076b968513dde8d81686064092127209..51fd3683d4ce3560e94ae11275bf3d464abbbb5e 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using address create API
+ * *
  */
 function address_create_example(){
 $params = array(
@@ -14,15 +14,23 @@ $params = array(
   'country_id' => '1152',
   'city' => 'Brummen',
   'is_primary' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'address','create',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function address_create_expectedresult(){
@@ -50,7 +58,7 @@ function address_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index c1e950775677cc859dc0777c10505e62b584a8e3..49e701041590442d5a72a44461e76ceb8400d71a 100644 (file)
@@ -1,28 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using address delete API
+ * *
  */
 function address_delete_example(){
 $params = array(
-  'contact_id' => 8,
-  'location_type_id' => 11,
-  'street_name' => 'Ambachtstraat',
-  'street_number' => '23',
-  'street_address' => 'Ambachtstraat 23',
-  'postal_code' => '6971 BN',
-  'country_id' => '1152',
-  'city' => 'Brummen',
-  'is_primary' => 1,
-  'version' => 3,
+  'id' => 6,
 );
 
-  $result = civicrm_api( 'address','delete',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function address_delete_expectedresult(){
@@ -34,7 +34,7 @@ function address_delete_expectedresult(){
   'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 502aa18115c419a648e5f9e7493ea6fa9c8f3e3d..9db78400609e243beb26bc4cf71e03cd40eb5df6 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using address get API
+ * *
  */
 function address_get_example(){
 $params = array(
   'contact_id' => 9,
   'street_name' => 'Ambachtstraat',
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'address','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function address_get_expectedresult(){
@@ -43,7 +51,7 @@ function address_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 6b83ee7df967853d648316daa57355f51245c7b4..55e2297d3aeb88fd7fc816de7a20addf36cb4a55 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using batch create API
+ * *
  */
 function batch_create_example(){
 $params = array(
@@ -11,16 +11,23 @@ $params = array(
   'total' => '300.33',
   'item_count' => 3,
   'status_id' => 1,
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'batch','create',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function batch_create_expectedresult(){
@@ -37,7 +44,7 @@ function batch_create_expectedresult(){
           'title' => 'New Batch 03',
           'description' => 'This is description for New Batch 03',
           'created_id' => '',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'modified_id' => '',
           'modified_date' => '2012-11-14 16:02:35',
           'saved_search_id' => '',
@@ -52,7 +59,7 @@ function batch_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 9830a487fbade6ee21ebcf10b5f195bc82306d03..6149e3fcaccbc3a6709ca7c41c5ef5765fcc87b5 100644 (file)
@@ -1,21 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using batch delete API
+ * *
  */
 function batch_delete_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'batch','delete',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function batch_delete_expectedresult(){
@@ -27,7 +34,7 @@ function batch_delete_expectedresult(){
   'values' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 2b5c73702391e0aafd82818266debe9cdb218611..449cf74db499825441dbb0ec21d8a723732eed06 100644 (file)
@@ -1,21 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using batch get API
+ * *
  */
 function batch_get_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'batch','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function batch_get_expectedresult(){
@@ -35,7 +42,7 @@ function batch_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 2b2fa5088918130b6e28a7628fbd56c3591bedfc..109789ce94a07775a4c96930847a3ffc5a3321ad 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using batch update API
+ * *
  */
 function batch_update_example(){
 $params = array(
@@ -11,16 +11,23 @@ $params = array(
   'total' => '400.44',
   'item_count' => 4,
   'id' => 1,
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'batch','update',$params );
+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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function batch_update_expectedresult(){
@@ -37,7 +44,7 @@ function batch_update_expectedresult(){
           'title' => 'New Batch 04',
           'description' => 'This is description for New Batch 04',
           'created_id' => '',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'modified_id' => '',
           'modified_date' => '2012-11-14 16:02:35',
           'saved_search_id' => '',
@@ -52,7 +59,7 @@ function batch_update_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 8fd508ba4b2814c63bd0792d7791456ce60c49b8..e5094280f572157a03a6e8d2aaa14f46fbd96e54 100644 (file)
@@ -1,22 +1,30 @@
 <?php
-
-/*
- Create a campaign - Note use of relative dates here http://www.php.net/manual/en/datetime.formats.relative.php
+/**
+ * Test Generated example of using campaign create API
+ * Create a campaign - Note use of relative dates here http://www.php.net/manual/en/datetime.formats.relative.php *
  */
 function campaign_create_example(){
 $params = array(
-  'version' => 3,
   'title' => 'campaign title',
   'description' => 'Call people, ask for money',
   'created_date' => 'first sat of July 2008',
 );
 
-  $result = civicrm_api( 'campaign','create',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function campaign_create_expectedresult(){
@@ -40,7 +48,7 @@ function campaign_create_expectedresult(){
           'parent_id' => '',
           'is_active' => '',
           'created_id' => '',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'last_modified_id' => '',
           'last_modified_date' => '',
           'goal_general' => '',
@@ -49,7 +57,7 @@ function campaign_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index e929d203278b7f5f2943848054afd9b5c8207ca0..8ae1877d77a48c3ed72b11edeb4db09827719341 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using campaign delete API
+ * *
  */
 function campaign_delete_example(){
 $params = array(
-  'version' => 3,
   'id' => 2,
 );
 
-  $result = civicrm_api( 'campaign','delete',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function campaign_delete_expectedresult(){
@@ -26,7 +34,7 @@ function campaign_delete_expectedresult(){
   'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 5a61b38983cf5a91071a71d7549ef70cab0887f9..2fac41eaae0b2ff40c3124b89510b5793e7eaa3a 100644 (file)
@@ -1,22 +1,30 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using campaign get API
+ * *
  */
 function campaign_get_example(){
 $params = array(
-  'version' => 3,
   'title' => 'campaign title',
   'description' => 'Call people, ask for money',
   'created_date' => 'first sat of July 2008',
 );
 
-  $result = civicrm_api( 'campaign','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function campaign_get_expectedresult(){
@@ -33,12 +41,12 @@ function campaign_get_expectedresult(){
           'title' => 'campaign title',
           'description' => 'Call people, ask for money',
           'is_active' => '1',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 2a2b8fe60ba9e3ddd7e0a67c6b11f80be35f8183..42f6a59b593a4663b65cf8e32402e5aa2cccea7b 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using constant get API
+ * *
  */
 function constant_get_example(){
 $params = array(
   'field' => 'location_type_id',
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'constant','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function constant_get_expectedresult(){
@@ -32,7 +40,7 @@ function constant_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index a14c048fdeccd75a884bd9fae8898bfb2e03b4d6..4436fb8d27df8a0055d266c5b0fde8e41d6714bb 100644 (file)
@@ -1,12 +1,11 @@
 <?php
-
-/*
- /*this demonstrates the usage of chained api functions. In this case no notes or custom fields have been created 
+/**
+ * Test Generated example of using contact get API
+ * /*this demonstrates the usage of chained api functions. In this case no notes or custom fields have been created  *
  */
 function contact_get_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
   'api.website.get' => array(),
   'api.Contribution.get' => array(
       'total_amount' => '120.00',
@@ -15,12 +14,21 @@ $params = array(
   'api.Note.get' => 1,
 );
 
-  $result = civicrm_api( 'contact','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_get_expectedresult(){
@@ -173,7 +181,7 @@ function contact_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 576cbbed3ea9422effcf18521484db3a4debfdfd..02c3231881c3d0d5f69d7759b72e925a4111563c 100644 (file)
@@ -1,13 +1,12 @@
 <?php
-
-/*
- /*this demonstrates the usage of chained api functions. A variety of return formats are used. Note that no notes
-    *custom fields or memberships exist
+/**
+ * Test Generated example of using contact get API
/*this demonstrates the usage of chained api functions. A variety of return formats are used. Note that no notes
+    *custom fields or memberships exist *
  */
 function contact_get_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
   'api.website.getValue' => array(
       'return' => 'url',
     ),
@@ -17,12 +16,21 @@ $params = array(
   'api.Membership.getCount' => array(),
 );
 
-  $result = civicrm_api( 'contact','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_get_expectedresult(){
@@ -108,7 +116,7 @@ function contact_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 320c448a732d747e45abbcda61ee968d35c48407..3409d3538acf421dc8be177008507130717e4a6c 100644 (file)
@@ -1,12 +1,11 @@
 <?php
-
-/*
- /*this demonstrates the usage of chained api functions. A variety of techniques are used
+/**
+ * Test Generated example of using contact get API
+ * /*this demonstrates the usage of chained api functions. A variety of techniques are used *
  */
 function contact_get_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
   'api.website.getValue' => array(
       'return' => 'url',
     ),
@@ -14,12 +13,21 @@ $params = array(
   'api.CustomValue.get' => 1,
 );
 
-  $result = civicrm_api( 'contact','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_get_expectedresult(){
@@ -91,13 +99,13 @@ function contact_get_expectedresult(){
           'api.CustomValue.get' => array(
               'is_error' => 0,
               'version' => 3,
-              'count' => 10,
+              'count' => 8,
               'values' => array(
                   '0' => array(
                       'entity_id' => '1',
                       'latest' => 'value 4',
-                      'id' => '13',
-                      '0' => 'value 4',
+                      'id' => '1',
+                      'entity_table' => 'Contact',
                     ),
                   '1' => array(
                       'entity_table' => 'Contact',
@@ -105,46 +113,41 @@ function contact_get_expectedresult(){
                   '2' => array(
                       'entity_id' => '1',
                       'latest' => 'value 3',
-                      'id' => '14',
+                      'id' => '2',
                       '1' => 'value 2',
+                      'entity_table' => 'Contact',
                       '2' => 'value 3',
                     ),
                   '3' => array(
-                      'entity_table' => 'Contact',
-                    ),
-                  '4' => array(
                       'entity_id' => '1',
                       'latest' => '',
-                      'id' => '15',
+                      'id' => '3',
                       '1' => 'warm beer',
                       '2' => '',
                     ),
-                  '5' => array(
+                  '4' => array(
                       'entity_id' => '1',
                       'latest' => '',
-                      'id' => '16',
+                      'id' => '4',
                       '1' => '',
                       '2' => '',
                     ),
-                  '6' => array(
-                      'entity_table' => 'Contact',
-                    ),
-                  '7' => array(
+                  '5' => array(
                       'entity_id' => '1',
                       'latest' => '',
-                      'id' => '17',
+                      'id' => '5',
                       '1' => '',
                     ),
-                  '8' => array(
+                  '6' => array(
                       'entity_id' => '1',
                       'latest' => 'vegemite',
-                      'id' => '18',
+                      'id' => '6',
                       '1' => 'vegemite',
                     ),
-                  '9' => array(
+                  '7' => array(
                       'entity_id' => '1',
                       'latest' => '',
-                      'id' => '19',
+                      'id' => '7',
                       '1' => '',
                     ),
                 ),
@@ -153,7 +156,7 @@ function contact_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index d1fb46798a63f8ee404b15051d5987a40eb662e3..e303628b40430037cc5cd396c9e829b8ae5fcd74 100644 (file)
@@ -1,12 +1,11 @@
 <?php
-
-/*
- /*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). 
+/**
+ * Test Generated example of using 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).  *
  */
 function contact_create_example(){
 $params = array(
-  'version' => 3,
   'display_name' => 'batman',
   'contact_type' => 'Individual',
   'api.tag.create' => array(
@@ -19,12 +18,21 @@ $params = array(
     ),
 );
 
-  $result = civicrm_api( 'contact','create',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_create_expectedresult(){
@@ -60,8 +68,6 @@ function contact_create_expectedresult(){
           'first_name' => '',
           'middle_name' => '',
           'last_name' => '',
-          'prefix_id' => '',
-          'suffix_id' => '',
           'email_greeting_id' => '1',
           'email_greeting_custom' => '',
           'email_greeting_display' => '',
@@ -81,7 +87,7 @@ function contact_create_expectedresult(){
           'organization_name' => '',
           'sic_code' => '',
           'user_unique_id' => '',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'modified_date' => '2012-11-14 16:02:35',
           'api.tag.create' => 6,
           'api.entity_tag.create' => array(
@@ -94,7 +100,7 @@ function contact_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 3f7afaa34b81b17c3d7af63ac53c955e1d1dbeea..fcc1bacb279a75bb62e6e2b47133e9a9fc9738dd 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
- test demonstrates the syntax to create 2 chained entities
+/**
+ * Test Generated example of using contact create API
+ * test demonstrates the syntax to create 2 chained entities *
  */
 function contact_create_example(){
 $params = array(
@@ -9,7 +9,6 @@ $params = array(
   'last_name' => 'xyz3',
   'contact_type' => 'Individual',
   'email' => 'man3@yahoo.com',
-  'version' => 3,
   'api.contribution.create' => array(
       'receive_date' => '2010-01-01',
       'total_amount' => '100',
@@ -31,12 +30,21 @@ $params = array(
     ),
 );
 
-  $result = civicrm_api( 'contact','create',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_create_expectedresult(){
@@ -72,8 +80,6 @@ function contact_create_expectedresult(){
           'first_name' => 'abc3',
           'middle_name' => '',
           'last_name' => 'xyz3',
-          'prefix_id' => '',
-          'suffix_id' => '',
           'email_greeting_id' => '1',
           'email_greeting_custom' => '',
           'email_greeting_display' => '',
@@ -93,7 +99,7 @@ function contact_create_expectedresult(){
           'organization_name' => '',
           'sic_code' => '',
           'user_unique_id' => '',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'modified_date' => '2012-11-14 16:02:35',
           'api.contribution.create' => array(
               'is_error' => 0,
@@ -166,7 +172,7 @@ function contact_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index a6480efee9165ae4b0ecceb26f1b4df5cc4bd6fe..83acfc5f8ddd3770b4d4b63c68434d3789a5cb04 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
- demonstrates creating two websites as an array
+/**
+ * Test Generated example of using contact create API
+ * demonstrates creating two websites as an array *
  */
 function contact_create_example(){
 $params = array(
@@ -9,7 +9,6 @@ $params = array(
   'last_name' => 'xyz3',
   'contact_type' => 'Individual',
   'email' => 'man3@yahoo.com',
-  'version' => 3,
   'api.contribution.create' => array(
       'receive_date' => '2010-01-01',
       'total_amount' => '100',
@@ -34,12 +33,21 @@ $params = array(
     ),
 );
 
-  $result = civicrm_api( 'contact','create',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_create_expectedresult(){
@@ -75,8 +83,6 @@ function contact_create_expectedresult(){
           'first_name' => 'abc3',
           'middle_name' => '',
           'last_name' => 'xyz3',
-          'prefix_id' => '',
-          'suffix_id' => '',
           'email_greeting_id' => '1',
           'email_greeting_custom' => '',
           'email_greeting_display' => '',
@@ -96,7 +102,7 @@ function contact_create_expectedresult(){
           'organization_name' => '',
           'sic_code' => '',
           'user_unique_id' => '',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'modified_date' => '2012-11-14 16:02:35',
           'api.contribution.create' => array(
               'is_error' => 0,
@@ -171,7 +177,7 @@ function contact_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 6c2442336e075fd5aa1b91f0ce37945258529a24..1e885ef8e61745b913030a5c56546525ab9dcaf5 100644 (file)
@@ -1,23 +1,32 @@
 <?php
-
-/*
- /*this demonstrates setting a custom field through the API 
+/**
+ * Test Generated example of using contact create API
+ * /*this demonstrates setting a custom field through the API  *
  */
 function contact_create_example(){
 $params = array(
   'first_name' => 'abc1',
   'contact_type' => 'Individual',
   'last_name' => 'xyz1',
-  'version' => 3,
   'custom_1' => 'custom string',
+  'version' => 3,
 );
 
-  $result = civicrm_api( 'contact','create',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_create_expectedresult(){
@@ -53,8 +62,6 @@ function contact_create_expectedresult(){
           'first_name' => 'abc1',
           'middle_name' => '',
           'last_name' => 'xyz1',
-          'prefix_id' => '',
-          'suffix_id' => '',
           'email_greeting_id' => '1',
           'email_greeting_custom' => '',
           'email_greeting_display' => '',
@@ -80,7 +87,7 @@ function contact_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 5806b7cb4c29ad3e011ecbdfa2a76fcc0128308f..7076ac73739e9fed188a70387be700d783ba203f 100644 (file)
@@ -1,23 +1,29 @@
 <?php
-
-/*
- /*this demonstrates setting a custom field through the API 
+/**
+ * Test Generated example of using contact get API
+ * /*this demonstrates setting a custom field through the API  *
  */
 function contact_get_example(){
 $params = array(
-  'first_name' => 'abc1',
-  'contact_type' => 'Individual',
-  'last_name' => 'xyz1',
-  'version' => 3,
-  'custom_3' => 'custom string',
+  'return.custom_1' => 1,
+  'id' => 1,
 );
 
-  $result = civicrm_api( 'contact','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_get_expectedresult(){
@@ -30,14 +36,14 @@ function contact_get_expectedresult(){
   'values' => array(
       '1' => array(
           'contact_id' => '1',
-          'civicrm_value_testgetwithcu_3_id' => '1',
-          'custom_3' => 'custom string',
+          'civicrm_value_testgetwithcu_1_id' => '1',
+          'custom_1' => 'custom string',
           'id' => '1',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 3a1e9694ba6a9ef97f6a5d2f00f9db843eedd269..2d69422671caa75029a3db44da163b72276c85c1 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
- /*this demonstrates setting a custom field through the API 
+/**
+ * Test Generated example of using contact get API
+ * /*this demonstrates setting a custom field through the API  *
  */
 function contact_get_example(){
 $params = array(
-  'return' => 'custom_4',
-  'version' => 3,
+  'return' => 'custom_1',
   'id' => 1,
 );
 
-  $result = civicrm_api( 'contact','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_get_expectedresult(){
@@ -28,14 +36,14 @@ function contact_get_expectedresult(){
   'values' => array(
       '1' => array(
           'contact_id' => '1',
-          'civicrm_value_testgetwithcu_4_id' => '1',
-          'custom_4' => 'custom string',
+          'civicrm_value_testgetwithcu_1_id' => '1',
+          'custom_1' => 'custom string',
           'id' => '1',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 481580e94fbc3ba3d2460e7f8df1222e1f641751..8ba618db7e593c8b77d163b4f01b44ec445b1c22 100644 (file)
@@ -1,29 +1,37 @@
 <?php
-
-/*
- 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
+/**
+ * Test Generated example of using 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 *
  */
 function contact_create_example(){
 $params = array(
-  'version' => 3,
   'id' => 500,
   'format.is_success' => 1,
 );
 
-  $result = civicrm_api( 'contact','create',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_create_expectedresult(){
 
   $expectedResult = 0;
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 51ae3d5c10548280f6fd8a698f968e371bcecda2..77b6f35eea7e5a7bc2204b382afae3a0b8b26f78 100644 (file)
@@ -1,29 +1,37 @@
 <?php
-
-/*
- 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
+/**
+ * Test Generated example of using 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 *
  */
 function contact_get_example(){
 $params = array(
-  'version' => 3,
   'id' => 17,
   'format.is_success' => 1,
 );
 
-  $result = civicrm_api( 'contact','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_get_expectedresult(){
 
   $expectedResult = 1;
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index e777c6e940e729c2eecf97f4ab64ca3c34ea9f7e..3acbd4dc3ac347135e9a775d3a825a18fb1e1999 100644 (file)
@@ -1,30 +1,38 @@
 <?php
-
-/*
- This demonstrates use of the 'format.id_only' param.
+/**
+ * Test Generated example of using 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
+    /* it will be ignored if there is not exactly 1 result *
  */
 function contact_get_example(){
 $params = array(
-  'version' => 3,
   'id' => 17,
   'format.only_id' => 1,
 );
 
-  $result = civicrm_api( 'contact','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_get_expectedresult(){
 
   $expectedResult = 17;
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 252829cdde475d94f22bf59248950369b131894d..2e9b14250cbd59b79e2dd9bf6477690891761ab5 100644 (file)
@@ -1,30 +1,38 @@
 <?php
-
-/*
- This demonstrates use of the 'format.single_value' param.
+/**
+ * Test Generated example of using 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
+    /* it will be ignored if there is not exactly 1 result *
  */
 function contact_getvalue_example(){
 $params = array(
-  'version' => 3,
   'id' => 17,
   'return' => 'display_name',
 );
 
-  $result = civicrm_api( 'contact','getvalue',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_getvalue_expectedresult(){
 
   $expectedResult = 'Test Contact';
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index f022c50db15cdc452f887612c28819887090cf9b..d9b8e566e21b8931a766450a4c5288279bf01931 100644 (file)
@@ -1,28 +1,36 @@
 <?php
-
-/*
- /*This demonstrates use of the 'getCount' action
-    /*  This param causes the count of the only function to be returned as an integer
+/**
+ * Test Generated example of using contact get API
/*This demonstrates use of the 'getCount' action
+    /*  This param causes the count of the only function to be returned as an integer *
  */
 function contact_get_example(){
 $params = array(
-  'version' => 3,
   'id' => 17,
 );
 
-  $result = civicrm_api( 'contact','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_get_expectedresult(){
 
-  $expectedResult = '1';
+  $expectedResult = 1;
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index fac0bae4e7eb9524e2ad6c61d0cec7a176e345d7..032ddc9c023b2a50c5ee7b2542aff0e0c27cb430 100644 (file)
@@ -1,23 +1,31 @@
 <?php
-
-/*
- Demonstrate retrieving metadata with custom field options
+/**
+ * Test Generated example of using contact GetFields API
+ * Demonstrate retrieving metadata with custom field options *
  */
 function contact_getfields_example(){
 $params = array(
   'options' => array(
       'get_options' => 'custom_1',
     ),
-  'version' => 3,
   'action' => 'create',
 );
 
-  $result = civicrm_api( 'contact','GetFields',$params );
+try{
+  $result = civicrm_api3('contact', 'GetFields', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_getfields_expectedresult(){
@@ -300,32 +308,6 @@ function contact_getfields_expectedresult(){
           'dataPattern' => '/^\w+(\s\w+)?+$/',
           'export' => true,
         ),
-      'prefix_id' => array(
-          'name' => 'prefix_id',
-          'type' => 1,
-          'title' => 'Individual Prefix',
-          'import' => true,
-          'where' => 'civicrm_contact.prefix_id',
-          'headerPattern' => '/^(prefix|title)/i',
-          'dataPattern' => '/^(mr|ms|mrs|sir|dr)\.?$/i',
-          'export' => true,
-          'pseudoconstant' => array(
-              'optionGroupName' => 'individual_prefix',
-            ),
-        ),
-      'suffix_id' => array(
-          'name' => 'suffix_id',
-          'type' => 1,
-          'title' => 'Individual Suffix',
-          'import' => true,
-          'where' => 'civicrm_contact.suffix_id',
-          'headerPattern' => '/^suffix$/i',
-          'dataPattern' => '/^(sr|jr)\.?|i{2,}$/',
-          'export' => true,
-          'pseudoconstant' => array(
-              'optionGroupName' => 'individual_suffix',
-            ),
-        ),
       'email_greeting_id' => array(
           'name' => 'email_greeting_id',
           'type' => 1,
@@ -521,6 +503,34 @@ function contact_getfields_expectedresult(){
           'export' => true,
           'uniqueName' => 'contact_source',
         ),
+      'prefix_id' => array(
+          'name' => 'prefix_id',
+          'type' => 1,
+          'title' => 'Individual Prefix',
+          'import' => true,
+          'where' => 'civicrm_contact.prefix_id',
+          'headerPattern' => '/^(prefix|title)/i',
+          'dataPattern' => '/^(mr|ms|mrs|sir|dr)\.?$/i',
+          'export' => true,
+          'pseudoconstant' => array(
+              'optionGroupName' => 'individual_prefix',
+            ),
+          'uniqueName' => 'individual_prefix_id',
+        ),
+      'suffix_id' => array(
+          'name' => 'suffix_id',
+          'type' => 1,
+          'title' => 'Individual Suffix',
+          'import' => true,
+          'where' => 'civicrm_contact.suffix_id',
+          'headerPattern' => '/^suffix$/i',
+          'dataPattern' => '/^(sr|jr)\.?|i{2,}$/',
+          'export' => true,
+          'pseudoconstant' => array(
+              'optionGroupName' => 'individual_suffix',
+            ),
+          'uniqueName' => 'individual_suffix_id',
+        ),
       'employer_id' => array(
           'name' => 'employer_id',
           'type' => 1,
@@ -553,7 +563,7 @@ function contact_getfields_expectedresult(){
           'extends_entity_column_id' => '',
           'is_view' => 0,
           'is_multiple' => 0,
-          'option_group_id' => '97',
+          'option_group_id' => '99',
           'date_format' => '',
           'time_format' => '',
           'name' => 'custom_1',
@@ -573,7 +583,7 @@ function contact_getfields_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 95126339556a777bf61ca5fe7bf31d55383902c9..6b22a2f9a1ce5023dfd697024251051af12ccdb8 100644 (file)
@@ -1,22 +1,30 @@
 <?php
-
-/*
- This demonstrates use of the 'format.single_entity_array' param.
+/**
+ * Test Generated example of using 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
+    /* it will be ignored if there is not exactly 1 result *
  */
 function contact_getsingle_example(){
 $params = array(
-  'version' => 3,
   'id' => 17,
 );
 
-  $result = civicrm_api( 'contact','getsingle',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_getsingle_expectedresult(){
@@ -79,7 +87,7 @@ function contact_getsingle_expectedresult(){
   'id' => '17',
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 6e11f1bfb6034247924ed18791a3cf3f34d8521f..3c76bda6af61f897f1327474a5bc6ee65ee7eb8f 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
- Get all from group and display contacts
+/**
+ * Test Generated example of using contact get API
+ * Get all from group and display contacts *
  */
 function contact_get_example(){
 $params = array(
@@ -9,16 +9,24 @@ $params = array(
       '0' => 1,
       '1' => 26,
     ),
-  'version' => 3,
   'contact_type' => 'Individual',
 );
 
-  $result = civicrm_api( 'contact','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_get_expectedresult(){
@@ -89,7 +97,7 @@ function contact_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 44c0afe0d73915bbb12ed147589817f760d51943..9f9e0b843817a53e4de19bfe9c7bc4fab90ae110 100644 (file)
 <?php
-
-
-/*
-
+/**
+ * Test Generated example of using contact create API
+ * /*this demonstrates setting a custom field through the API  *
  */
-function contact_create_example() {
-  $params = array(
-    'first_name' => 'abc3',
-    'last_name' => 'xyz3',
-    'contact_type' => 'Individual',
-    'email' => 'man3@yahoo.com',
-    'version' => 3,
-    '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,
-      ),
-    ),
-  );
+function contact_create_example(){
+$params = array(
+  'first_name' => 'abc1',
+  'contact_type' => 'Individual',
+  'last_name' => 'xyz1',
+  'custom_1' => 'custom string',
+);
 
-  require_once 'api/api.php';
-  $result = civicrm_api('contact', 'create', $params);
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
-function contact_create_expectedresult() {
+function contact_create_expectedresult(){
 
   $expectedResult = array(
-    'is_error' => 0,
-    'version' => 3,
-    'count' => 1,
-    'id' => 1,
-    'values' => array(
+  'is_error' => 0,
+  'version' => 3,
+  'count' => 1,
+  'id' => 1,
+  'values' => array(
       '1' => array(
-        'id' => 1,
-        'contact_type' => 'Individual',
-        'contact_sub_type' => 'null',
-        'do_not_email' => '',
-        'do_not_phone' => '',
-        'do_not_mail' => '',
-        'do_not_sms' => '',
-        'do_not_trade' => '',
-        'is_opt_out' => '',
-        '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' => '',
-        'api_key' => '',
-        'first_name' => 'abc3',
-        'middle_name' => '',
-        'last_name' => 'xyz3',
-        'prefix_id' => '',
-        'suffix_id' => '',
-        'email_greeting_id' => '',
-        'email_greeting_custom' => '',
-        'email_greeting_display' => '',
-        'postal_greeting_id' => '',
-        'postal_greeting_custom' => '',
-        'postal_greeting_display' => '',
-        'addressee_id' => '',
-        'addressee_custom' => '',
-        'addressee_display' => '',
-        'job_title' => '',
-        'gender_id' => '',
-        'birth_date' => '',
-        'is_deceased' => '',
-        'deceased_date' => '',
-        'household_name' => '',
-        'primary_contact_id' => '',
-        'organization_name' => '',
-        'sic_code' => '',
-        'user_unique_id' => '',
-        'api.contribution.create' => array(
-          'is_error' => 0,
-          'version' => 3,
-          'count' => 1,
-          'id' => 2,
-          'values' => array(
-            '0' => array(
-              'id' => 2,
-              'contact_id' => 1,
-                      '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' => '',
-              'honor_contact_id' => '',
-              'is_test' => '',
-              'is_pay_later' => '',
-              'contribution_status_id' => 1,
-              'honor_type_id' => '',
-              'address_id' => '',
-              'check_number' => 'null',
-              'campaign_id' => '',
-            ),
-          ),
-        ),
-        'api.website.create' => array(
-          '0' => array(
-            'is_error' => 0,
-            'version' => 3,
-            'count' => 1,
-            'id' => 3,
-            'values' => array(
-              '0' => array(
-                'id' => 3,
-                'contact_id' => 1,
-                'url' => 'http://civicrm.org',
-                'website_type_id' => '',
-              ),
-            ),
-          ),
-          '1' => array(
-            'is_error' => 0,
-            'version' => 3,
-            'count' => 1,
-            'id' => 4,
-            'values' => array(
-              '0' => array(
-                'id' => 4,
-                'contact_id' => 1,
-                'url' => 'http://chained.org',
-                'website_type_id' => 2,
-              ),
-            ),
-          ),
+          'id' => '1',
+          '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',
+          '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 05:52:14',
+          '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
 *
-* testCreateIndividualWithContributionChainedArrays and can be found in
-* http://svn.civicrm.org/civicrm/branches/v3.4/tests/phpunit/CiviTest/api/v3/ContactTest.php
+* testCreateWithCustom and can be found in
+* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php
 *
 * You can see the outcome of the API tests at
 * http://tests.dev.civicrm.org/trunk/results-api_v3
+*
+* To Learn about the API read
+* http://book.civicrm.org/developer/current/techniques/api/
+*
 * and review the wiki at
 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
+*
 * 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
+*/
\ No newline at end of file
index 01bc26c2ec2ca17d74840ffbc88e6a619ba076dd..f299e0244b8c203b5c86dde1f1c1cc95a9e05302 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using contact delete API
+ * *
  */
 function contact_delete_example(){
 $params = array(
-  'id' => 17,
-  'version' => 3,
+  'id' => 1,
 );
 
-  $result = civicrm_api( 'contact','delete',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_delete_expectedresult(){
@@ -26,7 +34,7 @@ function contact_delete_expectedresult(){
   'values' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index b4dc0bbe9adab3a2e2188e5476503a39814dc09a..a597b7bbf8cca3207186a9ae26e5b51c74cbebec 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using contact get API
+ * *
  */
 function contact_get_example(){
 $params = array(
   'email' => 'man2@yahoo.com',
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'contact','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_get_expectedresult(){
@@ -85,7 +93,7 @@ function contact_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 12f2272acfaf8f1c2ab8af327a11ceccedf85e96..2497092f17a0c60149f93bcb22d23309e8405abf 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
- Demonstrates retrieving options for a custom field
+/**
+ * Test Generated example of using contact getoptions API
+ * Demonstrates retrieving options for a custom field *
  */
 function contact_getoptions_example(){
 $params = array(
   'field' => 'custom_1',
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'contact','getoptions',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_getoptions_expectedresult(){
@@ -29,7 +37,7 @@ function contact_getoptions_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 95cf55adc77c33a08288f2593ddedcf9eed28fb9..efd3a0c1bdfb35993a63fcd7fcdbb9ea12900a4b 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
- Demonstrates creating contribution with Note Entity
+/**
+ * Test Generated example of using contribution create API
+ * Demonstrates creating contribution with Note Entity *
  */
 function contribution_create_example(){
 $params = array(
@@ -17,16 +17,24 @@ $params = array(
   'invoice_id' => 67890,
   'source' => 'SSF',
   'contribution_status_id' => 1,
-  'version' => 3,
   'note' => 'my contribution note',
 );
 
-  $result = civicrm_api( 'contribution','create',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contribution_create_expectedresult(){
@@ -71,7 +79,7 @@ function contribution_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 7dda9bfe724b5a59b867d74a681e7c78ce23e2e1..5517820800d4cc3a09a41f1d480f8a9f38da3c12 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
- Demonstrates creating contribution with SoftCredit
+/**
+ * Test Generated example of using contribution create API
+ * Demonstrates creating contribution with SoftCredit *
  */
 function contribution_create_example(){
 $params = array(
@@ -14,16 +14,24 @@ $params = array(
   'net_amount' => '95',
   'source' => 'SSF',
   'contribution_status_id' => 1,
-  'version' => 3,
   'soft_credit_to' => 2,
 );
 
-  $result = civicrm_api( 'contribution','create',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contribution_create_expectedresult(){
@@ -68,7 +76,7 @@ function contribution_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 19950dd49494a598673468404df787a9e0930672..4f00ff18461ef8953fa78fafc5b996b99c48b6f4 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
- Create Contribution with Nested Line Items
+/**
+ * Test Generated example of using contribution create API
+ * Create Contribution with Nested Line Items *
  */
 function contribution_create_example(){
 $params = array(
@@ -17,7 +17,6 @@ $params = array(
   'invoice_id' => 67890,
   'source' => 'SSF',
   'contribution_status_id' => 1,
-  'version' => 3,
   'skipLineItem' => 1,
   'api.line_item.create' => array(
       '0' => array(
@@ -33,15 +32,23 @@ $params = array(
           'unit_price' => '80',
         ),
     ),
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'contribution','create',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contribution_create_expectedresult(){
@@ -132,7 +139,7 @@ function contribution_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 5eece67eae67ababe1aca8ae3cf7ed02fe845276..196512eaf80697444ed1d25ecd826b853d59146d 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using contribution create API
+ * *
  */
 function contribution_create_example(){
 $params = array(
@@ -14,15 +14,23 @@ $params = array(
   'invoice_id' => 67890,
   'source' => 'SSF',
   'contribution_status_id' => 2,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'contribution','create',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contribution_create_expectedresult(){
@@ -67,7 +75,7 @@ function contribution_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 76bcf2e3e162532f426c12c6ace2017764cb0c0b..f2586828a53c208826eb7eed6eb40dddf51ed0ca 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using contribution delete API
+ * *
  */
 function contribution_delete_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'contribution','delete',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contribution_delete_expectedresult(){
@@ -29,7 +37,7 @@ function contribution_delete_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index b1f1f3705279ffa91cf73f938a2111ee1e77bcb6..41f8714c285fddf3951600c298cd4d6c07985473 100644 (file)
@@ -1,21 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using contribution get API
+ * *
  */
 function contribution_get_example(){
 $params = array(
   'contribution_id' => 1,
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'contribution','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contribution_get_expectedresult(){
@@ -78,7 +85,7 @@ function contribution_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 4ac57e44a91d9ceff041106d5627cebd9761efa8..b2ae487b5776a02e1bc6aa35b236eb2869b68dd9 100644 (file)
@@ -1,23 +1,31 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using contribution_page create API
+ * *
  */
 function contribution_page_create_example(){
 $params = array(
-  'version' => 3,
   'title' => 'Test Contribution Page',
   'financial_type_id' => 1,
   'currency' => 'NZD',
   'goal_amount' => 34567,
 );
 
-  $result = civicrm_api( 'contribution_page','create',$params );
+try{
+  $result = civicrm_api3('contribution_page', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contribution_page_create_expectedresult(){
@@ -73,7 +81,7 @@ function contribution_page_create_expectedresult(){
           'start_date' => '',
           'end_date' => '',
           'created_id' => '',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'currency' => 'NZD',
           'campaign_id' => '',
           'is_share' => '',
@@ -81,7 +89,7 @@ function contribution_page_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 49735c77b15d9e319e3e0cbd2ef234d8a3309af3..dc3a05d59c73a29fe4258b289eee63ce2b550b96 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using contribution_page delete API
+ * *
  */
 function contribution_page_delete_example(){
 $params = array(
-  'version' => 3,
   'id' => 4,
 );
 
-  $result = civicrm_api( 'contribution_page','delete',$params );
+try{
+  $result = civicrm_api3('contribution_page', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contribution_page_delete_expectedresult(){
@@ -26,7 +34,7 @@ function contribution_page_delete_expectedresult(){
   'values' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index aba7ccea5177fdc3846d2fb19d065931d27fdee5..bdb335613a228ec2973ee25e312cad631241ef5d 100644 (file)
@@ -1,22 +1,30 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using contribution_page get API
+ * *
  */
 function contribution_page_get_example(){
 $params = array(
-  'version' => 3,
   'amount' => '34567',
   'currency' => 'NZD',
   'financial_type_id' => 1,
 );
 
-  $result = civicrm_api( 'contribution_page','get',$params );
+try{
+  $result = civicrm_api3('contribution_page', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contribution_page_get_expectedresult(){
@@ -50,7 +58,7 @@ function contribution_page_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 722de8ea183fa40e0a412aea7d58143c8f1f3199..c83fb85f74d27e3b4e2186bd506d565d6dc254df 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using contribution_recur create API
+ * *
  */
 function contribution_recur_create_example(){
 $params = array(
-  'version' => 3,
   'contact_id' => 3,
   'installments' => '12',
   'frequency_interval' => '1',
@@ -16,12 +15,21 @@ $params = array(
   'frequency_unit' => 'day',
 );
 
-  $result = civicrm_api( 'contribution_recur','create',$params );
+try{
+  $result = civicrm_api3('contribution_recur', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contribution_recur_create_expectedresult(){
@@ -41,7 +49,7 @@ function contribution_recur_create_expectedresult(){
           'frequency_interval' => '1',
           'installments' => '12',
           'start_date' => '20120101000000',
-          'create_date' => '20130713234826',
+          'create_date' => '20120130621222105',
           'modified_date' => '2012-11-14 16:02:35',
           'cancel_date' => '',
           'end_date' => '',
@@ -64,7 +72,7 @@ function contribution_recur_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 70848d36d922c0320463f515034d7a1c289e8460..2f4a8e0ce496d22f640684964f8ea6188eab8c70 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using contribution_recur delete API
+ * *
  */
 function contribution_recur_delete_example(){
 $params = array(
-  'version' => 3,
   'id' => 1,
 );
 
-  $result = civicrm_api( 'contribution_recur','delete',$params );
+try{
+  $result = civicrm_api3('contribution_recur', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contribution_recur_delete_expectedresult(){
@@ -26,7 +34,7 @@ function contribution_recur_delete_expectedresult(){
   'values' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index b1d1ebdda501d3048f8f4132a264a5f19edefc44..6158d65a30762bd18895aabc27ada37229dde9b2 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using contribution_recur get API
+ * *
  */
 function contribution_recur_get_example(){
 $params = array(
-  'version' => 3,
   'amount' => '500',
 );
 
-  $result = civicrm_api( 'contribution_recur','get',$params );
+try{
+  $result = civicrm_api3('contribution_recur', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contribution_recur_get_expectedresult(){
@@ -34,7 +42,7 @@ function contribution_recur_get_expectedresult(){
           'frequency_interval' => '1',
           'installments' => '12',
           'start_date' => '2012-01-01 00:00:00',
-          'create_date' => '2013-07-13 23:48:27',
+          'create_date' => '20120130621222105',
           'contribution_status_id' => '1',
           'is_test' => 0,
           'cycle_day' => '1',
@@ -45,7 +53,7 @@ function contribution_recur_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 3f042d8df842f5f656f40df10d35e84635d3aadf..c9e12465f1467f807c1942ac3b92f906b4a38c8f 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using contribution_soft create API
+ * *
  */
 function contribution_soft_create_example(){
 $params = array(
@@ -9,15 +9,23 @@ $params = array(
   'contact_id' => 2,
   'amount' => '10',
   'currency' => 'USD',
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'contribution_soft','create',$params );
+try{
+  $result = civicrm_api3('contribution_soft', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contribution_soft_create_expectedresult(){
@@ -42,7 +50,7 @@ function contribution_soft_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 1948ac716c6a2d1a822e555bc00a067c1b9d89de..5ca7d1b92db51b5dfdd04e04d32a34add79b6b77 100644 (file)
@@ -1,27 +1,35 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using contribution_soft delete API
+ * *
  */
 function contribution_soft_delete_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'contribution_soft','delete',$params );
+try{
+  $result = civicrm_api3('contribution_soft', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contribution_soft_delete_expectedresult(){
 
   $expectedResult = '';
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index ec8044630dd9108f804327d41e1fab967afeaa9b..93625387da41ecf1c69d1e02a732dbfbf065e782 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using contribution_soft get API
+ * *
  */
 function contribution_soft_get_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'contribution_soft','get',$params );
+try{
+  $result = civicrm_api3('contribution_soft', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contribution_soft_get_expectedresult(){
@@ -28,7 +36,7 @@ function contribution_soft_get_expectedresult(){
       '1' => array(
           'id' => '1',
           'contribution_id' => '1',
-          'contact_id' => '2',
+          'contact_id' => '4',
           'amount' => '10.00',
           'currency' => 'USD',
           'pcp_display_in_roll' => 0,
@@ -36,7 +44,7 @@ function contribution_soft_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index fa6d263de2e06084056e83f6012d8dd04c66dcca..c0496c093cc89b5d17b04c08112e3419ad8259a0 100644 (file)
 <?php
-
-
-
-/*
-
+/**
+ * Test Generated example of using custom_field create API
+ * *
  */
-function custom_field_create_example() {
-  $params = array(
-    'custom_group_id' => 1,
-    'name' => 'test_date',
-    'label' => 'test_date',
-    'html_type' => 'Select Date',
-    'data_type' => 'Date',
-    'default_value' => '20071212',
-    'weight' => 4,
-    'is_required' => 1,
-    'is_searchable' => 0,
-    'is_active' => 1,
-    'version' => 3,
-  );
+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,
+);
 
-  require_once 'api/api.php';
-  $result = civicrm_api('custom_field', 'create', $params);
+try{
+  $result = civicrm_api3('custom_field', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
-function custom_field_create_expectedresult() {
+function custom_field_create_expectedresult(){
 
   $expectedResult = array(
-    'is_error' => 0,
-    'version' => 3,
-    'count' => 1,
-    'id' => 1,
-    'values' => array(
+  'is_error' => 0,
+  'version' => 3,
+  'count' => 1,
+  'id' => 1,
+  'values' => array(
       '1' => array(
-        'id' => '1',
-        'custom_group_id' => '1',
-        'name' => 'test_date',
-        'label' => 'test_date',
-        'data_type' => 'Date',
-        'html_type' => 'Select Date',
-        'default_value' => '20071212',
-        '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' => 'test_date_1',
-        'option_group_id' => '',
-      ),
+          'id' => '1',
+          'custom_group_id' => '1',
+          'name' => 'Name1',
+          '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' => '',
+        ),
     ),
-  );
+);
 
   return $expectedResult;
 }
 
 
-
-
 /*
 * This example has been generated from the API test suite. The test that created it is called
-* custom_field_create
+*
+* testCustomFieldCreateWithEdit and can be found in
+* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/CustomFieldTest.php
+*
 * You can see the outcome of the API tests at
 * http://tests.dev.civicrm.org/trunk/results-api_v3
+*
+* To Learn about the API read
+* http://book.civicrm.org/developer/current/techniques/api/
+*
 * and review the wiki at
-* http://wiki.civicrm.org/confluence/display/CRMDOC40/CiviCRM+Public+APIs
+* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
+*
 * 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
+*/
\ No newline at end of file
index 696de1ac1dbe59c12ed7b25da28daa86314ab2d7..db4437fccb7e9d662c30700861202e6a1a84f481 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using custom_field delete API
+ * *
  */
 function custom_field_delete_example(){
 $params = array(
-  'version' => 3,
   'id' => 1,
 );
 
-  $result = civicrm_api( 'custom_field','delete',$params );
+try{
+  $result = civicrm_api3('custom_field', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function custom_field_delete_expectedresult(){
@@ -26,7 +34,7 @@ function custom_field_delete_expectedresult(){
   'values' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index c03dd487613ee464c8d5b4240b6fb0942dec92a0..c57089324775a8a968792d1c25a2971c96a37703 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using custom_group create API
+ * *
  */
 function custom_group_create_example(){
 $params = array(
@@ -16,15 +16,23 @@ $params = array(
   'help_pre' => 'This is Pre Help For Test Group 1',
   'help_post' => 'This is Post Help For Test Group 1',
   'is_active' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'custom_group','create',$params );
+try{
+  $result = civicrm_api3('custom_group', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function custom_group_create_expectedresult(){
@@ -54,13 +62,13 @@ function custom_group_create_expectedresult(){
           'max_multiple' => 'null',
           'collapse_adv_display' => '',
           'created_id' => '',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'is_reserved' => '',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 0c2d0aefe7846ef9321201f1e10c3eb39cf2a677..e5b7dc15e634b051c2035a408893e96bb9dbaf97 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using custom_group delete API
+ * *
  */
 function custom_group_delete_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'custom_group','delete',$params );
+try{
+  $result = civicrm_api3('custom_group', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function custom_group_delete_expectedresult(){
@@ -26,7 +34,7 @@ function custom_group_delete_expectedresult(){
   'values' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 6195030bca71231df85fdca6bd16c0c239ec0774..35d4217897988fd1e56f689eda3e232d61b4a208 100644 (file)
@@ -1,19 +1,26 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using custom_group get API
+ * *
  */
 function custom_group_get_example(){
-$params = array(
-  'version' => 3,
-);
+$params = array();
 
-  $result = civicrm_api( 'custom_group','get',$params );
+try{
+  $result = civicrm_api3('custom_group', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function custom_group_get_expectedresult(){
@@ -38,11 +45,12 @@ function custom_group_get_expectedresult(){
           'table_name' => 'civicrm_value_test_group_1_1',
           'is_multiple' => 0,
           'collapse_adv_display' => 0,
+          'is_reserved' => 0,
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 3279ad8db17eaaff4232ab6f14b6ab0b5b3c4e8c..e88d7b454fda3948269094a8d20d61a329a44067 100644 (file)
@@ -1,22 +1,30 @@
 <?php
-
-/*
- utilises field names
+/**
+ * Test Generated example of using custom_value get API
+ * utilises field names *
  */
 function custom_value_get_example(){
 $params = array(
   'id' => 2,
-  'version' => 3,
   'entity_id' => 2,
   'format.field_names' => 1,
 );
 
-  $result = civicrm_api( 'custom_value','get',$params );
+try{
+  $result = civicrm_api3('custom_value', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function custom_value_get_expectedresult(){
@@ -30,7 +38,6 @@ function custom_value_get_expectedresult(){
           'entity_id' => '2',
           'latest' => 'value 1',
           'id' => 'mySingleField',
-          '0' => 'value 1',
         ),
       'Cust_Field' => array(
           'entity_id' => '2',
@@ -56,7 +63,7 @@ function custom_value_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 92c75ced3bdf19612be4981c1231ca31f26ff807..fb8e0479f44b3be8e5a290a5f3debad57c861818 100644 (file)
@@ -1,33 +1,41 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using custom_value create API
+ * *
  */
 function custom_value_create_example(){
-$params = array( 
+$params = array(
   'custom_1' => 'customString',
-  'version' => 3,
   'entity_id' => 3,
 );
 
-  $result = civicrm_api( 'custom_value','create',$params );
+try{
+  $result = civicrm_api3('custom_value', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function custom_value_create_expectedresult(){
 
-  $expectedResult = array( 
+  $expectedResult = array(
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
   'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 80cb01fcc10c933dad9bab15365776ab8d53a297..4ca42103af4320807f7c879a454a02df81bd0b54 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
- /*this demonstrates the use of CustomValue get
+/**
+ * Test Generated example of using custom_value get API
+ * /*this demonstrates the use of CustomValue get *
  */
 function custom_value_get_example(){
 $params = array(
   'id' => 2,
-  'version' => 3,
   'entity_id' => 2,
 );
 
-  $result = civicrm_api( 'custom_value','get',$params );
+try{
+  $result = civicrm_api3('custom_value', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function custom_value_get_expectedresult(){
@@ -29,7 +37,6 @@ function custom_value_get_expectedresult(){
           'entity_id' => '2',
           'latest' => 'value 1',
           'id' => '1',
-          '0' => 'value 1',
         ),
       '2' => array(
           'entity_id' => '2',
@@ -76,7 +83,7 @@ function custom_value_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 71316d270d647001b8d55f76cffb1b1b604d07cc..5de8ff77ccc220780ba62b661d431041d57094ee 100644 (file)
@@ -1,23 +1,31 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using domain create API
+ * *
  */
 function domain_create_example(){
 $params = array(
   'name' => 'A-team domain',
   'description' => 'domain of chaos',
-  'version' => 3,
   'domain_version' => '4.2',
   'contact_id' => 6,
 );
 
-  $result = civicrm_api( 'domain','create',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function domain_create_expectedresult(){
@@ -41,7 +49,7 @@ function domain_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 8fcfb516db6a9749cf7f834e0cb88de0576d04c6..2456fea48c10f00a02e09feb3ba196492ac51a5a 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using domain get API
+ * *
  */
 function domain_get_example(){
 $params = array(
-  'version' => 3,
   'sequential' => 1,
 );
 
-  $result = civicrm_api( 'domain','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function domain_get_expectedresult(){
@@ -27,7 +35,7 @@ function domain_get_expectedresult(){
       '0' => array(
           'id' => '1',
           'name' => 'Default Domain Name',
-          'config_backend' => 'a:79:{s:10:"userSystem";O:26:"CRM_Utils_System_UnitTests":4:{s:9:"is_drupal";b:0;s:9:"is_joomla";b:0;s:12:"is_wordpress";b:0;s:24:"supports_form_extensions";b:0;}s:11:"initialized";i:0;s:15:"DAOFactoryClass";s:23:"CRM_Contact_DAO_Factory";s:17:"componentRegistry";O:18:"CRM_Core_Component":0:{}s:9:"inCiviCRM";b:0;s:18:"recaptchaPublicKey";N;s:5:"debug";i:0;s:9:"backtrace";i:0;s:12:"resourceBase";N;s:13:"extensionsURL";N;s:12:"countryLimit";a:1:{i:0;s:4:"1228";}s:27:"defaultContactStateProvince";N;s:13:"provinceLimit";a:1:{i:0;s:4:"1228";}s:21:"defaultContactCountry";s:4:"1228";s:15:"defaultCurrency";s:3:"USD";s:10:"lcMessages";s:5:"en_US";s:18:"dateformatDatetime";s:20:"%B %E%f, %Y %l:%M %P";s:14:"dateformatFull";s:11:"%B %E%f, %Y";s:17:"dateformatPartial";s:5:"%B %Y";s:14:"dateformatYear";s:2:"%Y";s:14:"dateformatTime";s:8:"%l:%M %P";s:15:"timeInputFormat";i:1;s:15:"dateInputFormat";s:8:"mm/dd/yy";s:15:"fiscalYearStart";a:2:{s:1:"M";i:1;s:1:"d";i:1;}s:11:"moneyformat";s:5:"%c %a";s:16:"moneyvalueformat";s:3:"%!i";s:15:"currencySymbols";s:0:"";s:21:"defaultCurrencySymbol";s:1:"$";s:20:"monetaryDecimalPoint";s:1:".";s:25:"monetaryThousandSeparator";s:1:",";s:14:"gettextCodeset";s:5:"utf-8";s:13:"gettextDomain";s:7:"civicrm";s:27:"userFrameworkUsersTableName";s:5:"users";s:21:"userFrameworkFrontend";b:0;s:20:"userFrameworkLogging";b:0;s:17:"maxImportFileSize";i:1048576;s:11:"maxFileSize";i:2;s:11:"mapProvider";N;s:9:"mapAPIKey";N;s:11:"geoProvider";N;s:9:"geoAPIKey";N;s:13:"geocodeMethod";s:0:"";s:12:"mapGeoCoding";i:1;s:7:"logging";b:0;s:12:"versionCheck";b:1;s:16:"enableComponents";a:6:{i:0;s:14:"CiviContribute";i:1;s:10:"CiviPledge";i:2;s:10:"CiviMember";i:3;s:9:"CiviEvent";i:4;s:8:"CiviMail";i:5;s:10:"CiviReport";}s:18:"enableComponentIDs";a:6:{i:0;i:1;i:1;i:6;i:2;i:2;i:3;i:3;i:4;i:4;i:5;i:8;}s:9:"enableSSL";b:0;s:18:"fatalErrorTemplate";s:20:"CRM/common/fatal.tpl";s:17:"fatalErrorHandler";N;s:14:"legacyEncoding";s:12:"Windows-1252";s:14:"fieldSeparator";s:1:",";s:17:"maxLocationBlocks";i:2;s:15:"captchaFontPath";s:25:"/usr/X11R6/lib/X11/fonts/";s:11:"captchaFont";s:17:"HelveticaBold.ttf";s:21:"includeWildCardInName";i:1;s:18:"includeEmailInName";i:1;s:21:"includeNickNameInName";i:0;s:22:"smartGroupCacheTimeout";i:5;s:22:"defaultSearchProfileID";N;s:21:"dashboardCacheTimeout";i:1440;s:15:"doNotResetCache";i:0;s:24:"includeAlphabeticalPager";i:1;s:20:"includeOrderByClause";i:1;s:13:"oldInputStyle";i:1;s:14:"formKeyDisable";b:0;s:21:"doNotAttachPDFReceipt";b:0;s:15:"wkhtmltopdfPath";b:0;s:10:"wpBasePage";N;s:13:"verpSeparator";s:1:".";s:12:"mailerPeriod";i:180;s:16:"mailerSpoolLimit";i:0;s:16:"mailerBatchLimit";i:0;s:13:"mailerJobSize";i:0;s:13:"mailerJobsMax";i:0;s:16:"mailThrottleTime";i:0;s:12:"customCSSURL";N;s:15:"civiRelativeURL";s:13:"/index.php?q=";s:11:"civiVersion";s:10:"4.4.alpha1";}',
+          'config_backend' => 'a:80:{s:10:"userSystem";O:26:"CRM_Utils_System_UnitTests":4:{s:9:"is_drupal";b:0;s:9:"is_joomla";b:0;s:12:"is_wordpress";b:0;s:24:"supports_form_extensions";b:0;}s:11:"initialized";i:0;s:15:"DAOFactoryClass";s:23:"CRM_Contact_DAO_Factory";s:17:"componentRegistry";O:18:"CRM_Core_Component":0:{}s:9:"inCiviCRM";b:0;s:18:"recaptchaPublicKey";N;s:5:"debug";i:0;s:9:"backtrace";i:0;s:12:"resourceBase";N;s:13:"extensionsURL";N;s:12:"countryLimit";a:1:{i:0;s:4:"1228";}s:27:"defaultContactStateProvince";N;s:13:"provinceLimit";a:1:{i:0;s:4:"1228";}s:21:"defaultContactCountry";s:4:"1228";s:15:"defaultCurrency";s:3:"USD";s:10:"lcMessages";s:5:"en_US";s:18:"dateformatDatetime";s:20:"%B %E%f, %Y %l:%M %P";s:14:"dateformatFull";s:11:"%B %E%f, %Y";s:17:"dateformatPartial";s:5:"%B %Y";s:14:"dateformatYear";s:2:"%Y";s:14:"dateformatTime";s:8:"%l:%M %P";s:15:"timeInputFormat";i:1;s:15:"dateInputFormat";s:8:"mm/dd/yy";s:15:"fiscalYearStart";a:2:{s:1:"M";i:1;s:1:"d";i:1;}s:11:"moneyformat";s:5:"%c %a";s:16:"moneyvalueformat";s:3:"%!i";s:15:"currencySymbols";s:0:"";s:21:"defaultCurrencySymbol";s:1:"$";s:20:"monetaryDecimalPoint";s:1:".";s:25:"monetaryThousandSeparator";s:1:",";s:14:"gettextCodeset";s:5:"utf-8";s:13:"gettextDomain";s:7:"civicrm";s:27:"userFrameworkUsersTableName";s:5:"users";s:21:"userFrameworkFrontend";b:0;s:20:"userFrameworkLogging";b:0;s:17:"maxImportFileSize";i:1048576;s:11:"maxFileSize";i:2;s:11:"mapProvider";N;s:9:"mapAPIKey";N;s:11:"geoProvider";N;s:9:"geoAPIKey";N;s:13:"geocodeMethod";s:0:"";s:12:"mapGeoCoding";i:1;s:7:"logging";b:0;s:12:"versionCheck";b:1;s:16:"enableComponents";a:6:{i:0;s:14:"CiviContribute";i:1;s:10:"CiviPledge";i:2;s:10:"CiviMember";i:3;s:9:"CiviEvent";i:4;s:8:"CiviMail";i:5;s:10:"CiviReport";}s:18:"enableComponentIDs";a:6:{i:0;i:1;i:1;i:6;i:2;i:2;i:3;i:3;i:4;i:4;i:5;i:8;}s:9:"enableSSL";b:0;s:18:"fatalErrorTemplate";s:20:"CRM/common/fatal.tpl";s:17:"fatalErrorHandler";N;s:14:"legacyEncoding";s:12:"Windows-1252";s:14:"fieldSeparator";s:1:",";s:17:"maxLocationBlocks";i:2;s:15:"captchaFontPath";s:25:"/usr/X11R6/lib/X11/fonts/";s:11:"captchaFont";s:17:"HelveticaBold.ttf";s:21:"includeWildCardInName";i:1;s:18:"includeEmailInName";i:1;s:21:"includeNickNameInName";i:0;s:22:"smartGroupCacheTimeout";i:5;s:22:"defaultSearchProfileID";N;s:21:"dashboardCacheTimeout";i:1440;s:15:"doNotResetCache";i:0;s:24:"includeAlphabeticalPager";i:1;s:20:"includeOrderByClause";i:1;s:13:"oldInputStyle";i:1;s:14:"formKeyDisable";b:0;s:21:"doNotAttachPDFReceipt";b:0;s:15:"wkhtmltopdfPath";b:0;s:23:"secondDegRelPermissions";b:0;s:10:"wpBasePage";N;s:13:"verpSeparator";s:1:".";s:12:"mailerPeriod";i:180;s:16:"mailerSpoolLimit";i:0;s:16:"mailerBatchLimit";i:0;s:13:"mailerJobSize";i:0;s:13:"mailerJobsMax";i:0;s:16:"mailThrottleTime";i:0;s:12:"customCSSURL";N;s:15:"civiRelativeURL";s:13:"/index.php?q=";s:11:"civiVersion";s:10:"4.4.alpha1";}',
           'version' => '3',
           'contact_id' => '3',
           'domain_email' => 'my@email.com',
@@ -52,7 +60,7 @@ function domain_get_expectedresult(){
       '1' => array(
           'id' => '2',
           'name' => 'Second Domain',
-          'config_backend' => 'a:79:{s:10:"userSystem";O:26:"CRM_Utils_System_UnitTests":4:{s:9:"is_drupal";b:0;s:9:"is_joomla";b:0;s:12:"is_wordpress";b:0;s:24:"supports_form_extensions";b:0;}s:11:"initialized";i:0;s:15:"DAOFactoryClass";s:23:"CRM_Contact_DAO_Factory";s:17:"componentRegistry";O:18:"CRM_Core_Component":0:{}s:9:"inCiviCRM";b:0;s:18:"recaptchaPublicKey";N;s:5:"debug";i:0;s:9:"backtrace";i:0;s:12:"resourceBase";N;s:13:"extensionsURL";N;s:12:"countryLimit";a:1:{i:0;s:4:"1228";}s:27:"defaultContactStateProvince";N;s:13:"provinceLimit";a:1:{i:0;s:4:"1228";}s:21:"defaultContactCountry";s:4:"1228";s:15:"defaultCurrency";s:3:"USD";s:10:"lcMessages";s:5:"en_US";s:18:"dateformatDatetime";s:20:"%B %E%f, %Y %l:%M %P";s:14:"dateformatFull";s:11:"%B %E%f, %Y";s:17:"dateformatPartial";s:5:"%B %Y";s:14:"dateformatYear";s:2:"%Y";s:14:"dateformatTime";s:8:"%l:%M %P";s:15:"timeInputFormat";i:1;s:15:"dateInputFormat";s:8:"mm/dd/yy";s:15:"fiscalYearStart";a:2:{s:1:"M";i:1;s:1:"d";i:1;}s:11:"moneyformat";s:5:"%c %a";s:16:"moneyvalueformat";s:3:"%!i";s:15:"currencySymbols";s:0:"";s:21:"defaultCurrencySymbol";s:1:"$";s:20:"monetaryDecimalPoint";s:1:".";s:25:"monetaryThousandSeparator";s:1:",";s:14:"gettextCodeset";s:5:"utf-8";s:13:"gettextDomain";s:7:"civicrm";s:27:"userFrameworkUsersTableName";s:5:"users";s:21:"userFrameworkFrontend";b:0;s:20:"userFrameworkLogging";b:0;s:17:"maxImportFileSize";i:1048576;s:11:"maxFileSize";i:2;s:11:"mapProvider";N;s:9:"mapAPIKey";N;s:11:"geoProvider";N;s:9:"geoAPIKey";N;s:13:"geocodeMethod";s:0:"";s:12:"mapGeoCoding";i:1;s:7:"logging";b:0;s:12:"versionCheck";b:1;s:16:"enableComponents";a:6:{i:0;s:14:"CiviContribute";i:1;s:10:"CiviPledge";i:2;s:10:"CiviMember";i:3;s:9:"CiviEvent";i:4;s:8:"CiviMail";i:5;s:10:"CiviReport";}s:18:"enableComponentIDs";a:6:{i:0;i:1;i:1;i:6;i:2;i:2;i:3;i:3;i:4;i:4;i:5;i:8;}s:9:"enableSSL";b:0;s:18:"fatalErrorTemplate";s:20:"CRM/common/fatal.tpl";s:17:"fatalErrorHandler";N;s:14:"legacyEncoding";s:12:"Windows-1252";s:14:"fieldSeparator";s:1:",";s:17:"maxLocationBlocks";i:2;s:15:"captchaFontPath";s:25:"/usr/X11R6/lib/X11/fonts/";s:11:"captchaFont";s:17:"HelveticaBold.ttf";s:21:"includeWildCardInName";i:1;s:18:"includeEmailInName";i:1;s:21:"includeNickNameInName";i:0;s:22:"smartGroupCacheTimeout";i:5;s:22:"defaultSearchProfileID";N;s:21:"dashboardCacheTimeout";i:1440;s:15:"doNotResetCache";i:0;s:24:"includeAlphabeticalPager";i:1;s:20:"includeOrderByClause";i:1;s:13:"oldInputStyle";i:1;s:14:"formKeyDisable";b:0;s:21:"doNotAttachPDFReceipt";b:0;s:15:"wkhtmltopdfPath";b:0;s:10:"wpBasePage";N;s:13:"verpSeparator";s:1:".";s:12:"mailerPeriod";i:180;s:16:"mailerSpoolLimit";i:0;s:16:"mailerBatchLimit";i:0;s:13:"mailerJobSize";i:0;s:13:"mailerJobsMax";i:0;s:16:"mailThrottleTime";i:0;s:12:"customCSSURL";N;s:15:"civiRelativeURL";s:13:"/index.php?q=";s:11:"civiVersion";s:10:"4.4.alpha1";}',
+          'config_backend' => 'a:80:{s:10:"userSystem";O:26:"CRM_Utils_System_UnitTests":4:{s:9:"is_drupal";b:0;s:9:"is_joomla";b:0;s:12:"is_wordpress";b:0;s:24:"supports_form_extensions";b:0;}s:11:"initialized";i:0;s:15:"DAOFactoryClass";s:23:"CRM_Contact_DAO_Factory";s:17:"componentRegistry";O:18:"CRM_Core_Component":0:{}s:9:"inCiviCRM";b:0;s:18:"recaptchaPublicKey";N;s:5:"debug";i:0;s:9:"backtrace";i:0;s:12:"resourceBase";N;s:13:"extensionsURL";N;s:12:"countryLimit";a:1:{i:0;s:4:"1228";}s:27:"defaultContactStateProvince";N;s:13:"provinceLimit";a:1:{i:0;s:4:"1228";}s:21:"defaultContactCountry";s:4:"1228";s:15:"defaultCurrency";s:3:"USD";s:10:"lcMessages";s:5:"en_US";s:18:"dateformatDatetime";s:20:"%B %E%f, %Y %l:%M %P";s:14:"dateformatFull";s:11:"%B %E%f, %Y";s:17:"dateformatPartial";s:5:"%B %Y";s:14:"dateformatYear";s:2:"%Y";s:14:"dateformatTime";s:8:"%l:%M %P";s:15:"timeInputFormat";i:1;s:15:"dateInputFormat";s:8:"mm/dd/yy";s:15:"fiscalYearStart";a:2:{s:1:"M";i:1;s:1:"d";i:1;}s:11:"moneyformat";s:5:"%c %a";s:16:"moneyvalueformat";s:3:"%!i";s:15:"currencySymbols";s:0:"";s:21:"defaultCurrencySymbol";s:1:"$";s:20:"monetaryDecimalPoint";s:1:".";s:25:"monetaryThousandSeparator";s:1:",";s:14:"gettextCodeset";s:5:"utf-8";s:13:"gettextDomain";s:7:"civicrm";s:27:"userFrameworkUsersTableName";s:5:"users";s:21:"userFrameworkFrontend";b:0;s:20:"userFrameworkLogging";b:0;s:17:"maxImportFileSize";i:1048576;s:11:"maxFileSize";i:2;s:11:"mapProvider";N;s:9:"mapAPIKey";N;s:11:"geoProvider";N;s:9:"geoAPIKey";N;s:13:"geocodeMethod";s:0:"";s:12:"mapGeoCoding";i:1;s:7:"logging";b:0;s:12:"versionCheck";b:1;s:16:"enableComponents";a:6:{i:0;s:14:"CiviContribute";i:1;s:10:"CiviPledge";i:2;s:10:"CiviMember";i:3;s:9:"CiviEvent";i:4;s:8:"CiviMail";i:5;s:10:"CiviReport";}s:18:"enableComponentIDs";a:6:{i:0;i:1;i:1;i:6;i:2;i:2;i:3;i:3;i:4;i:4;i:5;i:8;}s:9:"enableSSL";b:0;s:18:"fatalErrorTemplate";s:20:"CRM/common/fatal.tpl";s:17:"fatalErrorHandler";N;s:14:"legacyEncoding";s:12:"Windows-1252";s:14:"fieldSeparator";s:1:",";s:17:"maxLocationBlocks";i:2;s:15:"captchaFontPath";s:25:"/usr/X11R6/lib/X11/fonts/";s:11:"captchaFont";s:17:"HelveticaBold.ttf";s:21:"includeWildCardInName";i:1;s:18:"includeEmailInName";i:1;s:21:"includeNickNameInName";i:0;s:22:"smartGroupCacheTimeout";i:5;s:22:"defaultSearchProfileID";N;s:21:"dashboardCacheTimeout";i:1440;s:15:"doNotResetCache";i:0;s:24:"includeAlphabeticalPager";i:1;s:20:"includeOrderByClause";i:1;s:13:"oldInputStyle";i:1;s:14:"formKeyDisable";b:0;s:21:"doNotAttachPDFReceipt";b:0;s:15:"wkhtmltopdfPath";b:0;s:23:"secondDegRelPermissions";b:0;s:10:"wpBasePage";N;s:13:"verpSeparator";s:1:".";s:12:"mailerPeriod";i:180;s:16:"mailerSpoolLimit";i:0;s:16:"mailerBatchLimit";i:0;s:13:"mailerJobSize";i:0;s:13:"mailerJobsMax";i:0;s:16:"mailThrottleTime";i:0;s:12:"customCSSURL";N;s:15:"civiRelativeURL";s:13:"/index.php?q=";s:11:"civiVersion";s:10:"4.4.alpha1";}',
           'version' => '4.3.alpha1',
           'contact_id' => '2',
           'domain_email' => '"Domain Email" <domainemail2@example.org>',
@@ -77,7 +85,7 @@ function domain_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 9a0a46eab3d4cfaf352409cb9bfb1ca82f5f9d2c..0e11d25e25d53ac3a9c9fd7ed598ced5f20dbb56 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
- example demonstrates use of Replace in a nested API call
+/**
+ * Test Generated example of using email replace API
+ * example demonstrates use of Replace in a nested API call *
  */
 function email_replace_example(){
 $params = array(
-  'version' => 3,
   'id' => 10,
   'api.email.replace' => array(
       'values' => array(
@@ -38,12 +37,21 @@ $params = array(
     ),
 );
 
-  $result = civicrm_api( 'email','replace',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function email_replace_expectedresult(){
@@ -191,7 +199,7 @@ function email_replace_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index dedf7bfc91ec938bd56901c121b8b11deb879117..cfeb2745dacb3c83c273a4667c647ad40ae9f6d4 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using email create API
+ * *
  */
 function email_create_example(){
 $params = array(
@@ -9,15 +9,23 @@ $params = array(
   'location_type_id' => 6,
   'email' => 'api@a-team.com',
   'is_primary' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'email','create',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function email_create_expectedresult(){
@@ -45,7 +53,7 @@ function email_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 40bf993c6e7593f81c1f9cd48fad335786d3ce34..cd07fdbd4e14c16308f087264a948ad464fd0b98 100644 (file)
@@ -1,23 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using email delete API
+ * *
  */
 function email_delete_example(){
 $params = array(
-  'contact_id' => 8,
-  'location_type_id' => 16,
-  'email' => 'api@a-team.com',
-  'is_primary' => 1,
-  'version' => 3,
+  'id' => 11,
 );
 
-  $result = civicrm_api( 'email','delete',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function email_delete_expectedresult(){
@@ -29,7 +34,7 @@ function email_delete_expectedresult(){
   'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index f6a6c4cdb8647b2eb5c574e652840c2095f3fb48..fac556978282cead56db253789256453afac4256 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using email replace API
+ * *
  */
 function email_replace_example(){
 $params = array(
-  'version' => 3,
   'contact_id' => 9,
   'values' => array(
       '0' => array(
@@ -36,12 +35,21 @@ $params = array(
     ),
 );
 
-  $result = civicrm_api( 'email','replace',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function email_replace_expectedresult(){
@@ -124,7 +132,7 @@ function email_replace_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 9eda49f51d3f8c0623680338cad595b80bd82499..13c837eab85e76755fab346aa60667c272dc72ca 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using entity_tag create API
+ * *
  */
 function entity_tag_create_example(){
 $params = array(
   'contact_id' => 12,
-  'tag_id' => 1,
-  'version' => 3,
+  'tag_id' => '1',
 );
 
-  $result = civicrm_api( 'entity_tag','create',$params );
+try{
+  $result = civicrm_api3('entity_tag', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function entity_tag_create_expectedresult(){
@@ -27,7 +35,7 @@ function entity_tag_create_expectedresult(){
   'total_count' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 1315022fb3846a3722034918a1ab9903ac9ced9a..5abd8fea0dd87d2952e3351f4aad88287c93e145 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using entity_tag delete API
+ * *
  */
 function entity_tag_delete_example(){
 $params = array(
   'contact_id_h' => 46,
-  'tag_id' => 1,
-  'version' => 3,
+  'tag_id' => '1',
 );
 
-  $result = civicrm_api( 'entity_tag','delete',$params );
+try{
+  $result = civicrm_api3('entity_tag', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function entity_tag_delete_expectedresult(){
@@ -27,7 +35,7 @@ function entity_tag_delete_expectedresult(){
   'total_count' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..59841bee8d9d0902c4d88f02819e9f7fad735ba1 100644 (file)
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Test Generated example of using entity_tag get API
+ * *
+ */
+function entity_tag_get_example(){
+$params = array(
+  'contact_id' => 24,
+  'tag_id' => '1',
+);
+
+try{
+  $result = civicrm_api3('entity_tag', '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
+ */
+function entity_tag_get_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 in
+* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/EntityTagTest.php
+*
+* You can see the outcome of the API tests at
+* http://tests.dev.civicrm.org/trunk/results-api_v3
+*
+* To Learn about the API read
+* http://book.civicrm.org/developer/current/techniques/api/
+*
+* and review the wiki at
+* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
+*
+* 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
+*/
\ No newline at end of file
index 1e4acedb90c51c72224b1ce2da8e0fad9a74d992..35e38236b3f0890c77b26793c42cb47808ccc87f 100644 (file)
@@ -1,21 +1,28 @@
 <?php
-
-/*
- demonstrates use of is.Current option
+/**
+ * Test Generated example of using event get API
+ * demonstrates use of is.Current option *
  */
 function event_get_example(){
 $params = array(
   'isCurrent' => 1,
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'event','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function event_get_expectedresult(){
@@ -36,10 +43,10 @@ function event_get_expectedresult(){
           'event_type_id' => '1',
           'participant_listing_id' => 0,
           'is_public' => '1',
-          'start_date' => '2013-06-23 00:00:00',
-          'event_start_date' => '2013-06-23 00:00:00',
-          'end_date' => '2013-06-29 00:00:00',
-          'event_end_date' => '2013-06-29 00:00:00',
+          'start_date' => '2013-07-29 00:00:00',
+          'event_start_date' => '2013-07-29 00:00:00',
+          'end_date' => '2013-08-04 00:00:00',
+          'event_end_date' => '2013-08-04 00:00:00',
           'is_online_registration' => '1',
           'registration_start_date' => '2010-06-01 00:00:00',
           'registration_end_date' => '2010-10-15 00:00:00',
@@ -56,13 +63,13 @@ function event_get_expectedresult(){
           'is_multiple_registrations' => 0,
           'allow_same_participant_emails' => 0,
           'is_template' => 0,
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'is_share' => '1',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 3cb158cb0abe5d2395b6fc75590deda406dac5dd..24d7e2ec6f39f87d4fb977fe25aa892d34ba872a 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
- demonstrates use of return is_full 
+/**
+ * Test Generated example of using event getsingle API
+ * demonstrates use of return is_full  *
  */
 function event_getsingle_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
   'return.is_full' => 1,
 );
 
-  $result = civicrm_api( 'event','getsingle',$params );
+try{
+  $result = civicrm_api3('event', 'getsingle', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function event_getsingle_expectedresult(){
@@ -42,13 +50,13 @@ function event_getsingle_expectedresult(){
   'is_multiple_registrations' => 0,
   'allow_same_participant_emails' => 0,
   'is_template' => 0,
-  'created_date' => '2013-06-22 08:49:03',
+  'created_date' => '2013-07-28 08:49:19',
   'is_share' => '1',
   'available_places' => 0,
   'is_full' => '1',
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 1c04b164e628f6b3abd899fc35a6cac40522c132..bee390e79c30f25997f32ee392ce2e86ad9162de 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using event create API
+ * *
  */
 function event_create_example(){
 $params = array(
@@ -20,15 +20,23 @@ $params = array(
   'is_monetary' => 0,
   'is_active' => 1,
   'is_show_location' => 0,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'event','create',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function event_create_expectedresult(){
@@ -97,7 +105,7 @@ function event_create_expectedresult(){
           'is_template' => 0,
           'template_title' => '',
           'created_id' => '',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'currency' => '',
           'campaign_id' => '',
           'is_share' => '',
@@ -107,7 +115,7 @@ function event_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 75d5b0e2b6f632961e6d6a436b940b75e25b8309..e851cd6f32bba7b51ce5ead41b68dce3edb95709 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using event delete API
+ * *
  */
 function event_delete_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'event','delete',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function event_delete_expectedresult(){
@@ -26,7 +34,7 @@ function event_delete_expectedresult(){
   'values' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 7174320716940ad0bf515335b1ba846ca59f54b5..cd349e32d76e26fb6d4328adb3c9ec53e52a90c3 100644 (file)
@@ -1,22 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using event get API
+ * *
  */
 function event_get_example(){
 $params = array(
   'event_title' => 'Annual CiviCRM meet',
   'sequential' => true,
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'event','get',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function event_get_expectedresult(){
@@ -48,13 +55,13 @@ function event_get_expectedresult(){
           'is_multiple_registrations' => 0,
           'allow_same_participant_emails' => 0,
           'is_template' => 0,
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'is_share' => '1',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
diff --git a/api/v3/examples/EventUpdate.php b/api/v3/examples/EventUpdate.php
deleted file mode 100644 (file)
index 64b46e3..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-<?php
-
-/*
- */
-function event_update_example(){
-$params = array(
-  '0' => 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,
-      'version' => 3,
-    ),
-  '1' => array(
-      'title' => 'Annual CiviCRM meet 2',
-      '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' => 20101021,
-      'end_date' => 20101023,
-      'is_online_registration' => 1,
-      'registration_start_date' => 20100601,
-      'registration_end_date' => '2010-10-15',
-      'max_participants' => 100,
-      'event_full_text' => 'Sorry! We are already full',
-      'is_monetory' => 0,
-      'is_active' => 1,
-      'is_show_location' => 0,
-      'version' => 3,
-    ),
-);
-
-  $result = civicrm_api( 'event','update',$params );
-
-  return $result;
-}
-
-/*
- * Function returns array of result expected from previous function
- */
-function event_update_expectedresult(){
-
-  $expectedResult = array(
-  'is_error' => 0,
-  'version' => 3,
-  'count' => 1,
-  'id' => 3,
-  'values' => array(
-      '3' => array(
-          'id' => '3',
-          'title' => 'Annual CiviCRM meet 2',
-          'event_title' => 'Annual CiviCRM meet 2',
-          '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_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' => 0,
-          'is_public' => '1',
-          'start_date' => '2010-10-21 00:00:00',
-          'event_start_date' => '2010-10-21 00:00:00',
-          'end_date' => '2010-10-23 00:00:00',
-          'event_end_date' => '2010-10-23 00:00:00',
-          'is_online_registration' => '1',
-          'registration_start_date' => '2010-06-01 00:00:00',
-          'registration_end_date' => '2010-10-15 00:00:00',
-          'max_participants' => '150',
-          'event_full_text' => 'Sorry! We are already full',
-          'is_monetary' => 0,
-          'is_map' => 0,
-          'is_active' => '1',
-          'is_show_location' => 0,
-          'default_role_id' => '1',
-          'is_email_confirm' => 0,
-          'is_pay_later' => 0,
-          'is_partial_payment' => 0,
-          'is_multiple_registrations' => 0,
-          'allow_same_participant_emails' => 0,
-          'is_template' => 0,
-          'created_date' => '20120130621222105',
-          'is_share' => '1',
-        ),
-    ),
-);
-
-  return $expectedResult  ;
-}
-
-
-/*
-* This example has been generated from the API test suite. The test that created it is called
-*
-* testUpdateEvent and can be found in
-* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/EventTest.php
-*
-* You can see the outcome of the API tests at
-* http://tests.dev.civicrm.org/trunk/results-api_v3
-*
-* To Learn about the API read
-* http://book.civicrm.org/developer/current/techniques/api/
-*
-* and review the wiki at
-* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
-*
-* 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
-*/
\ No newline at end of file
index 5053fe603fb4ad27f0f90aeced9899fcc1d70d53..37d928094e712add28d2b3c4364c6913b6c947d5 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using grant create API
+ * *
  */
 function grant_create_example(){
 $params = array(
-  'version' => 3,
   'contact_id' => 3,
   'application_received_date' => 'now',
   'decision_date' => 'next Monday',
@@ -16,12 +15,21 @@ $params = array(
   'grant_type_id' => 1,
 );
 
-  $result = civicrm_api( 'grant','create',$params );
+try{
+  $result = civicrm_api3('grant', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function grant_create_expectedresult(){
@@ -35,8 +43,8 @@ function grant_create_expectedresult(){
       '1' => array(
           'id' => '1',
           'contact_id' => '3',
-          'application_received_date' => '20130622084947',
-          'decision_date' => '20130624000000',
+          'application_received_date' => '20130728084957',
+          'decision_date' => '20130729000000',
           'money_transfer_date' => '',
           'grant_due_date' => '',
           'grant_report_received' => '',
@@ -52,7 +60,7 @@ function grant_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 92b6487a60066a8f15686af44065d8802d488ed3..d0a7214771b5d64e0a87a1f7769cd8756fff31b1 100644 (file)
@@ -1,27 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using grant delete API
+ * *
  */
 function grant_delete_example(){
 $params = array(
-  'version' => 3,
-  'contact_id' => 5,
-  'application_received_date' => 'now',
-  'decision_date' => 'next Monday',
-  'amount_total' => '500',
-  'status_id' => 1,
-  'rationale' => 'Just Because',
-  'currency' => 'USD',
-  'grant_type_id' => 1,
+  'id' => 3,
 );
 
-  $result = civicrm_api( 'grant','delete',$params );
+try{
+  $result = civicrm_api3('grant', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function grant_delete_expectedresult(){
@@ -33,7 +34,7 @@ function grant_delete_expectedresult(){
   'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 9a90bb4f6137d4a54421ca245797939ca66833ab..65319a465f5d83c29e23929b5b5ec70bf2393456 100644 (file)
@@ -1,27 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using grant get API
+ * *
  */
 function grant_get_example(){
 $params = array(
-  'version' => 3,
-  'contact_id' => 4,
-  'application_received_date' => 'now',
-  'decision_date' => 'next Monday',
-  'amount_total' => '500',
-  'status_id' => 1,
   'rationale' => 'Just Because',
-  'currency' => 'USD',
-  'grant_type_id' => 1,
 );
 
-  $result = civicrm_api( 'grant','get',$params );
+try{
+  $result = civicrm_api3('grant', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function grant_get_expectedresult(){
@@ -35,8 +36,8 @@ function grant_get_expectedresult(){
       '2' => array(
           'id' => '2',
           'contact_id' => '4',
-          'application_received_date' => '2013-06-22',
-          'decision_date' => '2013-06-24',
+          'application_received_date' => '2013-07-28',
+          'decision_date' => '2013-07-29',
           'grant_type_id' => '1',
           'amount_total' => '500.00',
           'currency' => 'USD',
@@ -46,7 +47,7 @@ function grant_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 42375a50158b25974af1e592b396a0a65298433a..5a769c9056f045f9f4538020743f6cec82096c7c 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
- demonstrate use of getfields to interogate api
+/**
+ * Test Generated example of using group getfields API
+ * demonstrate use of getfields to interogate api *
  */
 function group_getfields_example(){
 $params = array(
-  'version' => 3,
   'action' => 'create',
 );
 
-  $result = civicrm_api( 'group','getfields',$params );
+try{
+  $result = civicrm_api3('group', 'getfields', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function group_getfields_expectedresult(){
@@ -142,7 +150,7 @@ function group_getfields_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
diff --git a/api/v3/examples/GroupContact.php b/api/v3/examples/GroupContact.php
deleted file mode 100644 (file)
index 944e989..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-
-function group_contact__example() {
-  $params = array(
-    'contact_id' => '1',
-    'group_id' => '1',
-    'version' => '3',
-  );
-  require_once 'api/api.php';
-  $result = civicrm_api('group_contact', '', $params);
-
-  return $result;
-}
-
-/*
- * Function returns array of result expected from previous function
- */
-function group_contact__expectedresult() {
-
-  $expectedResult = array(
-    'is_error' => '0',
-    'version' => '3',
-    'count' => '4',
-    'values' => array(
-      'is_error' => '0', 'not_removed' => '0', 'removed' => '1', 'total_count' => '1',
-    ),
-  );
-
-  return $expectedResult;
-}
-
index c8e8772afc5847c0f786e0d78291c10c225736ba..f41d8fb6f743902354f6d12752f57d48402105a6 100644 (file)
@@ -1,22 +1,30 @@
 <?php
-
-/*
- Get all from group and display contacts
+/**
+ * Test Generated example of using group_contact get API
+ * Get all from group and display contacts *
  */
 function group_contact_get_example(){
 $params = array(
   'group_id' => 1,
-  'version' => 3,
   'api.group.get' => 1,
   'sequential' => 1,
 );
 
-  $result = civicrm_api( 'group_contact','get',$params );
+try{
+  $result = civicrm_api3('group_contact', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function group_contact_get_expectedresult(){
@@ -105,7 +113,7 @@ function group_contact_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 1dc180c0a4a204ef25c827da442749139e3083af..309c0edfcf0319ab0561f90c797b48010ffa2a30 100644 (file)
@@ -1,22 +1,30 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using group_contact create API
+ * *
  */
 function group_contact_create_example(){
 $params = array(
   'contact_id' => 1,
   'contact_id.2' => 2,
   'group_id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'group_contact','create',$params );
+try{
+  $result = civicrm_api3('group_contact', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function group_contact_create_expectedresult(){
@@ -31,7 +39,7 @@ function group_contact_create_expectedresult(){
   'not_added' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 87ab9e311f5517c04e6b62cc08b5fc6ecb81827c..44efa758da69ce176aa7d6e046fe41dc8fee963e 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using group_contact delete API
+ * *
  */
 function group_contact_delete_example(){
 $params = array(
   'contact_id' => 1,
   'group_id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'group_contact','delete',$params );
+try{
+  $result = civicrm_api3('group_contact', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function group_contact_delete_expectedresult(){
@@ -30,7 +38,7 @@ function group_contact_delete_expectedresult(){
   'not_removed' => 0,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index aabe20108de580e62de4db8085991376f3b853a9..d808dc118a2f9dc7d1ab992e691f403a3790c7ac 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using group_contact get API
+ * *
  */
 function group_contact_get_example(){
 $params = array(
   'contact_id' => 3,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'group_contact','get',$params );
+try{
+  $result = civicrm_api3('group_contact', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function group_contact_get_expectedresult(){
@@ -31,13 +39,13 @@ function group_contact_get_expectedresult(){
           'title' => 'New Test Group Created',
           'visibility' => 'Public Pages',
           'is_hidden' => 0,
-          'in_date' => '2013-06-22 08:50:14',
+          'in_date' => '2013-07-28 08:50:19',
           'in_method' => 'API',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index f3506f99ae22d568d71e7daa6d765e99853560c5..ce5e3093d1e19bd1004ae84895e543c2dceea27a 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using group get API
+ * *
  */
 function group_get_example(){
 $params = array(
-  'version' => 3,
-  'name' => 'Test Group 1_5',
+  'name' => 'Test Group 1_4',
 );
 
-  $result = civicrm_api( 'group','get',$params );
+try{
+  $result = civicrm_api3('group', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function group_get_expectedresult(){
@@ -23,20 +31,20 @@ function group_get_expectedresult(){
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
-  'id' => 5,
+  'id' => 4,
   'values' => array(
-      '5' => array(
-          'id' => '5',
-          'name' => 'Test Group 1_5',
+      '4' => array(
+          'id' => '4',
+          'name' => 'Test Group 1_4',
           'title' => 'New Test Group Created',
           'description' => 'New Test Group Created',
           'source' => '',
           'saved_search_id' => '',
           'is_active' => '1',
           'visibility' => 'Public Pages',
-          'where_clause' => ' ( `civicrm_group_contact-5`.group_id IN ( 5 ) AND `civicrm_group_contact-5`.status IN ("Added") ) ',
-          'select_tables' => 'a:9:{s:15:"civicrm_contact";i:1;s:15:"civicrm_address";i:1;s:22:"civicrm_state_province";i:1;s:15:"civicrm_country";i:1;s:13:"civicrm_email";i:1;s:13:"civicrm_phone";i:1;s:10:"civicrm_im";i:1;s:19:"civicrm_worldregion";i:1;s:25:"`civicrm_group_contact-5`";s:114:" LEFT JOIN civicrm_group_contact `civicrm_group_contact-5` ON contact_a.id = `civicrm_group_contact-5`.contact_id ";}',
-          'where_tables' => 'a:2:{s:15:"civicrm_contact";i:1;s:25:"`civicrm_group_contact-5`";s:114:" LEFT JOIN civicrm_group_contact `civicrm_group_contact-5` ON contact_a.id = `civicrm_group_contact-5`.contact_id ";}',
+          'where_clause' => ' ( `civicrm_group_contact-4`.group_id IN ( 4 ) AND `civicrm_group_contact-4`.status IN ("Added") ) ',
+          'select_tables' => 'a:9:{s:15:"civicrm_contact";i:1;s:15:"civicrm_address";i:1;s:22:"civicrm_state_province";i:1;s:15:"civicrm_country";i:1;s:13:"civicrm_email";i:1;s:13:"civicrm_phone";i:1;s:10:"civicrm_im";i:1;s:19:"civicrm_worldregion";i:1;s:25:"`civicrm_group_contact-4`";s:114:" LEFT JOIN civicrm_group_contact `civicrm_group_contact-4` ON contact_a.id = `civicrm_group_contact-4`.contact_id ";}',
+          'where_tables' => 'a:2:{s:15:"civicrm_contact";i:1;s:25:"`civicrm_group_contact-4`";s:114:" LEFT JOIN civicrm_group_contact `civicrm_group_contact-4` ON contact_a.id = `civicrm_group_contact-4`.contact_id ";}',
           'group_type' => array(
               '0' => '1',
               '1' => '2',
@@ -52,7 +60,7 @@ function group_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 50634eabd0f8f4e0773d7d9e277061242cdea7f7..d6464fb8df5d4bef810aef045565428b2dd46a11 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using group_nesting create API
+ * *
  */
 function group_nesting_create_example(){
 $params = array(
   'parent_group_id' => 1,
   'child_group_id' => 3,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'group_nesting','create',$params );
+try{
+  $result = civicrm_api3('group_nesting', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function group_nesting_create_expectedresult(){
@@ -30,7 +38,7 @@ function group_nesting_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 6fe5997088b5304777fb1d592b0fe9bd3a102cea..f62acbbe7b4376111efc22ba6f701fca5983636e 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using group_nesting delete API
+ * *
  */
 function group_nesting_delete_example(){
 $params = array(
-  'version' => 3,
   'id' => 1,
 );
 
-  $result = civicrm_api( 'group_nesting','delete',$params );
+try{
+  $result = civicrm_api3('group_nesting', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function group_nesting_delete_expectedresult(){
@@ -26,7 +34,7 @@ function group_nesting_delete_expectedresult(){
   'values' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index ccf2b2e11397cc51761b35aef1e5c761b15dd02a..331b593c0603769e5176e961bb0659ca75f2c60f 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using group_nesting get API
+ * *
  */
 function group_nesting_get_example(){
 $params = array(
   'parent_group_id' => 1,
   'child_group_id' => 2,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'group_nesting','get',$params );
+try{
+  $result = civicrm_api3('group_nesting', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function group_nesting_get_expectedresult(){
@@ -34,7 +42,7 @@ function group_nesting_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 44f51c73adcb6ed74d501f53838f1516c70caf17..a90fe3f51b975fd391461b5879ae0efc40020885 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using group_organization create API
+ * *
  */
 function group_organization_create_example(){
 $params = array(
   'organization_id' => 1,
   'group_id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'group_organization','create',$params );
+try{
+  $result = civicrm_api3('group_organization', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function group_organization_create_expectedresult(){
@@ -32,7 +40,7 @@ function group_organization_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index ca3656287d025c39e1ba6773fa190020927a6df7..bda69751735db3101929468314db3481d6ddcaf8 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using group_organization delete API
+ * *
  */
 function group_organization_delete_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'group_organization','delete',$params );
+try{
+  $result = civicrm_api3('group_organization', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function group_organization_delete_expectedresult(){
@@ -26,7 +34,7 @@ function group_organization_delete_expectedresult(){
   'values' => 'Deleted Group Organization successfully',
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 46bce4da702432a143ff75665236d36b358ab674..aab63bb6f84bd78d1f85a4a6a1e001e9c9d5a3e9 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using group_organization get API
+ * *
  */
 function group_organization_get_example(){
 $params = array(
   'organization_id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'group_organization','get',$params );
+try{
+  $result = civicrm_api3('group_organization', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function group_organization_get_expectedresult(){
@@ -26,7 +34,7 @@ function group_organization_get_expectedresult(){
   'values' => array(),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index db62ed748704aa8c4da6b2441f75d0ef12f7c849..260d0a83a9c7daf226b6ab51efd292f5e110c5e6 100644 (file)
@@ -1,23 +1,31 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using im create API
+ * *
  */
 function im_create_example(){
 $params = array(
-  'version' => 3,
   'contact_id' => 3,
   'name' => 'My Yahoo IM Handle',
   'location_type_id' => 1,
   'provider_id' => 1,
 );
 
-  $result = civicrm_api( 'im','create',$params );
+try{
+  $result = civicrm_api3('im', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function im_create_expectedresult(){
@@ -40,7 +48,7 @@ function im_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index e9558581dfd55bd36824de993404c5f2799743c2..d74fc3ab499d642a32733ed41b022bbd374e1e7b 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using im delete API
+ * *
  */
 function im_delete_example(){
 $params = array(
-  'version' => 3,
   'id' => 1,
 );
 
-  $result = civicrm_api( 'im','delete',$params );
+try{
+  $result = civicrm_api3('im', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function im_delete_expectedresult(){
@@ -26,7 +34,7 @@ function im_delete_expectedresult(){
   'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index d8451607bd30e174125262704211a7e034ba9b44..eec5230a7c034e46d83fdaa9bd90aa766ab3fb2c 100644 (file)
@@ -1,23 +1,31 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using im get API
+ * *
  */
 function im_get_example(){
 $params = array(
-  'version' => 3,
   'contact_id' => 1,
   'name' => 'My Yahoo IM Handle',
   'location_type_id' => 1,
   'provider_id' => 1,
 );
 
-  $result = civicrm_api( 'im','get',$params );
+try{
+  $result = civicrm_api3('im', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function im_get_expectedresult(){
@@ -40,7 +48,7 @@ function im_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 7a3eb49161e0ce36351c4d245b41e820b34c7add..3ab7c9bbc1d48fa399bf131a3c21810b27dc1e21 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using job create API
+ * *
  */
 function job_create_example(){
 $params = array(
-  'version' => 3,
   'sequential' => 1,
   'name' => 'API_Test_Job',
   'description' => 'A long description written by hand in cursive',
@@ -16,12 +15,21 @@ $params = array(
   'is_active' => 1,
 );
 
-  $result = civicrm_api( 'job','create',$params );
+try{
+  $result = civicrm_api3('job', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function job_create_expectedresult(){
@@ -47,7 +55,7 @@ function job_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 970993faf1ad84c7e750e294647986083f533d5f..9e548d980570aac49dcce711c0a996bd1eabd007 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using job delete API
+ * *
  */
 function job_delete_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'job','delete',$params );
+try{
+  $result = civicrm_api3('job', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function job_delete_expectedresult(){
@@ -26,7 +34,7 @@ function job_delete_expectedresult(){
   'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index fd0ce15f35ad2760dbb0303856abee08fbdcbc1f..610970e4891daabee61b9f232b58ac16d163a870 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using line_item create API
+ * *
  */
 function line_item_create_example(){
 $params = array(
-  'version' => 3,
   'price_field_value_id' => 1,
   'price_field_id' => 1,
   'entity_table' => 'civicrm_contribution',
@@ -13,30 +12,30 @@ $params = array(
   'qty' => 1,
   'unit_price' => 50,
   'line_total' => 50,
+  'debug' => 1,
 );
 
-  $result = civicrm_api( 'line_item','create',$params );
+try{
+  $result = civicrm_api3('line_item', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function line_item_create_expectedresult(){
 
   $expectedResult = array(
   'is_error' => 0,
-  'undefined_fields' => array(
-      '0' => 'label',
-      '1' => 'price_field_value_id',
-      '2' => 'price_field_id',
-      '3' => 'entity_table',
-      '4' => 'entity_id',
-      '5' => 'qty',
-      '6' => 'unit_price',
-      '7' => 'line_total',
-    ),
   'version' => 3,
   'count' => 1,
   'id' => 1,
@@ -56,14 +55,9 @@ function line_item_create_expectedresult(){
           'deductible_amount' => '',
         ),
     ),
-  'xdebug' => array(
-      'peakMemory' => 144948640,
-      'memory' => 131358352,
-      'timeIndex' => '1877.7615101337',
-    ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index ded11f52986ba048d494c2034d64bcc27762e590..4df6f07b5ffa4690644451aa53b00fe4b902ff53 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using line_item delete API
+ * *
  */
 function line_item_delete_example(){
 $params = array(
-  'version' => 3,
   'id' => 1,
 );
 
-  $result = civicrm_api( 'line_item','delete',$params );
+try{
+  $result = civicrm_api3('line_item', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function line_item_delete_expectedresult(){
@@ -26,7 +34,7 @@ function line_item_delete_expectedresult(){
   'values' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 3e94135dba19498e18492c642affd74ecb536e92..d31b9e8474c5eeeccc6d31af252bdd69919fa3b5 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using line_item get API
+ * *
  */
 function line_item_get_example(){
 $params = array(
-  'version' => 3,
   'entity_table' => 'civicrm_contribution',
 );
 
-  $result = civicrm_api( 'line_item','get',$params );
+try{
+  $result = civicrm_api3('line_item', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function line_item_get_expectedresult(){
@@ -35,13 +43,13 @@ function line_item_get_expectedresult(){
           'unit_price' => '100.00',
           'line_total' => '100.00',
           'price_field_value_id' => '1',
-          'financial_type_id' => '3',
+          'financial_type_id' => '1',
           'deductible_amount' => '0.00',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index a2716516eea5728ba73eb1fa7bbc1ba96da4cd8c..61ecaaf53c2571145db76601dd33b15f9b71b7a7 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using loc_block create API
+ * *
  */
 function loc_block_create_example(){
 $params = array(
@@ -10,12 +10,21 @@ $params = array(
   'email_id' => 3,
 );
 
-  $result = civicrm_api( 'loc_block','create',$params );
+try{
+  $result = civicrm_api3('loc_block', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function loc_block_create_expectedresult(){
@@ -38,14 +47,9 @@ function loc_block_create_expectedresult(){
           'im_2_id' => '',
         ),
     ),
-  'xdebug' => array(
-      'peakMemory' => 145366376,
-      'memory' => 131621280,
-      'timeIndex' => '1882.6170191765',
-    ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index a71bf66096557a013d3dcd866250aabc6887725e..c205135a92d1ffdc9654ed6144ab30a73e9a2b67 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
- Create entities and location block in 1 api call
+/**
+ * Test Generated example of using loc_block createEntities API
+ * Create entities and location block in 1 api call *
  */
 function loc_block_createentities_example(){
 $params = array(
@@ -21,16 +21,23 @@ $params = array(
       'location_type_id' => 1,
       'street_address' => '987654321',
     ),
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'loc_block','createEntities',$params );
+try{
+  $result = civicrm_api3('loc_block', 'createEntities', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function loc_block_createentities_expectedresult(){
@@ -101,7 +108,7 @@ function loc_block_createentities_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 86e7d42ab7c0c792cbd68cc1fdcf3a94dd7746a7..870dbe84d55dc30960d0fcb7a2ffa6aff6756baf 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
- Get entities and location block in 1 api call
+/**
+ * Test Generated example of using loc_block get API
+ * Get entities and location block in 1 api call *
  */
 function loc_block_get_example(){
 $params = array(
-  'version' => 3,
   'id' => 3,
   'return' => 'all',
 );
 
-  $result = civicrm_api( 'loc_block','get',$params );
+try{
+  $result = civicrm_api3('loc_block', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function loc_block_get_expectedresult(){
@@ -61,7 +69,7 @@ function loc_block_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index bb6a60a6ce7d9df58f86835b3b6f439d37cb57d0..7c8690d76ce59c8962c82b9dc5f32336e750bca5 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
- demonstrates get + delete in the same call
+/**
+ * Test Generated example of using mail_settings get API
+ * demonstrates get + delete in the same call *
  */
 function mail_settings_get_example(){
 $params = array(
-  'version' => 3,
   'title' => 'MailSettings title',
   'api.MailSettings.delete' => 1,
 );
 
-  $result = civicrm_api( 'mail_settings','get',$params );
+try{
+  $result = civicrm_api3('mail_settings', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function mail_settings_get_expectedresult(){
@@ -58,7 +66,7 @@ function mail_settings_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index b8f246187f8d466af7dd0a76d27bda98b9197c4d..072e60d2a533e17a5334787cb94e3ca64fe3e8c9 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using mail_settings create API
+ * *
  */
 function mail_settings_create_example(){
 $params = array(
@@ -12,15 +12,23 @@ $params = array(
   'server' => 'localhost',
   'username' => 'sue',
   'password' => 'pass',
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'mail_settings','create',$params );
+try{
+  $result = civicrm_api3('mail_settings', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function mail_settings_create_expectedresult(){
@@ -50,7 +58,7 @@ function mail_settings_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index bcd66dfcb73a33466728a7edfc0c658a236ab46f..b062459b55f6a9764d8217e52b2da778925d5435 100644 (file)
@@ -1,26 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using mail_settings delete API
+ * *
  */
 function mail_settings_delete_example(){
 $params = array(
-  'domain_id' => 1,
-  'name' => 'my mail setting',
-  'domain' => 'setting.com',
-  'local_part' => 'civicrm+',
-  'server' => 'localhost',
-  'username' => 'sue',
-  'password' => 'pass',
-  'version' => 3,
+  'id' => 2,
 );
 
-  $result = civicrm_api( 'mail_settings','delete',$params );
+try{
+  $result = civicrm_api3('mail_settings', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function mail_settings_delete_expectedresult(){
@@ -32,7 +34,7 @@ function mail_settings_delete_expectedresult(){
   'values' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index c5090886c51315c0a0c9395c15f870bbb4618d56..69959acc521f745b2d3421ff47c1667f7fb4c2f7 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using mail_settings get API
+ * *
  */
 function mail_settings_get_example(){
 $params = array(
@@ -12,15 +12,23 @@ $params = array(
   'server' => 'localhost',
   'username' => 'sue',
   'password' => 'pass',
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'mail_settings','get',$params );
+try{
+  $result = civicrm_api3('mail_settings', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function mail_settings_get_expectedresult(){
@@ -45,7 +53,7 @@ function mail_settings_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 8ef2f999f946e7f8fa8e948bab1f7ad357ae2219..7fab57269cbec9afe2878d450d4a4ebef5562a99 100644 (file)
@@ -1,23 +1,31 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using mailing create API
+ * *
  */
 function mailing_create_example(){
 $params = array(
   'subject' => 'maild',
   'body_text' => 'bdkfhdskfhduew',
-  'version' => 3,
   'name' => 'mailing name',
   'created_id' => 1,
 );
 
-  $result = civicrm_api( 'mailing','create',$params );
+try{
+  $result = civicrm_api3('mailing', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function mailing_create_expectedresult(){
@@ -52,11 +60,11 @@ function mailing_create_expectedresult(){
           'msg_template_id' => '',
           'override_verp' => '1',
           'created_id' => '1',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'scheduled_id' => '',
-          'scheduled_date' => '20130622085501',
+          'scheduled_date' => '20130728085413',
           'approver_id' => '1',
-          'approval_date' => '20130622085501',
+          'approval_date' => '20130728085413',
           'approval_status_id' => '',
           'approval_note' => '',
           'is_archived' => '',
@@ -73,7 +81,7 @@ function mailing_create_expectedresult(){
                   '0' => array(
                       'id' => '1',
                       'mailing_id' => '1',
-                      'scheduled_date' => '20130622085501',
+                      'scheduled_date' => '20130728085413',
                       'start_date' => '',
                       'end_date' => '',
                       'status' => 'Scheduled',
@@ -89,7 +97,7 @@ function mailing_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
similarity index 55%
rename from api/v3/examples/ActivityTypeDelete.php
rename to api/v3/examples/MailingDelete.php
index b087ac58e7f71ac4c95b4dd2e0e2131b7746caa8..17282a221bf1836cbc00a91f97dc810868f4c72d 100644 (file)
@@ -1,38 +1,48 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using mailing delete API
+ * *
  */
-function activity_type_delete_example(){
+function mailing_delete_example(){
 $params = array(
-  'activity_type_id' => 724,
-  'version' => 3,
+  'id' => 2,
 );
 
-  $result = civicrm_api( 'activity_type','delete',$params );
+try{
+  $result = civicrm_api3('mailing', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
-function activity_type_delete_expectedresult(){
+function mailing_delete_expectedresult(){
 
   $expectedResult = array(
-  'is_error' => 1,
-  'error_message' => 'Undefined index: activity_type_id',
+  'is_error' => 0,
+  'version' => 3,
+  'count' => 1,
+  'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
 /*
 * This example has been generated from the API test suite. The test that created it is called
 *
-* testActivityTypeDelete and can be found in
-* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ActivityTypeTest.php
+* testMailerDeleteSuccess and can be found in
+* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/MailingTest.php
 *
 * You can see the outcome of the API tests at
 * http://tests.dev.civicrm.org/trunk/results-api_v3
index 6ed2b2c18afbf189d9cee9f9f174f1ad7ff85200..99821a9f64b5742c75adbfc34b4fa0aa37d13ed9 100644 (file)
@@ -1,24 +1,32 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using mailing_group subscribe API
+ * *
  */
 function mailing_group_subscribe_example(){
 $params = array(
   'email' => 'test@test.test',
   'group_id' => 2,
   'contact_id' => 3,
-  'version' => 3,
   'hash' => 'b15de8b64e2cec34',
   'time_stamp' => '20101212121212',
 );
 
-  $result = civicrm_api( 'mailing_group','subscribe',$params );
+try{
+  $result = civicrm_api3('mailing_group', 'subscribe', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function mailing_group_subscribe_expectedresult(){
@@ -30,12 +38,12 @@ function mailing_group_subscribe_expectedresult(){
   'values' => array(
       'contact_id' => '3',
       'subscribe_id' => '1',
-      'hash' => '5b056fa32d2d56c6',
+      'hash' => 'fcf4e727e2a34e5d',
       'is_error' => 0,
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index db786971a980dbb211e3218995cbcc59bb5f279e..2bf364e3ab437a151d72b4a2e94a27f57536f49e 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
- Demonstrates use of 'filter' active_only' param
+/**
+ * Test Generated example of using membership get API
+ * Demonstrates use of 'filter' active_only' param *
  */
 function membership_get_example(){
 $params = array(
@@ -9,15 +9,23 @@ $params = array(
   'filters' => array(
       'is_current' => 1,
     ),
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'membership','get',$params );
+try{
+  $result = civicrm_api3('membership', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function membership_get_expectedresult(){
@@ -53,7 +61,7 @@ function membership_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 82fbdfe3f91e33dda7fe5a41ac47cccef863ef68..47ec1be3ba64a67c3310070b6c046effff4c4264 100644 (file)
@@ -1,28 +1,36 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using membership create API
+ * *
  */
 function membership_create_example(){
 $params = array(
-  'contact_id' => 26,
-  'membership_type_id' => 23,
+  'contact_id' => 25,
+  'membership_type_id' => 22,
   'join_date' => '2009-01-21',
   'start_date' => '2009-01-21',
   'end_date' => '2009-12-21',
   'source' => 'Payment',
   'is_override' => 1,
-  'status_id' => 29,
-  'version' => 3,
-  'custom_2' => 'custom string',
+  'status_id' => 28,
+  'custom_1' => 'custom string',
 );
 
-  $result = civicrm_api( 'membership','create',$params );
+try{
+  $result = civicrm_api3('membership', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function membership_create_expectedresult(){
@@ -35,13 +43,13 @@ function membership_create_expectedresult(){
   'values' => array(
       '1' => array(
           'id' => '1',
-          'contact_id' => '26',
-          'membership_type_id' => '23',
+          'contact_id' => '25',
+          'membership_type_id' => '22',
           'join_date' => '20090121000000',
           'start_date' => '20090121000000',
           'end_date' => '20091221000000',
           'source' => 'Payment',
-          'status_id' => '29',
+          'status_id' => '28',
           'is_override' => '1',
           'owner_membership_id' => '',
           'max_related' => '',
@@ -53,7 +61,7 @@ function membership_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 610dbcdc65d4d05a754896ba1dc8f9d214ad886b..cd2426bcb841abca1948721c9f0dfa6a3688e864 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using membership delete API
+ * *
  */
 function membership_delete_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'membership','delete',$params );
+try{
+  $result = civicrm_api3('membership', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function membership_delete_expectedresult(){
@@ -23,10 +31,10 @@ function membership_delete_expectedresult(){
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
-  'values' => 1,
+  'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 2a02a7cf35dbea55abd752525713cb985332bdc4..fe5bcf09042a7b5dd25d575d208d10cf4f293255 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using membership get API
+ * *
  */
 function membership_get_example(){
 $params = array(
-  'version' => 3,
   'membership_type_id' => 8,
 );
 
-  $result = civicrm_api( 'membership','get',$params );
+try{
+  $result = civicrm_api3('membership', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function membership_get_expectedresult(){
@@ -45,7 +53,7 @@ function membership_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 73e675b554ae594147506220785fd0143b7f0235..d58e0e13469a2f25cdc315ea10ed1ca0feda2ab4 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using membership_payment create API
+ * *
  */
 function membership_payment_create_example(){
 $params = array(
   'contribution_id' => 1,
   'membership_id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'membership_payment','create',$params );
+try{
+  $result = civicrm_api3('membership_payment', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function membership_payment_create_expectedresult(){
@@ -34,7 +42,7 @@ function membership_payment_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 42e5b15a49c177b9d8be48d21e140e0932cabbb1..c1bc97bc87181f5af25f71e97a51ff1ea582beeb 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using membership_payment get API
+ * *
  */
 function membership_payment_get_example(){
 $params = array(
   'contribution_id' => 1,
   'membership_id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'membership_payment','get',$params );
+try{
+  $result = civicrm_api3('membership_payment', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function membership_payment_get_expectedresult(){
@@ -34,7 +42,7 @@ function membership_payment_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 970706cb3b09a3c76659ba9ab9a72cb2da56c517..fd17f8549762a3ef58412fb86f03b4a9865fe201 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using membership_status create API
+ * *
  */
 function membership_status_create_example(){
 $params = array(
   'name' => 'test membership status',
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'membership_status','create',$params );
+try{
+  $result = civicrm_api3('membership_status', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function membership_status_create_expectedresult(){
@@ -23,10 +31,10 @@ function membership_status_create_expectedresult(){
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
-  'id' => 19,
+  'id' => 15,
   'values' => array(
-      '19' => array(
-          'id' => '19',
+      '15' => array(
+          'id' => '15',
           'name' => 'test membership status',
           'label' => 'test membership status',
           'start_event' => '',
@@ -45,7 +53,7 @@ function membership_status_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 7e21356c0da7a06bd2ce46e1c1249f15ba3f34a7..3de04001feb8521ac89cd9b975e03925e2d015ad 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using membership_status get API
+ * *
  */
 function membership_status_get_example(){
 $params = array(
   'name' => 'test status',
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'membership_status','get',$params );
+try{
+  $result = civicrm_api3('membership_status', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function membership_status_get_expectedresult(){
@@ -23,10 +31,10 @@ function membership_status_get_expectedresult(){
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
-  'id' => 10,
+  'id' => 9,
   'values' => array(
-      '10' => array(
-          'id' => '10',
+      '9' => array(
+          'id' => '9',
           'name' => 'test status',
           'label' => 'test status',
           'start_event' => 'start_date',
@@ -40,7 +48,7 @@ function membership_status_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index a48de6940f99ea6ff178118721eba2e5e247fdf8..3eca2da079d4b3438ab765558660c1c844ddb40a 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using membership_type create API
+ * *
  */
 function membership_type_create_example(){
 $params = array(
@@ -15,15 +15,23 @@ $params = array(
   'duration_interval' => '10',
   'period_type' => 'rolling',
   'visibility' => 'public',
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'membership_type','create',$params );
+try{
+  $result = civicrm_api3('membership_type', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function membership_type_create_expectedresult(){
@@ -61,7 +69,7 @@ function membership_type_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 584d6d7892ecb0f9b0ccd1ad5d5dc3802af502e7..8baab176e284aec9a7c350498bdf71bae6d48779 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using membership_type delete API
+ * *
  */
 function membership_type_delete_example(){
 $params = array(
   'id' => 4,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'membership_type','delete',$params );
+try{
+  $result = civicrm_api3('membership_type', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function membership_type_delete_expectedresult(){
@@ -26,7 +34,7 @@ function membership_type_delete_expectedresult(){
   'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 482b6d59d3b81acc92853e78b3332c58942b8a13..8bcb08be2a06c8d74fde06306c87b846ffe86637 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using membership_type get API
+ * *
  */
 function membership_type_get_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'membership_type','get',$params );
+try{
+  $result = civicrm_api3('membership_type', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function membership_type_get_expectedresult(){
@@ -42,7 +50,7 @@ function membership_type_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index b0b17bcbf990b7bb39e45d98b5920b58a7d967db..53ecc5e6525162f17d59fb1f9e2634a3a0d22514 100644 (file)
@@ -1,28 +1,36 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using membership update API
+ * *
  */
 function membership_update_example(){
 $params = array(
-  'contact_id' => 32,
-  'membership_type_id' => 29,
+  'contact_id' => 31,
+  'membership_type_id' => 28,
   'join_date' => '2009-01-21',
   'start_date' => '2009-01-21',
   'end_date' => '2009-12-21',
   'source' => 'Payment',
   'is_override' => 1,
-  'status_id' => 35,
-  'version' => 3,
-  'custom_3' => 'custom string',
+  'status_id' => 34,
+  'custom_1' => 'custom string',
 );
 
-  $result = civicrm_api( 'membership','update',$params );
+try{
+  $result = civicrm_api3('membership', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function membership_update_expectedresult(){
@@ -35,13 +43,13 @@ function membership_update_expectedresult(){
   'values' => array(
       '1' => array(
           'id' => '1',
-          'contact_id' => '32',
-          'membership_type_id' => '29',
+          'contact_id' => '31',
+          'membership_type_id' => '28',
           'join_date' => '20090121000000',
           'start_date' => '20090121000000',
           'end_date' => '20091221000000',
           'source' => 'Payment',
-          'status_id' => '35',
+          'status_id' => '34',
           'is_override' => '1',
           'owner_membership_id' => '',
           'max_related' => '',
@@ -53,7 +61,7 @@ function membership_update_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 43a4a16454abca11b1de1cac5faa7307f74366c9..469f4087367b08cf900adc0b06db2c558800d227 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using note create API
+ * *
  */
 function note_create_example(){
 $params = array(
@@ -11,15 +11,23 @@ $params = array(
   'contact_id' => 1,
   'modified_date' => '2011-01-31',
   'subject' => 'Test Note',
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'note','create',$params );
+try{
+  $result = civicrm_api3('note', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function note_create_expectedresult(){
@@ -43,7 +51,7 @@ function note_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 07d637bfdc7fcd890399586b0998dcf3b4671f4d..e8933772c00e806493a3c4a64202d5fe2a74cec2 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using note delete API
+ * *
  */
 function note_delete_example(){
 $params = array(
   'id' => 2,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'note','delete',$params );
+try{
+  $result = civicrm_api3('note', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function note_delete_expectedresult(){
@@ -26,7 +34,7 @@ function note_delete_expectedresult(){
   'values' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 51fca52077d20c50219482bbb0a34495e6d14428..ebd17d2fe47512e1d8142f25927cee2b448a37a1 100644 (file)
@@ -1,25 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using note get API
+ * *
  */
 function note_get_example(){
 $params = array(
   'entity_table' => 'civicrm_contact',
   'entity_id' => 1,
-  'note' => 'Hello!!! m testing Note',
-  'contact_id' => 1,
-  'modified_date' => '2011-01-31',
-  'subject' => 'Test Note',
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'note','get',$params );
+try{
+  $result = civicrm_api3('note', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function note_get_expectedresult(){
@@ -43,7 +47,7 @@ function note_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 716e59c91455a3168ccbbb63836f849b687d0842..32097c168202aa0c7d037eb1da1b86e46ef52564 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using option_group create API
+ * *
  */
 function option_group_create_example(){
 $params = array(
-  'version' => 3,
   'sequential' => 1,
   'name' => 'civicrm_event.amount.560',
   'is_reserved' => 1,
@@ -17,15 +16,23 @@ $params = array(
       'is_active' => 1,
       'format.only_id' => 1,
     ),
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'option_group','create',$params );
+try{
+  $result = civicrm_api3('option_group', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function option_group_create_expectedresult(){
@@ -34,21 +41,21 @@ function option_group_create_expectedresult(){
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
-  'id' => 84,
+  'id' => 86,
   'values' => array(
       '0' => array(
-          'id' => '84',
+          'id' => '86',
           'name' => 'civicrm_event.amount.560',
           'title' => '',
           'description' => '',
           'is_reserved' => '1',
           'is_active' => '1',
-          'api.OptionValue.create' => 720,
+          'api.OptionValue.create' => 722,
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 2c2d23f22824fc29b5cac973b1edbca989c6198b..5a40f3e5abfb9d3f5b61cb8fa3e4040f7484843e 100644 (file)
@@ -1,21 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using option_group delete API
+ * *
  */
 function option_group_delete_example(){
 $params = array(
-  'id' => 89,
-  'version' => 3,
-  'debug' => 0,
+  'id' => 91,
 );
 
-  $result = civicrm_api( 'option_group','delete',$params );
+try{
+  $result = civicrm_api3('option_group', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function option_group_delete_expectedresult(){
@@ -27,7 +34,7 @@ function option_group_delete_expectedresult(){
   'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index d0e10240f3283f34ab02da94bcc4bf355a4541e1..735b63968905deca383fb4bf4cbde32a986468dc 100644 (file)
@@ -1,21 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using option_group get API
+ * *
  */
 function option_group_get_example(){
 $params = array(
   'name' => 'preferred_communication_method',
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'option_group','get',$params );
+try{
+  $result = civicrm_api3('option_group', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function option_group_get_expectedresult(){
@@ -36,7 +43,7 @@ function option_group_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 600344324312c6f4315a5f0394ad698e3836b1d8..367e3ce6b0d29cc41f9da3eb219d1db3fc604d23 100644 (file)
@@ -1,24 +1,32 @@
 <?php
-
-/*
- demonstrates use of Sort param (available in many api functions). Also, getsingle
+/**
+ * Test Generated example of using option_value getsingle API
+ * demonstrates use of Sort param (available in many api functions). Also, getsingle *
  */
 function option_value_getsingle_example(){
 $params = array(
   'option_group_id' => 1,
-  'version' => 3,
   'options' => array(
       'sort' => 'label DESC',
       'limit' => 1,
     ),
 );
 
-  $result = civicrm_api( 'option_value','getsingle',$params );
+try{
+  $result = civicrm_api3('option_value', 'getsingle', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function option_value_getsingle_expectedresult(){
@@ -35,7 +43,7 @@ function option_value_getsingle_expectedresult(){
   'is_active' => '1',
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index dbce441a53da0f8b605dc8f6c792c69b779b9468..9e02dc309f6bc2f52b50206dce64e3370dc9cf05 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using option_value get API
+ * *
  */
 function option_value_get_example(){
 $params = array(
   'option_group_id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'option_value','get',$params );
+try{
+  $result = civicrm_api3('option_value', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function option_value_get_expectedresult(){
@@ -82,7 +90,7 @@ function option_value_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 4c9df79844e832e03dd1ee80f771c307bcca4614..64b9ea3f957bc9aacbde70b5fa7d3153193736bf 100644 (file)
@@ -1,16 +1,15 @@
 <?php
-
-/*
- single function to create contact w partipation & contribution. Note that in the
-      case of 'contribution' the 'create' is implied (api.contribution.create)
+/**
+ * Test Generated example of using participant create API
single function to create contact w partipation & contribution. Note that in the
+      case of 'contribution' the 'create' is implied (api.contribution.create) *
  */
 function participant_create_example(){
 $params = array(
   'contact_type' => 'Individual',
   'display_name' => 'dlobo',
-  'version' => 3,
   'api.participant' => array(
-      'event_id' => 38,
+      'event_id' => 39,
       'status_id' => 1,
       'role_id' => 1,
       'format.only_id' => 1,
@@ -26,12 +25,21 @@ $params = array(
     ),
 );
 
-  $result = civicrm_api( 'participant','create',$params );
+try{
+  $result = civicrm_api3('participant', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function participant_create_expectedresult(){
@@ -67,8 +75,6 @@ function participant_create_expectedresult(){
           'first_name' => '',
           'middle_name' => '',
           'last_name' => '',
-          'prefix_id' => '',
-          'suffix_id' => '',
           'email_greeting_id' => '1',
           'email_greeting_custom' => '',
           'email_greeting_display' => '',
@@ -88,7 +94,7 @@ function participant_create_expectedresult(){
           'organization_name' => '',
           'sic_code' => '',
           'user_unique_id' => '',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'modified_date' => '2012-11-14 16:02:35',
           'api.participant' => 4,
           'api.contribution.create' => 1,
@@ -109,7 +115,7 @@ function participant_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index d786d42fe2288f95f58a538e047b41bebb40b654..a2a9bc18f376aea5034d61e593910ba822210024 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
- Criteria delete by nesting a GET & a DELETE
+/**
+ * Test Generated example of using participant Get API
+ * Criteria delete by nesting a GET & a DELETE *
  */
 function participant_get_example(){
 $params = array(
-  'version' => 3,
   'contact_id' => 4,
   'api.participant.delete' => 1,
 );
 
-  $result = civicrm_api( 'participant','Get',$params );
+try{
+  $result = civicrm_api3('participant', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function participant_get_expectedresult(){
@@ -31,7 +39,7 @@ function participant_get_expectedresult(){
           'contact_sub_type' => '',
           'sort_name' => 'Anderson, Anthony',
           'display_name' => 'Mr. Anthony Anderson II',
-          'event_id' => '37',
+          'event_id' => '38',
           'event_title' => 'Annual CiviCRM meet',
           'event_start_date' => '2008-10-21 00:00:00',
           'event_end_date' => '2008-10-23 00:00:00',
@@ -65,7 +73,7 @@ function participant_get_expectedresult(){
           'contact_sub_type' => '',
           'sort_name' => 'Anderson, Anthony',
           'display_name' => 'Mr. Anthony Anderson II',
-          'event_id' => '37',
+          'event_id' => '38',
           'event_title' => 'Annual CiviCRM meet',
           'event_start_date' => '2008-10-21 00:00:00',
           'event_end_date' => '2008-10-23 00:00:00',
@@ -96,7 +104,7 @@ function participant_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index aeb472a37b13117ff095114d941e638ae443044a..d4b3cf5cfe500ff432d7ee0fb4f9cb41da21fd4e 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
- use nested get to get an event
+/**
+ * Test Generated example of using participant get API
+ * use nested get to get an event *
  */
 function participant_get_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
   'api.event.get' => 1,
 );
 
-  $result = civicrm_api( 'participant','get',$params );
+try{
+  $result = civicrm_api3('participant', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function participant_get_expectedresult(){
@@ -89,7 +97,7 @@ function participant_get_expectedresult(){
                       'is_multiple_registrations' => 0,
                       'allow_same_participant_emails' => 0,
                       'is_template' => 0,
-                      'created_date' => '2013-06-22 09:01:44',
+                      'created_date' => '2013-07-28 05:52:14',
                       'is_share' => '1',
                     ),
                 ),
@@ -98,7 +106,7 @@ function participant_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 5506ab3fea7948a15e20638814a8e8191cd2cb82..735322b0c97611957fe48dd553503b2dff4e4c41 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using participant create API
+ * *
  */
 function participant_create_example(){
 $params = array(
@@ -11,16 +11,24 @@ $params = array(
   'role_id' => 1,
   'register_date' => '2007-07-21 00:00:00',
   'source' => 'Online Event Registration: API Testing',
-  'version' => 3,
   'custom_1' => 'custom string',
 );
 
-  $result = civicrm_api( 'participant','create',$params );
+try{
+  $result = civicrm_api3('participant', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function participant_create_expectedresult(){
@@ -54,7 +62,7 @@ function participant_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 79bf4375008f862c9fcf8b2df8d45f18204d2b92..9e4e31a827de7041308f7e25260c32d5527b900b 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using participant get API
+ * *
  */
 function participant_get_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'participant','get',$params );
+try{
+  $result = civicrm_api3('participant', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function participant_get_expectedresult(){
@@ -56,7 +64,7 @@ function participant_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index f6be1196030e82f79488aa8cf120e980055ae529..3e1b68ed03e94e8528a7e0608a417185338635d7 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using participant_payment create API
+ * *
  */
 function participant_payment_create_example(){
 $params = array(
   'participant_id' => 1,
   'contribution_id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'participant_payment','create',$params );
+try{
+  $result = civicrm_api3('participant_payment', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function participant_payment_create_expectedresult(){
@@ -34,7 +42,7 @@ function participant_payment_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index dbe31358733177d854bbe3e02994b2f06934cdb7..b0a938ff2ca63bad0ffbdb2ac64b9ba5b382e054 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using participant_payment delete API
+ * *
  */
 function participant_payment_delete_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'participant_payment','delete',$params );
+try{
+  $result = civicrm_api3('participant_payment', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function participant_payment_delete_expectedresult(){
@@ -26,7 +34,7 @@ function participant_payment_delete_expectedresult(){
   'values' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 455d1470d17c820cd6a9809ee9f8b34a63ed40ea..4f2d73a8eeb98e0f3064fb366fd833cb31036489 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using participant_payment get API
+ * *
  */
 function participant_payment_get_example(){
 $params = array(
   'participant_id' => 4,
   'contribution_id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'participant_payment','get',$params );
+try{
+  $result = civicrm_api3('participant_payment', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function participant_payment_get_expectedresult(){
@@ -34,7 +42,7 @@ function participant_payment_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 086accb61b6f69a97ab8db22cd3c82d9a2099300..8ddd44e15d8bf195b1c7c5b223fdecd60e2ea436 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using participant_status_type create API
+ * *
  */
 function participant_status_type_create_example(){
 $params = array(
-  'version' => 3,
   'name' => 'test status',
   'label' => 'I am a test',
   'class' => 'Positive',
@@ -16,12 +15,21 @@ $params = array(
   'weight' => 10,
 );
 
-  $result = civicrm_api( 'participant_status_type','create',$params );
+try{
+  $result = civicrm_api3('participant_status_type', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function participant_status_type_create_expectedresult(){
@@ -46,7 +54,7 @@ function participant_status_type_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 21c69628e333624dea3ce53bf24cbdd9b59f423f..7f40197884b28a887630a72d112cdcc3005606cc 100644 (file)
@@ -1,27 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using participant_status_type delete API
+ * *
  */
 function participant_status_type_delete_example(){
 $params = array(
-  'version' => 3,
-  'name' => 'test status',
-  'label' => 'I am a test',
-  'class' => 'Positive',
-  'is_reserved' => 0,
-  'is_active' => 1,
-  'is_counted' => 1,
-  'visibility_id' => 1,
-  'weight' => 10,
+  'id' => 15,
 );
 
-  $result = civicrm_api( 'participant_status_type','delete',$params );
+try{
+  $result = civicrm_api3('participant_status_type', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function participant_status_type_delete_expectedresult(){
@@ -33,7 +34,7 @@ function participant_status_type_delete_expectedresult(){
   'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 4272c2b03232b0753ec21543a32235e0676e161b..1b170f6adfbde7ce1891c1f4c7510202a47d821b 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using participant_status_type get API
+ * *
  */
 function participant_status_type_get_example(){
 $params = array(
-  'version' => 3,
   'name' => 'test status',
   'label' => 'I am a test',
   'class' => 'Positive',
@@ -16,12 +15,21 @@ $params = array(
   'weight' => 10,
 );
 
-  $result = civicrm_api( 'participant_status_type','get',$params );
+try{
+  $result = civicrm_api3('participant_status_type', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function participant_status_type_get_expectedresult(){
@@ -46,7 +54,7 @@ function participant_status_type_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 0a1443836004d332712f7c8325a898d765869066..355335619087fa4fa09a900d70dbebde1771db4f 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using payment_processor create API
+ * *
  */
 function payment_processor_create_example(){
 $params = array(
-  'version' => 3,
   'name' => 'API Test PP',
   'payment_processor_type_id' => 1,
   'class_name' => 'CRM_Core_Payment_APITest',
@@ -13,12 +12,21 @@ $params = array(
   'domain_id' => 1,
 );
 
-  $result = civicrm_api( 'payment_processor','create',$params );
+try{
+  $result = civicrm_api3('payment_processor', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function payment_processor_create_expectedresult(){
@@ -54,7 +62,7 @@ function payment_processor_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 5ab82e1a7077da8f796a365709d37c53a7d67022..392986fa5bd98c95769bbff5ac8881ac7ea037e6 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using payment_processor delete API
+ * *
  */
 function payment_processor_delete_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'payment_processor','delete',$params );
+try{
+  $result = civicrm_api3('payment_processor', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function payment_processor_delete_expectedresult(){
@@ -26,7 +34,7 @@ function payment_processor_delete_expectedresult(){
   'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 37d49d6c0b59cc97010406a43c673fd8f6dfaf9a..3159cd3a41c5e98f3d5e3c23ebc7e5b67457c0c7 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using payment_processor_type create API
+ * *
  */
 function payment_processor_type_create_example(){
 $params = array(
-  'version' => 3,
   'sequential' => 1,
   'name' => 'API_Test_PP',
   'title' => 'API Test Payment Processor',
@@ -14,12 +13,21 @@ $params = array(
   'is_recur' => 0,
 );
 
-  $result = civicrm_api( 'payment_processor_type','create',$params );
+try{
+  $result = civicrm_api3('payment_processor_type', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function payment_processor_type_create_expectedresult(){
@@ -57,7 +65,7 @@ function payment_processor_type_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 3deaf5ce54295510f9cd3172715ef752744fd5c5..2d8b47f8d31942b80e00453f761fc0788baf4254 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using payment_processor_type delete API
+ * *
  */
 function payment_processor_type_delete_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'payment_processor_type','delete',$params );
+try{
+  $result = civicrm_api3('payment_processor_type', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function payment_processor_type_delete_expectedresult(){
@@ -26,7 +34,7 @@ function payment_processor_type_delete_expectedresult(){
   'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index c6c79295f3a385968e76596974a633c06f847ed0..7a2b6c860423b1b6f68c10e205d63ba9abc21d0b 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using phone create API
+ * *
  */
 function phone_create_example(){
 $params = array(
@@ -9,16 +9,24 @@ $params = array(
   'location_type_id' => 6,
   'phone' => '(123) 456-7890',
   'is_primary' => 1,
-  'version' => 3,
   'phone_type_id' => 1,
 );
 
-  $result = civicrm_api( 'phone','create',$params );
+try{
+  $result = civicrm_api3('phone', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function phone_create_expectedresult(){
@@ -44,7 +52,7 @@ function phone_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index c2df8d4289e43ee6468b95862cdbf976ed3c22c1..d5dc2f2d9bc4ac5bed69d4f154e501761bca2b23 100644 (file)
@@ -1,24 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using phone delete API
+ * *
  */
 function phone_delete_example(){
 $params = array(
-  'contact_id' => 4,
-  'location_type_id' => 7,
-  'phone' => '(123) 456-7890',
-  'is_primary' => 1,
-  'version' => 3,
-  'phone_type_id' => 1,
+  'id' => 1,
 );
 
-  $result = civicrm_api( 'phone','delete',$params );
+try{
+  $result = civicrm_api3('phone', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function phone_delete_expectedresult(){
@@ -30,7 +34,7 @@ function phone_delete_expectedresult(){
   'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index b8f6c15b0b30c66c238ec555626209726616a0a9..a590a57046071e712bc8ed32d594fddc02a2d3ed 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using phone get API
+ * *
  */
 function phone_get_example(){
 $params = array(
-  'contact_id' => 8,
+  'contact_id' => 7,
   'phone' => '(123) 456-7890',
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'phone','get',$params );
+try{
+  $result = civicrm_api3('phone', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function phone_get_expectedresult(){
@@ -28,8 +36,8 @@ function phone_get_expectedresult(){
   'values' => array(
       '1' => array(
           'id' => '1',
-          'contact_id' => '8',
-          'location_type_id' => '11',
+          'contact_id' => '7',
+          'location_type_id' => '10',
           'is_primary' => '1',
           'is_billing' => 0,
           'phone' => '(123) 456-7890',
@@ -39,7 +47,7 @@ function phone_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index df3d7f8b4a1b49ee812815aa4e1e41fdd71e497d..7ab91d0fc52f90a425116003f69889bbeab30062 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
- demonstrates high date filter
+/**
+ * Test Generated example of using pledge get API
+ * demonstrates high date filter *
  */
 function pledge_get_example(){
 $params = array(
-  'version' => 3,
-  'pledge_start_date_high' => '20130620090530',
+  'pledge_start_date_high' => '20130726090416',
 );
 
-  $result = civicrm_api( 'pledge','get',$params );
+try{
+  $result = civicrm_api3('pledge', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function pledge_get_expectedresult(){
@@ -33,7 +41,7 @@ function pledge_get_expectedresult(){
           'display_name' => 'Mr. Anthony Anderson II',
           'pledge_id' => '2',
           'pledge_amount' => '100.00',
-          'pledge_create_date' => '2013-06-22 00:00:00',
+          'pledge_create_date' => '2013-07-28 00:00:00',
           'pledge_status' => 'Overdue',
           'pledge_total_paid' => '',
           'pledge_next_pay_date' => '2012-03-02 00:00:00',
@@ -51,7 +59,7 @@ function pledge_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index b90a03fb5f848be1e70d489dfe8387a8c5aa4a3a..70b6ad53173bcc60df9e1575b2880c0a734a3f4f 100644 (file)
@@ -1,14 +1,14 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using pledge create API
+ * *
  */
 function pledge_create_example(){
 $params = array(
   'contact_id' => 11,
-  'pledge_create_date' => '20130622',
-  'start_date' => '20130622',
-  'scheduled_date' => '20130624',
+  'pledge_create_date' => '20130728',
+  'start_date' => '20130728',
+  'scheduled_date' => '20130730',
   'amount' => '100',
   'pledge_status_id' => '2',
   'pledge_financial_type_id' => '1',
@@ -18,15 +18,23 @@ $params = array(
   'frequency_day' => 15,
   'installments' => 5,
   'sequential' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'pledge','create',$params );
+try{
+  $result = civicrm_api3('pledge', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function pledge_create_expectedresult(){
@@ -49,8 +57,8 @@ function pledge_create_expectedresult(){
           'frequency_interval' => '5',
           'frequency_day' => '15',
           'installments' => '5',
-          'start_date' => '20130622000000',
-          'create_date' => '20130622000000',
+          'start_date' => '20130728000000',
+          'create_date' => '20120130621222105',
           'acknowledge_date' => '',
           'modified_date' => '2012-11-14 16:02:35',
           'cancel_date' => '',
@@ -67,7 +75,7 @@ function pledge_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 56ef1f5803e9ac4a5604209df4cb4aa454256c70..d83fa0e8bd8c30fd3ac2d5e34240554cedc94b36 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using pledge delete API
+ * *
  */
 function pledge_delete_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'pledge','delete',$params );
+try{
+  $result = civicrm_api3('pledge', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function pledge_delete_expectedresult(){
@@ -29,7 +37,7 @@ function pledge_delete_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 4d532c777e1d0bb1f72a1f582e7e5d171bde5a26..c50cb5bba8329730a463426d13652392eb3eee58 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using pledge get API
+ * *
  */
 function pledge_get_example(){
 $params = array(
   'pledge_id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'pledge','get',$params );
+try{
+  $result = civicrm_api3('pledge', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function pledge_get_expectedresult(){
@@ -33,10 +41,10 @@ function pledge_get_expectedresult(){
           'display_name' => 'Mr. Anthony Anderson II',
           'pledge_id' => '1',
           'pledge_amount' => '100.00',
-          'pledge_create_date' => '2013-06-22 00:00:00',
+          'pledge_create_date' => '2013-07-28 00:00:00',
           'pledge_status' => 'Pending',
           'pledge_total_paid' => '',
-          'pledge_next_pay_date' => '2013-06-24 00:00:00',
+          'pledge_next_pay_date' => '2013-07-30 00:00:00',
           'pledge_next_pay_amount' => '20.00',
           'pledge_outstanding_amount' => '',
           'pledge_financial_type' => 'Donation',
@@ -51,7 +59,7 @@ function pledge_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 063c697262e6398051c7a1937beecf7247a97c11..d7b10206c85f44ccdbec0c22b3b55c9ff647fec6 100644 (file)
@@ -1,24 +1,32 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using pledge_payment create API
+ * *
  */
 function pledge_payment_create_example(){
 $params = array(
   'contact_id' => 1,
   'pledge_id' => 1,
   'contribution_id' => 1,
-  'version' => 3,
   'status_id' => 1,
   'actual_amount' => 20,
 );
 
-  $result = civicrm_api( 'pledge_payment','create',$params );
+try{
+  $result = civicrm_api3('pledge_payment', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function pledge_payment_create_expectedresult(){
@@ -44,7 +52,7 @@ function pledge_payment_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 6fef9b82d045a815bb82263ebd5caa6070cb31f5..2ef5a94adb94f0f2d6a59c7540615024fadf6e96 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using pledge_payment delete API
+ * *
  */
 function pledge_payment_delete_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'pledge_payment','delete',$params );
+try{
+  $result = civicrm_api3('pledge_payment', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function pledge_payment_delete_expectedresult(){
@@ -29,7 +37,7 @@ function pledge_payment_delete_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 77ffe9fbbb265c2a271f44edf6cba0519adef131..44d4c0ac62eaca27e942c77a7184ab6813e3501b 100644 (file)
@@ -1,19 +1,26 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using pledge_payment get API
+ * *
  */
 function pledge_payment_get_example(){
-$params = array(
-  'version' => 3,
-);
+$params = array();
 
-  $result = civicrm_api( 'pledge_payment','get',$params );
+try{
+  $result = civicrm_api3('pledge_payment', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function pledge_payment_get_expectedresult(){
@@ -28,7 +35,7 @@ function pledge_payment_get_expectedresult(){
           'pledge_id' => '1',
           'scheduled_amount' => '20.00',
           'currency' => 'USD',
-          'scheduled_date' => '2013-06-22 00:00:00',
+          'scheduled_date' => '2013-07-28 00:00:00',
           'reminder_count' => 0,
           'status_id' => '2',
         ),
@@ -37,7 +44,7 @@ function pledge_payment_get_expectedresult(){
           'pledge_id' => '1',
           'scheduled_amount' => '20.00',
           'currency' => 'USD',
-          'scheduled_date' => '2018-06-22 00:00:00',
+          'scheduled_date' => '2018-07-28 00:00:00',
           'reminder_count' => 0,
           'status_id' => '2',
         ),
@@ -46,7 +53,7 @@ function pledge_payment_get_expectedresult(){
           'pledge_id' => '1',
           'scheduled_amount' => '20.00',
           'currency' => 'USD',
-          'scheduled_date' => '2023-06-22 00:00:00',
+          'scheduled_date' => '2023-07-28 00:00:00',
           'reminder_count' => 0,
           'status_id' => '2',
         ),
@@ -55,7 +62,7 @@ function pledge_payment_get_expectedresult(){
           'pledge_id' => '1',
           'scheduled_amount' => '20.00',
           'currency' => 'USD',
-          'scheduled_date' => '2028-06-22 00:00:00',
+          'scheduled_date' => '2028-07-28 00:00:00',
           'reminder_count' => 0,
           'status_id' => '2',
         ),
@@ -64,14 +71,14 @@ function pledge_payment_get_expectedresult(){
           'pledge_id' => '1',
           'scheduled_amount' => '20.00',
           'currency' => 'USD',
-          'scheduled_date' => '2033-06-22 00:00:00',
+          'scheduled_date' => '2033-07-28 00:00:00',
           'reminder_count' => 0,
           'status_id' => '2',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 8897f4e78da858ac5d963ccd7d76f8c35d3ab2b1..8905465e257f755409bc2fb1e932e2e64f4611ce 100644 (file)
@@ -1,23 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using pledge_payment update API
+ * *
  */
 function pledge_payment_update_example(){
 $params = array(
-  'pledge_id' => 1,
-  'contribution_id' => 1,
-  'version' => 3,
-  'status_id' => 2,
-  'actual_amount' => 20,
+  'id' => 1,
+  'status_id' => 1,
 );
 
-  $result = civicrm_api( 'pledge_payment','update',$params );
+try{
+  $result = civicrm_api3('pledge_payment', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function pledge_payment_update_expectedresult(){
@@ -35,7 +41,7 @@ function pledge_payment_update_expectedresult(){
           'scheduled_amount' => '20.00',
           'actual_amount' => '20.00',
           'currency' => 'USD',
-          'scheduled_date' => '20130622000000',
+          'scheduled_date' => '20130728000000',
           'reminder_date' => '',
           'reminder_count' => 0,
           'status_id' => '1',
@@ -43,7 +49,7 @@ function pledge_payment_update_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 16dac7adcbfe12d550d7fc4108f13f903afdd3d9..1af45a971a783fe3a3b414dd378385a9bac694e5 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using price_field create API
+ * *
  */
 function price_field_create_example(){
 $params = array(
-  'version' => 3,
   'price_set_id' => 3,
   'name' => 'grassvariety',
   'label' => 'Grass Variety',
@@ -14,12 +13,21 @@ $params = array(
   'is_active' => 1,
 );
 
-  $result = civicrm_api( 'price_field','create',$params );
+try{
+  $result = civicrm_api3('price_field', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function price_field_create_expectedresult(){
@@ -52,7 +60,7 @@ function price_field_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 58c1bc24d9fd130dd1485124a9f7add8f7439c9c..bfcdba8ef58f105f338bee2ecb85a5f2684fe8d5 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using price_field delete API
+ * *
  */
 function price_field_delete_example(){
 $params = array(
-  'version' => 3,
   'id' => 4,
 );
 
-  $result = civicrm_api( 'price_field','delete',$params );
+try{
+  $result = civicrm_api3('price_field', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function price_field_delete_expectedresult(){
@@ -26,7 +34,7 @@ function price_field_delete_expectedresult(){
   'values' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 12a97c7eb66f2a1740ec65f221008879376cbf10..88d364e84bad548d8dee93d61fc49578bd11d812 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using price_field get API
+ * *
  */
 function price_field_get_example(){
 $params = array(
-  'version' => 3,
   'name' => 'contribution_amount',
 );
 
-  $result = civicrm_api( 'price_field','get',$params );
+try{
+  $result = civicrm_api3('price_field', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function price_field_get_expectedresult(){
@@ -42,7 +50,7 @@ function price_field_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 21e6cb2821c68d36c3322bedba6efd444b3777a5..ba01b11d00278caaaf9c54afa4a4a5bf8e625505 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using price_field_value create API
+ * *
  */
 function price_field_value_create_example(){
 $params = array(
-  'version' => 3,
   'price_field_id' => 13,
   'membership_type_id' => 5,
   'name' => 'memType1',
@@ -16,12 +15,21 @@ $params = array(
   'financial_type_id' => 2,
 );
 
-  $result = civicrm_api( 'price_field_value','create',$params );
+try{
+  $result = civicrm_api3('price_field_value', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function price_field_value_create_expectedresult(){
@@ -53,7 +61,7 @@ function price_field_value_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 6d0fc244cb02e2c16e409bc0c330ad96a21e40b5..434665edb1ee4c71462cae34182ca7dbb21fd737 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using price_field_value delete API
+ * *
  */
 function price_field_value_delete_example(){
 $params = array(
-  'version' => 3,
   'id' => 7,
 );
 
-  $result = civicrm_api( 'price_field_value','delete',$params );
+try{
+  $result = civicrm_api3('price_field_value', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function price_field_value_delete_expectedresult(){
@@ -26,7 +34,7 @@ function price_field_value_delete_expectedresult(){
   'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 8b21d1526646efb700c8c7b19526402a16df2fd3..c24d21c68155ab5a406d4e555ac2f41517bf1fd2 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using price_field_value get API
+ * *
  */
 function price_field_value_get_example(){
 $params = array(
-  'version' => 3,
   'name' => 'contribution_amount',
 );
 
-  $result = civicrm_api( 'price_field_value','get',$params );
+try{
+  $result = civicrm_api3('price_field_value', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function price_field_value_get_expectedresult(){
@@ -40,7 +48,7 @@ function price_field_value_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index c041e0b8cce59698b0d6c56cae0439b96607ab3f..76fae688e51c229f4f78fb560733b73b2a215adc 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using price_set create API
+ * *
  */
 function price_set_create_example(){
 $params = array(
-  'version' => 3,
   'name' => 'default_goat_priceset',
   'title' => 'Goat accessories',
   'is_active' => 1,
@@ -17,12 +16,21 @@ $params = array(
   'is_reserved' => 1,
 );
 
-  $result = civicrm_api( 'price_set','create',$params );
+try{
+  $result = civicrm_api3('price_set', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function price_set_create_expectedresult(){
@@ -31,10 +39,10 @@ function price_set_create_expectedresult(){
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
-  'id' => 3,
+  'id' => 15,
   'values' => array(
-      '3' => array(
-          'id' => '3',
+      '15' => array(
+          'id' => '15',
           'domain_id' => '',
           'name' => 'default_goat_priceset',
           'title' => 'Goat accessories',
@@ -50,7 +58,7 @@ function price_set_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index aec0a29b07ae652cbf54c1756f6decf8925b7e91..bd84ef81e398067288640c74f0d8bc9886ad1380 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using price_set delete API
+ * *
  */
 function price_set_delete_example(){
 $params = array(
-  'version' => 3,
-  'id' => 5,
+  'id' => 17,
 );
 
-  $result = civicrm_api( 'price_set','delete',$params );
+try{
+  $result = civicrm_api3('price_set', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function price_set_delete_expectedresult(){
@@ -26,7 +34,7 @@ function price_set_delete_expectedresult(){
   'values' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index dcfc7889869fc2056196d5dd0e0c2adff081c6af..8e9f32090fd534bf7d64938d6221763552411123 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using price_set get API
+ * *
  */
 function price_set_get_example(){
 $params = array(
-  'version' => 3,
   'name' => 'default_contribution_amount',
 );
 
-  $result = civicrm_api( 'price_set','get',$params );
+try{
+  $result = civicrm_api3('price_set', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function price_set_get_expectedresult(){
@@ -38,7 +46,7 @@ function price_set_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 694bdb89c936296e8e5b7f856d00968b7450c403..3ee493991aa8ff69932374db68a5d2fc449f4146 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using price_set set API
+ * *
  */
 function price_set_set_example(){
 $params = array(
-  'version' => 3,
   'entity_table' => 'civicrm_event',
   'entity_id' => 1,
   'name' => 'event price',
@@ -13,12 +12,21 @@ $params = array(
   'extends' => 1,
 );
 
-  $result = civicrm_api( 'price_set','set',$params );
+try{
+  $result = civicrm_api3('price_set', 'set', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function price_set_set_expectedresult(){
@@ -27,10 +35,10 @@ function price_set_set_expectedresult(){
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
-  'id' => 4,
+  'id' => 16,
   'values' => array(
-      '4' => array(
-          'id' => '4',
+      '16' => array(
+          'id' => '16',
           'domain_id' => '',
           'name' => 'event price',
           'title' => 'event price',
@@ -46,7 +54,7 @@ function price_set_set_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 0363c2a3ca180e53b925e667091dfd4d5fde9243..768386e948c5e1743d040fe717ec30a9e669819c 100644 (file)
@@ -1,13 +1,12 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using profile apply API
+ * *
  */
 function profile_apply_example(){
 $params = array(
   'profile_id' => 25,
   'contact_id' => 1,
-  'version' => 3,
   'first_name' => 'abc2',
   'last_name' => 'xyz2',
   'email-Primary' => 'abc2.xyz2@gmail.com',
@@ -16,12 +15,21 @@ $params = array(
   'state_province-1' => '1000',
 );
 
-  $result = civicrm_api( 'profile','apply',$params );
+try{
+  $result = civicrm_api3('profile', 'apply', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function profile_apply_expectedresult(){
@@ -64,7 +72,7 @@ function profile_apply_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 6699c3310fb226197655affec9af3d84fcadbe69..c639ae6ea20e020e696f9ba62cca87fb45902f14 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using profile get API
+ * *
  */
 function profile_get_example(){
 $params = array(
   'profile_id' => 25,
   'contact_id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'profile','get',$params );
+try{
+  $result = civicrm_api3('profile', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function profile_get_expectedresult(){
@@ -34,7 +42,7 @@ function profile_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index cb67f4897554ee850c357014f5374d2dfd968ff4..2e4426892a95565865fc11e8c4c140086bef0f32 100644 (file)
@@ -1,13 +1,12 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using profile set API
+ * *
  */
 function profile_set_example(){
 $params = array(
   'profile_id' => 25,
   'contact_id' => 1,
-  'version' => 3,
   'first_name' => 'abc2',
   'last_name' => 'xyz2',
   'email-Primary' => 'abc2.xyz2@gmail.com',
@@ -16,12 +15,21 @@ $params = array(
   'state_province-1' => '1000',
 );
 
-  $result = civicrm_api( 'profile','set',$params );
+try{
+  $result = civicrm_api3('profile', 'set', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function profile_set_expectedresult(){
@@ -57,17 +65,15 @@ function profile_set_expectedresult(){
           'first_name' => 'abc2',
           'middle_name' => '',
           'last_name' => 'xyz2',
-          'prefix_id' => '',
-          'suffix_id' => '',
           'email_greeting_id' => '1',
           'email_greeting_custom' => '',
-          'email_greeting_display' => 'Dear',
+          'email_greeting_display' => 'Dear abc1',
           'postal_greeting_id' => '1',
           'postal_greeting_custom' => '',
-          'postal_greeting_display' => 'Dear',
+          'postal_greeting_display' => 'Dear abc1',
           'addressee_id' => '1',
           'addressee_custom' => '',
-          'addressee_display' => '',
+          'addressee_display' => '{contact.individual_prefix} abc1 {contact.middle_name} xyz1 {contact.individual_suffix}',
           'job_title' => '',
           'gender_id' => '',
           'birth_date' => '',
@@ -78,13 +84,13 @@ function profile_set_expectedresult(){
           'organization_name' => '',
           'sic_code' => '',
           'user_unique_id' => '',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'modified_date' => '2012-11-14 16:02:35',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 5cd8d920c10832d75b53fa4b42781ca08a5135a6..e3191c4aee1e4e057aa3d2277b59fd6e9b603706 100644 (file)
@@ -1,26 +1,33 @@
 <?php
-
-/*
- demonstrates use of BETWEEN filter
+/**
+ * Test Generated example of using relationship get API
+ * demonstrates use of BETWEEN filter *
  */
 function relationship_get_example(){
 $params = array(
   'relationship_type_id' => array(
       'BETWEEN' => array(
-          '0' => 33,
-          '1' => 35,
+          '0' => 32,
+          '1' => 34,
         ),
     ),
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'relationship','get',$params );
+try{
+  $result = civicrm_api3('relationship', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function relationship_get_expectedresult(){
@@ -32,9 +39,9 @@ function relationship_get_expectedresult(){
   'values' => array(
       '2' => array(
           'id' => '2',
-          'contact_id_a' => '66',
-          'contact_id_b' => '67',
-          'relationship_type_id' => '33',
+          'contact_id_a' => '63',
+          'contact_id_b' => '64',
+          'relationship_type_id' => '32',
           'start_date' => '2008-12-20',
           'is_active' => '1',
           'description' => '',
@@ -43,9 +50,9 @@ function relationship_get_expectedresult(){
         ),
       '3' => array(
           'id' => '3',
-          'contact_id_a' => '66',
-          'contact_id_b' => '67',
-          'relationship_type_id' => '34',
+          'contact_id_a' => '63',
+          'contact_id_b' => '64',
+          'relationship_type_id' => '33',
           'start_date' => '2008-12-20',
           'is_active' => '1',
           'description' => '',
@@ -54,9 +61,9 @@ function relationship_get_expectedresult(){
         ),
       '4' => array(
           'id' => '4',
-          'contact_id_a' => '66',
-          'contact_id_b' => '67',
-          'relationship_type_id' => '35',
+          'contact_id_a' => '63',
+          'contact_id_b' => '64',
+          'relationship_type_id' => '34',
           'start_date' => '2008-12-20',
           'is_active' => '1',
           'description' => '',
@@ -66,7 +73,7 @@ function relationship_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 8014f90a1ea6ab4e46174ebfefb1d4c49b0cf605..8d03eb93d50c7492c3aa21bdae7d858112437ef2 100644 (file)
@@ -1,26 +1,33 @@
 <?php
-
-/*
- demonstrates use of IN filter
+/**
+ * Test Generated example of using relationship get API
+ * demonstrates use of IN filter *
  */
 function relationship_get_example(){
 $params = array(
   'relationship_type_id' => array(
       'IN' => array(
-          '0' => 33,
-          '1' => 34,
+          '0' => 32,
+          '1' => 33,
         ),
     ),
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'relationship','get',$params );
+try{
+  $result = civicrm_api3('relationship', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function relationship_get_expectedresult(){
@@ -32,9 +39,9 @@ function relationship_get_expectedresult(){
   'values' => array(
       '2' => array(
           'id' => '2',
-          'contact_id_a' => '66',
-          'contact_id_b' => '67',
-          'relationship_type_id' => '33',
+          'contact_id_a' => '63',
+          'contact_id_b' => '64',
+          'relationship_type_id' => '32',
           'start_date' => '2008-12-20',
           'is_active' => '1',
           'description' => '',
@@ -43,9 +50,9 @@ function relationship_get_expectedresult(){
         ),
       '3' => array(
           'id' => '3',
-          'contact_id_a' => '66',
-          'contact_id_b' => '67',
-          'relationship_type_id' => '34',
+          'contact_id_a' => '63',
+          'contact_id_b' => '64',
+          'relationship_type_id' => '33',
           'start_date' => '2008-12-20',
           'is_active' => '1',
           'description' => '',
@@ -55,7 +62,7 @@ function relationship_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index d81e5120075e314231e49d51f241149cc923f91b..03a843963c452fdd62ba3e75ad086494a675a0f4 100644 (file)
@@ -1,26 +1,33 @@
 <?php
-
-/*
- demonstrates use of Not BETWEEN filter
+/**
+ * Test Generated example of using relationship get API
+ * demonstrates use of Not BETWEEN filter *
  */
 function relationship_get_example(){
 $params = array(
-  'version' => 3,
   'relationship_type_id' => array(
       'NOT BETWEEN' => array(
-          '0' => 33,
-          '1' => 35,
+          '0' => 32,
+          '1' => 34,
         ),
     ),
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'relationship','get',$params );
+try{
+  $result = civicrm_api3('relationship', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function relationship_get_expectedresult(){
@@ -33,9 +40,9 @@ function relationship_get_expectedresult(){
   'values' => array(
       '1' => array(
           'id' => '1',
-          'contact_id_a' => '66',
-          'contact_id_b' => '67',
-          'relationship_type_id' => '32',
+          'contact_id_a' => '63',
+          'contact_id_b' => '64',
+          'relationship_type_id' => '31',
           'start_date' => '2008-12-20',
           'is_active' => '1',
           'description' => '',
@@ -45,7 +52,7 @@ function relationship_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 531f30fa08a90c16a1c0907588bc967bca873b5c..fa3bc4ee0bbfab4065662d3d88d2fdbfdb6ff5a6 100644 (file)
@@ -1,26 +1,33 @@
 <?php
-
-/*
- demonstrates use of NOT IN filter
+/**
+ * Test Generated example of using relationship get API
+ * demonstrates use of NOT IN filter *
  */
 function relationship_get_example(){
 $params = array(
   'relationship_type_id' => array(
       'NOT IN' => array(
-          '0' => 33,
-          '1' => 34,
+          '0' => 32,
+          '1' => 33,
         ),
     ),
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'relationship','get',$params );
+try{
+  $result = civicrm_api3('relationship', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function relationship_get_expectedresult(){
@@ -32,9 +39,9 @@ function relationship_get_expectedresult(){
   'values' => array(
       '1' => array(
           'id' => '1',
-          'contact_id_a' => '66',
-          'contact_id_b' => '67',
-          'relationship_type_id' => '32',
+          'contact_id_a' => '63',
+          'contact_id_b' => '64',
+          'relationship_type_id' => '31',
           'start_date' => '2008-12-20',
           'is_active' => '1',
           'description' => '',
@@ -43,9 +50,9 @@ function relationship_get_expectedresult(){
         ),
       '4' => array(
           'id' => '4',
-          'contact_id_a' => '66',
-          'contact_id_b' => '67',
-          'relationship_type_id' => '35',
+          'contact_id_a' => '63',
+          'contact_id_b' => '64',
+          'relationship_type_id' => '34',
           'start_date' => '2008-12-20',
           'is_active' => '1',
           'description' => '',
@@ -55,7 +62,7 @@ function relationship_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 9e441ac4eb5400fe70f83161a3017886ad295408..14eae6c90bc937a119d5ebad46a3a2b6835d3ca6 100644 (file)
@@ -1,23 +1,30 @@
 <?php
-
-/*
- demonstrates is_current filter
+/**
+ * Test Generated example of using relationship get API
+ * demonstrates is_current filter *
  */
 function relationship_get_example(){
 $params = array(
   'filters' => array(
       'is_current' => 1,
     ),
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'relationship','get',$params );
+try{
+  $result = civicrm_api3('relationship', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function relationship_get_expectedresult(){
@@ -30,9 +37,9 @@ function relationship_get_expectedresult(){
   'values' => array(
       '2' => array(
           'id' => '2',
-          'contact_id_a' => '63',
-          'contact_id_b' => '64',
-          'relationship_type_id' => '31',
+          'contact_id_a' => '60',
+          'contact_id_b' => '61',
+          'relationship_type_id' => '30',
           'start_date' => '2008-12-20',
           'is_active' => '1',
           'description' => '',
@@ -42,7 +49,7 @@ function relationship_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 5181ba72e56ac83afce827e2eef2c69ec46c3292..56ec1672f37ae03dc200c96ae3579ec5a6c00800 100644 (file)
@@ -1,27 +1,34 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using relationship create API
+ * *
  */
 function relationship_create_example(){
 $params = array(
-  'contact_id_a' => 27,
-  'contact_id_b' => 28,
-  'relationship_type_id' => 19,
+  'contact_id_a' => 24,
+  'contact_id_b' => 25,
+  'relationship_type_id' => 18,
   'start_date' => '2010-10-30',
   'end_date' => '2010-12-30',
   'is_active' => 1,
   'note' => 'note',
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'relationship','create',$params );
+try{
+  $result = civicrm_api3('relationship', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function relationship_create_expectedresult(){
@@ -34,9 +41,9 @@ function relationship_create_expectedresult(){
   'values' => array(
       '1' => array(
           'id' => '1',
-          'contact_id_a' => '27',
-          'contact_id_b' => '28',
-          'relationship_type_id' => '19',
+          'contact_id_a' => '24',
+          'contact_id_b' => '25',
+          'relationship_type_id' => '18',
           'start_date' => '20101030000000',
           'end_date' => '20101230000000',
           'is_active' => '1',
@@ -48,7 +55,7 @@ function relationship_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 06187c027b99a27c90f524a09f18d8225714e2ee..daa948f180b4b30ba9510edbe2da7506262b5e87 100644 (file)
@@ -1,21 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using relationship delete API
+ * *
  */
 function relationship_delete_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'relationship','delete',$params );
+try{
+  $result = civicrm_api3('relationship', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function relationship_delete_expectedresult(){
@@ -27,7 +34,7 @@ function relationship_delete_expectedresult(){
   'values' => 'Deleted relationship successfully',
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index b47bd7f5262377dde1fb59ca8d4d5563416b7940..70c830844b8809136fba1915b7c3d464f812bf38 100644 (file)
@@ -1,21 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using relationship get API
+ * *
  */
 function relationship_get_example(){
 $params = array(
-  'version' => 3,
   'id' => 1,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'relationship','get',$params );
+try{
+  $result = civicrm_api3('relationship', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function relationship_get_expectedresult(){
@@ -28,9 +35,9 @@ function relationship_get_expectedresult(){
   'values' => array(
       '1' => array(
           'id' => '1',
-          'contact_id_a' => '36',
-          'contact_id_b' => '37',
-          'relationship_type_id' => '22',
+          'contact_id_a' => '33',
+          'contact_id_b' => '34',
+          'relationship_type_id' => '21',
           'start_date' => '2008-12-20',
           'is_active' => '1',
           'description' => '',
@@ -42,7 +49,7 @@ function relationship_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 4f3135605ccbdce5d6126822cd1d5db5d811f449..46ffddb422d02c97848d025e28b16ac44fa6b72c 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using relationship_type create API
+ * *
  */
 function relationship_type_create_example(){
 $params = array(
@@ -11,16 +11,24 @@ $params = array(
   'contact_type_b' => 'Organization',
   'is_reserved' => 1,
   'is_active' => 1,
-  'version' => 3,
   'sequential' => 1,
 );
 
-  $result = civicrm_api( 'relationship_type','create',$params );
+try{
+  $result = civicrm_api3('relationship_type', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function relationship_type_create_expectedresult(){
@@ -48,7 +56,7 @@ function relationship_type_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 522cff97bebeafe229408228fc709832eaedaf92..0d68292bf8325e4035f251100a75d1828148881b 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using relationship_type delete API
+ * *
  */
 function relationship_type_delete_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'relationship_type','delete',$params );
+try{
+  $result = civicrm_api3('relationship_type', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function relationship_type_delete_expectedresult(){
@@ -23,10 +31,10 @@ function relationship_type_delete_expectedresult(){
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
-  'values' => 1,
+  'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 78351d2ded956f439be38f009f1fa31b4fa8fea3..fb82eb3c7ff5dc58821f6c3be003bb7b93664d60 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
- shows setting a variable for all domains
+/**
+ * Test Generated example of using setting create API
+ * shows setting a variable for all domains *
  */
 function setting_create_example(){
 $params = array(
-  'version' => 3,
   'domain_id' => 'all',
   'uniq_email_per_site' => 1,
 );
 
-  $result = civicrm_api( 'setting','create',$params );
+try{
+  $result = civicrm_api3('setting', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function setting_create_expectedresult(){
@@ -37,7 +45,7 @@ function setting_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index d41cd0383cdb279ccff7698882f94c4edc7eb671..78d29eeb58966b8e8a29b45dba36215d4891b86f 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
- shows setting a variable for a current domain
+/**
+ * Test Generated example of using setting create API
+ * shows setting a variable for a current domain *
  */
 function setting_create_example(){
 $params = array(
-  'version' => 3,
   'uniq_email_per_site' => 1,
 );
 
-  $result = civicrm_api( 'setting','create',$params );
+try{
+  $result = civicrm_api3('setting', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function setting_create_expectedresult(){
@@ -31,7 +39,7 @@ function setting_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index df11acabfb6e4d3c6062ffccd6b3cd4b9e59f7b0..4cc871247012fd75aa87fb586502928fbd3bef79 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
- shows setting a variable for specified domains
+/**
+ * Test Generated example of using setting create API
+ * shows setting a variable for specified domains *
  */
 function setting_create_example(){
 $params = array(
-  'version' => 3,
   'domain_id' => array(
       '0' => 1,
       '1' => 3,
@@ -13,12 +12,21 @@ $params = array(
   'uniq_email_per_site' => 0,
 );
 
-  $result = civicrm_api( 'setting','create',$params );
+try{
+  $result = civicrm_api3('setting', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function setting_create_expectedresult(){
@@ -37,7 +45,7 @@ function setting_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index bf363cc43c947400eff7ee58cdfa5ce7fd186471..32af9a1a66cb80301261f4d8f6e97a1ebfed29a9 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
- shows getting a variable for all domains
+/**
+ * Test Generated example of using setting Get API
+ * shows getting a variable for all domains *
  */
 function setting_get_example(){
 $params = array(
-  'version' => 3,
   'domain_id' => 'all',
   'return' => 'uniq_email_per_site',
 );
 
-  $result = civicrm_api( 'setting','Get',$params );
+try{
+  $result = civicrm_api3('setting', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function setting_get_expectedresult(){
@@ -37,7 +45,7 @@ function setting_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 4b5efa7526f105c08e6676e5d0f15c48638b85bf..5084c159cee6aacd1edf3a98d75819fdc3ffa40a 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
- gets defaults setting a variable for a given domain - if no domain is set current is assumed
+/**
+ * Test Generated example of using setting getdefaults API
+ * gets defaults setting a variable for a given domain - if no domain is set current is assumed *
  */
 function setting_getdefaults_example(){
 $params = array(
-  'version' => 3,
   'name' => 'address_format',
 );
 
-  $result = civicrm_api( 'setting','getdefaults',$params );
+try{
+  $result = civicrm_api3('setting', 'getdefaults', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function setting_getdefaults_expectedresult(){
@@ -36,7 +44,7 @@ function setting_getdefaults_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index d619b4ad02403872a4b3ab9e27552a75cba31fc0..b5b43f9741dc054beea8e7cc13f8f71da0d15f2a 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
- shows getting a variable for a current domain
+/**
+ * Test Generated example of using setting get API
+ * shows getting a variable for a current domain *
  */
 function setting_get_example(){
 $params = array(
-  'version' => 3,
   'return' => 'uniq_email_per_site',
 );
 
-  $result = civicrm_api( 'setting','get',$params );
+try{
+  $result = civicrm_api3('setting', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function setting_get_expectedresult(){
@@ -31,7 +39,7 @@ function setting_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 9389205ee04cc38bd59f255a04e4af33151bbc42..f839e0934cddb963dcefa254dbda829c802b0145 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
- shows getting a variable for specified domains
+/**
+ * Test Generated example of using setting Get API
+ * shows getting a variable for specified domains *
  */
 function setting_get_example(){
 $params = array(
-  'version' => 3,
   'domain_id' => array(
       '0' => 1,
       '1' => 2,
@@ -15,12 +14,21 @@ $params = array(
     ),
 );
 
-  $result = civicrm_api( 'setting','Get',$params );
+try{
+  $result = civicrm_api3('setting', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function setting_get_expectedresult(){
@@ -39,7 +47,7 @@ function setting_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 1aa00f62c5b1a323dc725749371790b06c07847a..146335553228b993943126892670eaa62c2c7f13 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using setting create API
+ * *
  */
 function setting_create_example(){
 $params = array(
-  'version' => 3,
   'domain_id' => 2,
   'uniq_email_per_site' => 1,
 );
 
-  $result = civicrm_api( 'setting','create',$params );
+try{
+  $result = civicrm_api3('setting', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function setting_create_expectedresult(){
@@ -32,7 +40,7 @@ function setting_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index ec76f9a9a72f2ffb5ca73d433f35cae9b435465b..714ae6d338ef6c8258e9863136a78cd30d0694e3 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using setting get API
+ * *
  */
 function setting_get_example(){
 $params = array(
-  'version' => 3,
   'domain_id' => 2,
   'return' => 'uniq_email_per_site',
 );
 
-  $result = civicrm_api( 'setting','get',$params );
+try{
+  $result = civicrm_api3('setting', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function setting_get_expectedresult(){
@@ -32,7 +40,7 @@ function setting_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 8afd44908d74d98f699c2f174212f0ed64dcf25c..c48517dd99822070ac3c2087fdf89842ebc5412f 100644 (file)
@@ -1,28 +1,36 @@
 <?php
-
-/*
- Demonstrates getvalue action - intended for runtime use as better caching than get
+/**
+ * Test Generated example of using setting getvalue API
+ * Demonstrates getvalue action - intended for runtime use as better caching than get *
  */
 function setting_getvalue_example(){
 $params = array(
-  'version' => 3,
   'name' => 'petition_contacts',
   'group' => 'Campaign Preferences',
 );
 
-  $result = civicrm_api( 'setting','getvalue',$params );
+try{
+  $result = civicrm_api3('setting', 'getvalue', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function setting_getvalue_expectedresult(){
 
   $expectedResult = 'Petition Contacts';
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 147b2e546ee1ef9ca0ea24ababfbd22b21a679a9..0fc2752ad6fc9f32da47bec2fe6b6db57c87bda6 100644 (file)
@@ -1,19 +1,26 @@
 <?php
-
-/*
- Demonstrate return from getfields - see subfolder for variants
+/**
+ * Test Generated example of using setting getfields API
+ * Demonstrate return from getfields - see subfolder for variants *
  */
 function setting_getfields_example(){
-$params = array(
-  'version' => 3,
-);
+$params = array();
 
-  $result = civicrm_api( 'setting','getfields',$params );
+try{
+  $result = civicrm_api3('setting', 'getfields', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function setting_getfields_expectedresult(){
@@ -21,7 +28,7 @@ function setting_getfields_expectedresult(){
   $expectedResult = array(
   'is_error' => 0,
   'version' => 3,
-  'count' => 75,
+  'count' => 78,
   'values' => array(
       'address_standardization_provider' => array(
           'group_name' => 'Address Preferences',
@@ -481,6 +488,20 @@ function setting_getfields_expectedresult(){
           'description' => 'If enabled, deleted contacts will be moved to trash (instead of being destroyed). Users with the proper permission are able to search for the deleted contacts and restore them (or delete permanently).',
           'help_text' => '',
         ),
+      'allowPermDeleteFinancial' => array(
+          'group_name' => 'CiviCRM Preferences',
+          'group' => 'core',
+          'name' => 'allowPermDeleteFinancial',
+          'type' => 'Boolean',
+          'quick_form_type' => 'YesNo',
+          'default' => '',
+          'add' => '4.3',
+          'title' => 'Contact Permanent Delete',
+          'is_domain' => 1,
+          'is_contact' => 0,
+          'description' => 'Allow Permanent Delete for contacts who are linked to live financial transactions',
+          'help_text' => '',
+        ),
       'versionAlert' => array(
           'group_name' => 'CiviCRM Preferences',
           'group' => 'core',
@@ -627,7 +648,7 @@ When enabled, statistics about your CiviCRM installation are reported anonymousl
             ),
           'default' => 7,
           'add' => '4.3',
-          'title' => 'Dashboard cache timeout',
+          'title' => 'Checksum Lifespan',
           'is_domain' => 1,
           'is_contact' => 0,
           'description' => '',
@@ -706,21 +727,48 @@ When enabled, statistics about your CiviCRM installation are reported anonymousl
           'help_text' => 'By default, CiviCRM will generate front-facing pages using the home page at http://wp/ as its base. If you want to use a different template for CiviCRM pages, set the path here.',
         ),
       'secondDegRelPermissions' => array(
-        'group_name' => 'CiviCRM Preferences',
-        'group' => 'core',
-        'name' => 'secondDegRelPermissions',
-        'prefetch' => 1,
-        'config_only'=> 1,
-        'type' => 'Boolean',
-        'quick_form_type' => 'YesNo',
-        'default' => 0,
-        'add' => '4.3',
-        'title' => 'Allow second-degree relationship permissions',
-        'is_domain' => 1,
-        'is_contact' => 0,
-        'description' => "If enabled, contacts with the permission to edit a related contact will inherit that contact's permission to edit other related contacts",
-        'help_text' => null,
-      ),
+          'group_name' => 'CiviCRM Preferences',
+          'group' => 'core',
+          'name' => 'secondDegRelPermissions',
+          'prefetch' => 1,
+          'config_only' => 1,
+          'type' => 'Boolean',
+          'quick_form_type' => 'YesNo',
+          'default' => 0,
+          'add' => '4.3',
+          'title' => 'Allow second-degree relationship permissions',
+          'is_domain' => 1,
+          'is_contact' => 0,
+          'description' => 'If enabled, contacts with the permission to edit a related contact will inherit that contact's permission to edit other related contacts',
+          'help_text' => '',
+        ),
+      'enable_components' => array(
+          'group_name' => 'CiviCRM Preferences',
+          'group' => 'core',
+          'name' => 'enable_components',
+          'type' => 'Array',
+          'quick_form_type' => 'Element',
+          'html_type' => 'advmultiselect',
+          'html_attributes' => array(
+              'size' => 5,
+              'style' => 'width:150px',
+              'class' => 'advmultiselect',
+            ),
+          'default' => array(
+              '0' => 'CiviEvent',
+              '1' => 'CiviContribute',
+              '2' => 'CiviMember',
+              '3' => 'CiviMail',
+              '4' => 'CiviReport',
+              '5' => 'CiviPledge',
+            ),
+          'add' => '4.4',
+          'title' => 'Enable Components',
+          'is_domain' => '1',
+          'is_contact' => 0,
+          'description' => '',
+          'help_text' => '',
+        ),
       'debug_enabled' => array(
           'group_name' => 'Developer Preferences',
           'group' => 'developer',
@@ -734,7 +782,7 @@ When enabled, statistics about your CiviCRM installation are reported anonymousl
           'title' => 'Enable Debugging',
           'is_domain' => 1,
           'is_contact' => 0,
-          'description' => 'Set this value to Yes if you want to use one of CiviCRM\'s debugging tools. This feature should NOT be enabled for production sites',
+          'description' => 'Set this value to Yes if you want to use one of CiviCRM's debugging tools. This feature should NOT be enabled for production sites',
           'prefetch' => 1,
           'help_text' => 'Do not turn this on on production sites',
         ),
@@ -752,8 +800,8 @@ When enabled, statistics about your CiviCRM installation are reported anonymousl
           'is_contact' => 0,
           'description' => 'Set this value to Yes if you want CiviCRM error/debugging messages to also appear in Drupal error logs',
           'prefetch' => 1,
-          'help_text' => 'Set this value to Yes if you want CiviCRM error/debugging messages the appear in your CMS\' error log.
-In the case of Drupal, this will cause all CiviCRM error messages to appear in the watchdog (assuming you have Drupal\'s watchdog enabled)',
+          'help_text' => 'Set this value to Yes if you want CiviCRM error/debugging messages the appear in your CMS' error log.
+In the case of Drupal, this will cause all CiviCRM error messages to appear in the watchdog (assuming you have Drupal's watchdog enabled)',
         ),
       'backtrace' => array(
           'group_name' => 'Developer Preferences',
@@ -1333,7 +1381,7 @@ In the case of Drupal, this will cause all CiviCRM error messages to appear in t
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 509c0ca111092596019a8e1f748c3976caba924d..ffacc49fd4145844e53e54defcb7d646a51f0dec 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
- Demonstrates reverting a parameter to default value
+/**
+ * Test Generated example of using setting revert API
+ * Demonstrates reverting a parameter to default value *
  */
 function setting_revert_example(){
 $params = array(
-  'version' => 3,
   'name' => 'address_format',
 );
 
-  $result = civicrm_api( 'setting','revert',$params );
+try{
+  $result = civicrm_api3('setting', 'revert', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function setting_revert_expectedresult(){
@@ -42,7 +50,7 @@ function setting_revert_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 28e453667fd5924d28c4bec7fae1da7782a8fefd..d2db10179a306a3ff0a77596ae8072f8b4d2f46c 100644 (file)
@@ -1,22 +1,29 @@
 <?php
-
-/*
- demonstrates get + delete in the same call
+/**
+ * Test Generated example of using survey get API
+ * demonstrates get + delete in the same call *
  */
 function survey_get_example(){
 $params = array(
   'title' => 'survey title',
   'api.survey.delete' => 1,
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'survey','get',$params );
+try{
+  $result = civicrm_api3('survey', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function survey_get_expectedresult(){
@@ -35,7 +42,7 @@ function survey_get_expectedresult(){
           'max_number_of_contacts' => '12',
           'is_active' => '1',
           'is_default' => 0,
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'bypass_confirm' => 0,
           'api.survey.delete' => array(
               'is_error' => 0,
@@ -47,7 +54,7 @@ function survey_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 39f6d61138380a6b49de6ffb038fd30356b764a2..763f3771160e338833204ebc24891065e26f51a0 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using survey create API
+ * *
  */
 function survey_create_example(){
 $params = array(
@@ -9,16 +9,23 @@ $params = array(
   'activity_type_id' => '35',
   'max_number_of_contacts' => 12,
   'instructions' => 'Call people, ask for money',
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'survey','create',$params );
+try{
+  $result = civicrm_api3('survey', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function survey_create_expectedresult(){
@@ -42,7 +49,7 @@ function survey_create_expectedresult(){
           'is_active' => '',
           'is_default' => '',
           'created_id' => '',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'last_modified_id' => '',
           'last_modified_date' => '',
           'result_id' => '',
@@ -53,7 +60,7 @@ function survey_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 04ace825884b09d0e99b8431f5564815f092efca..74a36e48935b4a86f627016f50413f532060c1a4 100644 (file)
@@ -1,21 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using survey delete API
+ * *
  */
 function survey_delete_example(){
 $params = array(
   'id' => 1,
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'survey','delete',$params );
+try{
+  $result = civicrm_api3('survey', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function survey_delete_expectedresult(){
@@ -27,7 +34,7 @@ function survey_delete_expectedresult(){
   'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index af565277af074ac71fe75b746db84f404939a0a1..322815ef92242c5b49da6995d19d8efca8032aa3 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using survey get API
+ * *
  */
 function survey_get_example(){
 $params = array(
@@ -9,16 +9,23 @@ $params = array(
   'activity_type_id' => '35',
   'max_number_of_contacts' => 12,
   'instructions' => 'Call people, ask for money',
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'survey','get',$params );
+try{
+  $result = civicrm_api3('survey', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function survey_get_expectedresult(){
@@ -37,13 +44,13 @@ function survey_get_expectedresult(){
           'max_number_of_contacts' => '12',
           'is_active' => '1',
           'is_default' => 0,
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'bypass_confirm' => 0,
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index c77a5509993acea0cdfc4e474a0204f4a66c3606..202ada504c210c8ee89cbdd254db715b0b31ee45 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using survey_respondant get API
+ * *
  */
 function survey_respondant_get_example(){
 $params = array(
-  'version' => 3,
   'sequential' => '1',
   'survey_id' => 1,
 );
 
-  $result = civicrm_api( 'survey_respondant','get',$params );
+try{
+  $result = civicrm_api3('survey_respondant', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function survey_respondant_get_expectedresult(){
@@ -27,7 +35,7 @@ function survey_respondant_get_expectedresult(){
   'values' => array(),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index e57a8e0c3f2df031e7ed240fbc95cf416d1d7b40..497e84c14ca259c325774cf35a87424958aae39a 100644 (file)
@@ -1,19 +1,26 @@
 <?php
-
-/*
- Flush all system caches
+/**
+ * Test Generated example of using system flush API
+ * Flush all system caches *
  */
 function system_flush_example(){
-$params = array(
-  'version' => 3,
-);
+$params = array();
 
-  $result = civicrm_api( 'system','flush',$params );
+try{
+  $result = civicrm_api3('system', 'flush', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function system_flush_expectedresult(){
@@ -25,7 +32,7 @@ function system_flush_expectedresult(){
   'values' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 20632a78761a33dc1579f7756775a1d5b93de58f..7d115c00dfe97faa4bf663c5e8cb8b20b24c8007 100644 (file)
@@ -1,24 +1,32 @@
 <?php
-
-/*
- demonstrates use of Return as an array
+/**
+ * Test Generated example of using tag get API
+ * demonstrates use of Return as an array *
  */
 function tag_get_example(){
 $params = array(
-  'id' => 7,
-  'name' => 'New Tag325818',
-  'version' => 3,
+  'id' => '8',
+  'name' => 'New Tag3',
   'return' => array(
       '0' => 'name',
     ),
 );
 
-  $result = civicrm_api( 'tag','get',$params );
+try{
+  $result = civicrm_api3('tag', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function tag_get_expectedresult(){
@@ -27,16 +35,16 @@ function tag_get_expectedresult(){
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
-  'id' => 7,
+  'id' => 8,
   'values' => array(
-      '7' => array(
-          'id' => '7',
-          'name' => 'New Tag325818',
+      '8' => array(
+          'id' => '8',
+          'name' => 'New Tag3',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 682b6aecb338af584dcd290c2b477c4aa7904d43..be58d0e7a2c071b3c72912a4475eb6ce4313b65a 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using tag create API
+ * *
  */
 function tag_create_example(){
 $params = array(
-  'name' => 'New Tag3',
-  'description' => 'This is description for New Tag 02',
-  'version' => 3,
+  'name' => 'Super Heros',
+  'description' => 'Outside undie-wearers',
 );
 
-  $result = civicrm_api( 'tag','create',$params );
+try{
+  $result = civicrm_api3('tag', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function tag_create_expectedresult(){
@@ -24,24 +32,24 @@ function tag_create_expectedresult(){
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
-  'id' => 8,
+  'id' => 12,
   'values' => array(
-      '8' => array(
-          'id' => '8',
-          'name' => 'New Tag3',
-          'description' => 'This is description for New Tag 02',
+      '12' => array(
+          'id' => '12',
+          'name' => 'Super Heros',
+          'description' => 'Outside undie-wearers',
           'parent_id' => '',
           'is_selectable' => '',
           'is_reserved' => '',
           'is_tagset' => '',
           'used_for' => 'civicrm_contact',
           'created_id' => '',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 428a72757c53f4d51c9e349521343214066b73c2..5bc3483337d1b80aeb7cd1034930c6e589259aec 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using tag delete API
+ * *
  */
 function tag_delete_example(){
 $params = array(
-  'id' => 11,
-  'version' => 3,
+  'id' => '17',
 );
 
-  $result = civicrm_api( 'tag','delete',$params );
+try{
+  $result = civicrm_api3('tag', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function tag_delete_expectedresult(){
@@ -26,7 +34,7 @@ function tag_delete_expectedresult(){
   'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 2b9bcd4db6be1e3032360549058d3cfe41401eff..76d9f9167b8f89228f5af6b14ee812faff040117 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using tag get API
+ * *
  */
 function tag_get_example(){
 $params = array(
-  'id' => 6,
-  'name' => 'New Tag320719',
-  'version' => 3,
+  'id' => '7',
+  'name' => 'New Tag3',
 );
 
-  $result = civicrm_api( 'tag','get',$params );
+try{
+  $result = civicrm_api3('tag', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function tag_get_expectedresult(){
@@ -24,22 +32,22 @@ function tag_get_expectedresult(){
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
-  'id' => 6,
+  'id' => 7,
   'values' => array(
-      '6' => array(
-          'id' => '6',
-          'name' => 'New Tag320719',
-          'description' => 'This is description for New Tag 30716',
+      '7' => array(
+          'id' => '7',
+          'name' => 'New Tag3',
+          'description' => 'This is description for Our New Tag ',
           'is_selectable' => '1',
           'is_reserved' => 0,
           'is_tagset' => 0,
           'used_for' => 'civicrm_contact',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
diff --git a/api/v3/examples/TagGetfields.php b/api/v3/examples/TagGetfields.php
new file mode 100644 (file)
index 0000000..a1bb2ba
--- /dev/null
@@ -0,0 +1,123 @@
+<?php
+/**
+ * Test Generated example of using tag getfields API
+ * demonstrate use of getfields to interogate api *
+ */
+function tag_getfields_example(){
+$params = array(
+  'action' => 'create',
+);
+
+try{
+  $result = civicrm_api3('tag', 'getfields', $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
+ */
+function tag_getfields_expectedresult(){
+
+  $expectedResult = array(
+  'is_error' => 0,
+  'version' => 3,
+  'count' => 10,
+  'values' => array(
+      'id' => array(
+          'name' => 'id',
+          'type' => 1,
+          'required' => true,
+          'api.aliases' => array(
+              '0' => 'tag',
+            ),
+        ),
+      'name' => array(
+          'name' => 'name',
+          'type' => 2,
+          'title' => 'Name',
+          'required' => true,
+          'maxlength' => 64,
+          'size' => 30,
+          'api.required' => 1,
+        ),
+      'description' => array(
+          'name' => 'description',
+          'type' => 2,
+          'title' => 'Description',
+          'maxlength' => 255,
+          'size' => 45,
+        ),
+      'parent_id' => array(
+          'name' => 'parent_id',
+          'type' => 1,
+          'default' => 'UL',
+          'FKClassName' => 'CRM_Core_DAO_Tag',
+        ),
+      'is_selectable' => array(
+          'name' => 'is_selectable',
+          'type' => 16,
+        ),
+      'is_reserved' => array(
+          'name' => 'is_reserved',
+          'type' => 16,
+        ),
+      'is_tagset' => array(
+          'name' => 'is_tagset',
+          'type' => 16,
+        ),
+      'used_for' => array(
+          'name' => 'used_for',
+          'type' => 2,
+          'title' => 'Used For',
+          'maxlength' => 64,
+          'size' => 30,
+          'default' => 'UL',
+          'api.default' => 'civicrm_contact',
+        ),
+      'created_id' => array(
+          'name' => 'created_id',
+          'type' => 1,
+          'FKClassName' => 'CRM_Contact_DAO_Contact',
+        ),
+      'created_date' => array(
+          'name' => 'created_date',
+          'type' => 12,
+          'title' => 'Tag Created Date',
+        ),
+    ),
+);
+
+  return $expectedResult;
+}
+
+
+/*
+* This example has been generated from the API test suite. The test that created it is called
+*
+* testTagGetfields and can be found in
+* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/TagTest.php
+*
+* You can see the outcome of the API tests at
+* http://tests.dev.civicrm.org/trunk/results-api_v3
+*
+* To Learn about the API read
+* http://book.civicrm.org/developer/current/techniques/api/
+*
+* and review the wiki at
+* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
+*
+* 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
+*/
\ No newline at end of file
index 1b374826d10952bf0b1d60ba167b48fb84722b78..1c7350982dca11acf53c0c5e905b2dba7222b2fd 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using uf_field create API
+ * *
  */
 function uf_field_create_example(){
 $params = array(
@@ -14,16 +14,24 @@ $params = array(
   'is_active' => 1,
   'location_type_id' => 1,
   'phone_type_id' => 1,
-  'version' => 3,
   'uf_group_id' => 11,
 );
 
-  $result = civicrm_api( 'uf_field','create',$params );
+try{
+  $result = civicrm_api3('uf_field', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function uf_field_create_expectedresult(){
@@ -57,7 +65,7 @@ function uf_field_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 134cdf34a9e5b21c24f235b830eae29c9c6395f0..0c639a7bc8f87298c3f343c1d2ee3a5931af0993 100644 (file)
@@ -1,21 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using uf_field delete API
+ * *
  */
 function uf_field_delete_example(){
 $params = array(
   'field_id' => 1,
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'uf_field','delete',$params );
+try{
+  $result = civicrm_api3('uf_field', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function uf_field_delete_expectedresult(){
@@ -27,7 +34,7 @@ function uf_field_delete_expectedresult(){
   'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 87704345ebc8bea96e0aa239858cf6835bbab5d1..1d9382cdd408b86d9f24d53a6b12cf1e2fc3bc45 100644 (file)
@@ -1,20 +1,26 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using uf_field get API
+ * *
  */
 function uf_field_get_example(){
-$params = array(
-  'version' => 3,
-  'debug' => 0,
-);
+$params = array();
 
-  $result = civicrm_api( 'uf_field','get',$params );
+try{
+  $result = civicrm_api3('uf_field', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function uf_field_get_expectedresult(){
@@ -45,7 +51,7 @@ function uf_field_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index f71855a22c8408c134053e131872365a74fc05f6..4c31a0e387b067c25b53a6e8d3ee4d91f3d3319d 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using uf_field replace API
+ * *
  */
 function uf_field_replace_example(){
 $params = array(
-  'version' => 3,
   'uf_group_id' => 11,
   'option.autoweight' => '',
   'values' => array(
@@ -42,12 +41,21 @@ $params = array(
     ),
 );
 
-  $result = civicrm_api( 'uf_field','replace',$params );
+try{
+  $result = civicrm_api3('uf_field', 'replace', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function uf_field_replace_expectedresult(){
@@ -120,7 +128,7 @@ function uf_field_replace_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 9f075c7eebfe52ec0d24c5954662bbe22b310952..866e7be4694773913c15882ab037a6535b73ab4c 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using uf_group create API
+ * *
  */
 function uf_group_create_example(){
 $params = array(
@@ -25,15 +25,23 @@ $params = array(
   'notify' => 'admin@example.org',
   'post_URL' => 'http://example.org/post',
   'title' => 'Test Group',
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'uf_group','create',$params );
+try{
+  $result = civicrm_api3('uf_group', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function uf_group_create_expectedresult(){
@@ -65,13 +73,13 @@ function uf_group_create_expectedresult(){
           'is_reserved' => '1',
           'name' => 'Test_Group_12',
           'created_id' => '69',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'is_proximity_search' => '',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index aeeeb6d3161f4ceddac478ea7f6b02bb4ec15fa1..4b190d4faf8b2bd727e2010fd6a6185e29f89c20 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using uf_group delete API
+ * *
  */
 function uf_group_delete_example(){
 $params = array(
@@ -25,15 +25,23 @@ $params = array(
   'notify' => 'admin@example.org',
   'post_URL' => 'http://example.org/post',
   'title' => 'Test Group',
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'uf_group','delete',$params );
+try{
+  $result = civicrm_api3('uf_group', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function uf_group_delete_expectedresult(){
@@ -45,7 +53,7 @@ function uf_group_delete_expectedresult(){
   'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 39a3586ab74ac74f35f3b9dcd5e61c92e8f44d2e..64c5ac1ab69399675e75d7186e21005315dd0965 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using uf_group get API
+ * *
  */
 function uf_group_get_example(){
 $params = array(
@@ -25,15 +25,23 @@ $params = array(
   'notify' => 'admin@example.org',
   'post_URL' => 'http://example.org/post',
   'title' => 'Test Group',
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'uf_group','get',$params );
+try{
+  $result = civicrm_api3('uf_group', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function uf_group_get_expectedresult(){
@@ -65,13 +73,13 @@ function uf_group_get_expectedresult(){
           'is_reserved' => '1',
           'name' => 'Test_Group_12',
           'created_id' => '69',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'is_proximity_search' => 0,
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index a22f0b1249d23a0328b009cb0e3b7a7a5b2c506b..6ac8c89213b7352715e61418da1f1d10a966c1d6 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using uf_join create API
+ * *
  */
 function uf_join_create_example(){
 $params = array(
@@ -11,16 +11,24 @@ $params = array(
   'weight' => 1,
   'uf_group_id' => 11,
   'is_active' => 1,
-  'version' => 3,
   'sequential' => 1,
 );
 
-  $result = civicrm_api( 'uf_join','create',$params );
+try{
+  $result = civicrm_api3('uf_join', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function uf_join_create_expectedresult(){
@@ -43,7 +51,7 @@ function uf_join_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index b3427fa54ea2451b97ca130efad41a8b727a6047..e8e735159531ce5461f5d1250a03ebf7c15ea69d 100644 (file)
@@ -1,22 +1,30 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using uf_join get API
+ * *
  */
 function uf_join_get_example(){
 $params = array(
   'entity_table' => 'civicrm_contribution_page',
   'entity_id' => 1,
-  'version' => 3,
   'sequential' => 1,
 );
 
-  $result = civicrm_api( 'uf_join','get',$params );
+try{
+  $result = civicrm_api3('uf_join', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function uf_join_get_expectedresult(){
@@ -39,7 +47,7 @@ function uf_join_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 852b15c6c71ac43ac45342dc703f0ee6c80d6ac1..2e664f4be6b3d93da15a7fd27420d547ff6b1962 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using uf_match get API
+ * *
  */
 function uf_match_get_example(){
 $params = array(
   'contact_id' => 69,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'uf_match','get',$params );
+try{
+  $result = civicrm_api3('uf_match', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function uf_match_get_expectedresult(){
@@ -34,7 +42,7 @@ function uf_match_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 8468367a0b55207517e73a354883ed69fb4a8524..06aa440fc7476e5bb8e25ae3d5abbcb6c7e6fa64 100644 (file)
@@ -1,22 +1,30 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using website create API
+ * *
  */
 function website_create_example(){
 $params = array(
-  'version' => 3,
   'contact_id' => 3,
   'url' => 'website.com',
   'website_type_id' => 1,
 );
 
-  $result = civicrm_api( 'website','create',$params );
+try{
+  $result = civicrm_api3('website', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function website_create_expectedresult(){
@@ -36,7 +44,7 @@ function website_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index e7ace8c42c89635b75cff466045bfafe9ec55579..254b6a233d50ffd1349b907e057594270bb63c8e 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using website delete API
+ * *
  */
 function website_delete_example(){
 $params = array(
-  'version' => 3,
   'id' => 1,
 );
 
-  $result = civicrm_api( 'website','delete',$params );
+try{
+  $result = civicrm_api3('website', 'delete', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function website_delete_expectedresult(){
@@ -26,7 +34,7 @@ function website_delete_expectedresult(){
   'values' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index 47c81b08ae867ef61ed422c66815337c36efb287..914c0c67a19f752bceb43048a5e950d5f78091c4 100644 (file)
@@ -1,22 +1,30 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using website get API
+ * *
  */
 function website_get_example(){
 $params = array(
-  'version' => 3,
   'contact_id' => 1,
   'url' => 'website.com',
   'website_type_id' => 1,
 );
 
-  $result = civicrm_api( 'website','get',$params );
+try{
+  $result = civicrm_api3('website', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function website_get_expectedresult(){
@@ -36,7 +44,7 @@ function website_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
index d25d43750af3828dacebf2c6d6257a8c3359e031..a9f0762464574c4725bc39a2ed55b0e7378a0e49 100644 (file)
@@ -1024,7 +1024,7 @@ function _civicrm_api3_basic_delete($bao_name, &$params) {
     if ($bao !== FALSE) {
       return civicrm_api3_create_success(TRUE);
     }
-    return civicrm_api3_create_error('Could not delete entity id ' . $params['id']);
+    throw new API_Exception('Could not delete entity id ' . $params['id']);
   }
   elseif (method_exists($bao_name, 'delete')) {
     $dao = new $bao_name();
@@ -1036,11 +1036,11 @@ function _civicrm_api3_basic_delete($bao_name, &$params) {
       }
     }
     else {
-      return civicrm_api3_create_error('Could not delete entity id ' . $params['id']);
+      throw new API_Exception('Could not delete entity id ' . $params['id']);
     }
   }
 
-  return civicrm_api3_create_error('no delete method found');
+  throw new API_Exception('no delete method found');
 }
 
 /**
index e37c76dc215c17c866188cbbbdea6219d4b13347..e3ecb795f97ff34cd6653a27faf89ed4669c257b 100644 (file)
@@ -623,7 +623,6 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
     if(!empty($apiResult['trace'])){
       $errorMessage .= "\n" . print_r($apiResult['trace'], TRUE);
     }
-
     $this->assertEquals(0, $apiResult['is_error'], $prefix . $errorMessage);
   }
 
@@ -1147,19 +1146,17 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
   /**
    * Function to create Tag
    *
-   * @return int tag_id of created tag
+   * @return array result of created tag
    */
-  function tagCreate($params = NULL) {
-    if ($params === NULL) {
-      $params = array(
-        'name' => 'New Tag3' . rand(),
-        'description' => 'This is description for New Tag ' . rand(),
-        'domain_id' => '1',
-      );
-    }
-
-    $result = $this->callAPISuccess('Tag', 'create', $params);
-    return $result;
+  function tagCreate($params = array()) {
+    $defaults = array(
+      'name' => 'New Tag3',
+      'description' => 'This is description for Our New Tag ',
+      'domain_id' => '1',
+    );
+    $params = array_merge($defaults, $params);
+    $result =  $this->callAPISuccess('Tag', 'create', $params);
+    return $result['values'][$result['id']];
   }
 
   /**
@@ -1879,6 +1876,9 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
     }
 
     $this->tidyExampleResult($result);
+    if(isset($params['version'])) {
+      unset($params['version']);
+    }
     // a cleverer person than me would do it in a single regex
     if (strstr($entity, 'UF')) {
       $fnPrefix = strtolower(preg_replace('/(?<! )(?<!^)(?<=UF)[A-Z]/', '_$0', $entity));
@@ -1929,11 +1929,11 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
     $fieldsToChange = array(
       'hash' => '67eac7789eaee00',
       'modified_date' => '2012-11-14 16:02:35',
-      'created_date' => '20120130621222105',
+      'created_date' => '2013-07-28 05:52:14',
       'create_date' => '20120130621222105',
     );
 
-    $keysToUnset = array('xdebug', 'undefined_fields');
+    $keysToUnset = array('xdebug', 'undefined_fields',);
     foreach ($keysToUnset as $unwantedKey) {
       if(isset($result[$unwantedKey])) {
         unset($result[$unwantedKey]);
@@ -2251,6 +2251,17 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
       $financialAccount->delete();
     }
   }
+
+  /**
+   * Use $ids as an instruction to do test cleanup
+   */
+  function deleteFromIDSArray() {
+    foreach ($this->ids as $entity => $ids) {
+      foreach ($ids as $id) {
+        $this->callAPISuccess($entity, 'delete', array('id' => $id));
+      }
+    }
+  }
 }
 
 function CiviUnitTestCase_fatalErrorHandler($message) {
index 37779fba56beb75d0afdb91d66056a3fac2dfe64..7559e76f85786d79af7b0e5b3cfc13ee2a1e74e0 100644 (file)
@@ -321,7 +321,7 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     $params['custom_' . $ids['custom_field_id']] = "custom string";
     $description = "/*this demonstrates setting a custom field through the API ";
     $subfile = "CustomFieldCreate";
-    $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, $subfile);
+    $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description);
 
     $check = $this->callAPISuccess($this->_entity, 'get', array('return.custom_' . $ids['custom_field_id'] => 1, 'id' => $result['id']));
     $this->assertEquals("custom string", $check['values'][$check['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__);
index d6d3e7ef1fb972c0757af5ced9fdf6fed8bc6217..7ea7951b61c7da94af454eb5db7d75737654d99c 100644 (file)
@@ -109,7 +109,7 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase {
       'is_active' => 1,
     );
 
-    $customField  = $this->callAPISuccess('custom_field', 'create', $params);
+    $customField  = $this->callAPIAndDocument('custom_field', 'create', $params, __FUNCTION__, __FILE__);
     $params['id'] = $customField['id'];
     $customField  = $this->callAPISuccess('custom_field', 'create', $params);
 
index 1b0c86aa4b048efe622807335e661a8a75c3ad16..530f9654909d8dfc09f5d116ced12ed4ebe133f0 100644 (file)
@@ -58,12 +58,10 @@ class api_v3_CustomValueTest extends CiviUnitTestCase {
   }
 
   public function testCreateCustomValue() {
-
     $params = array(
       'custom_' . $this->ids['single']['custom_field_id'] => 'customString') + $this->params;
 
-    $result = $this->callAPISuccess('custom_value', 'create', $params);
-    $this->assertAPISuccess($result, 'In line ' . __LINE__);
+    $result = $this->callAPIAndDocument('custom_value', 'create', $params, __FUNCTION__, __FILE__);
     $this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
     $result = $this->callAPISuccess('custom_value', 'get', $params);
   }
@@ -86,7 +84,6 @@ class api_v3_CustomValueTest extends CiviUnitTestCase {
 
 
     $result = $this->callAPISuccess('Contact', 'create', $params);
-    $this->assertAPISuccess($result, __LINE__);
     $contact_id = $result['id'];
     $result = $this->callAPISuccess('Contact', 'create',
       array(
index 253e9e9b4e5633703cf0952dda7bacb2fcaf195c..a559cac704a5a02305cbcec048a934d1d31ba1ea 100644 (file)
@@ -50,7 +50,7 @@ class api_v3_EntityTagTest extends CiviUnitTestCase {
     parent::setUp();
 
     $this->_individualID = $this->individualCreate(NULL);
-    $this->_tag = $this->tagCreate(NULL);
+    $this->_tag = $this->tagCreate();
     $this->_tagID = $this->_tag['id'];
     $this->_householdID = $this->houseHoldCreate(NULL);
     $this->_organizationID = $this->organizationCreate(NULL);
@@ -145,7 +145,7 @@ class api_v3_EntityTagTest extends CiviUnitTestCase {
       'tag_id' => $tagID,
     );
 
-    $individualEntity = $this->callAPISuccess('entity_tag', 'create', $params);
+    $individualEntity = $this->callAPIAndDocument('entity_tag', 'create', $params, __FUNCTION__, __FILE__);
     $this->assertEquals($individualEntity['added'], 1);
 
     $paramsEntity = array(
index 0c1819b2e6a8444886e99b27343c4d6d2b02ad61..c97a56e82b639fe60061197e773a391fc4d819c2 100644 (file)
@@ -353,7 +353,7 @@ class api_v3_EventTest extends CiviUnitTestCase {
       'id' => $result['id'], 'max_participants' => 150,
     );
     $this->callAPISuccess('Event', 'Create', $params);
-    $updated = $this->callAPIAndDocument('Event', 'Get', $params, __FUNCTION__, __FILE__);
+    $updated = $this->callAPISuccess('Event', 'Get', $params, __FUNCTION__, __FILE__);
     $this->assertEquals(150, $updated['values'][$result['id']]['max_participants']);
     $this->assertEquals('Annual CiviCRM meet 2', $updated['values'][$result['id']]['title']);
     $this->callAPISuccess($this->_entity, 'Delete', array('id' => $result['id']));
index 3d78b53217932aa52f61e1677bf0f2fddeabbc19..152d7424042956466f228b7284a77b168fcc5961 100644 (file)
@@ -37,46 +37,49 @@ require_once 'CiviTest/CiviUnitTestCase.php';
 
 class api_v3_TagTest extends CiviUnitTestCase {
   protected $_apiversion =3;
+  /**
+   * @ids array of values to be cleaned up in the tear down
+   */
+  protected $ids = array();
+  /**
+   * tag id
+   * @var integer
+   */
+  protected $tag = array();
+
+  protected $tagID;
   public $_eNoticeCompliant = TRUE;
   function setUp() {
     parent::setUp();
+    $this->tag = $this->tagCreate();
+    $this->ids['tag'][] = $this->tagID = $this->tag['id'];
   }
 
-  function tearDown() {}
-
-  ///////////////// civicrm_tag_get methods
-
-  /**
-   * Test civicrm_tag_get with wrong params type.
-   */
-  public function testGetWrongParamsType() {
-    $params = 'is_string';
-    $result = $this->callAPIFailure('tag', 'get', $params);
-    $this->assertEquals('Input variable `params` is not an array', $result['error_message'], 'In line ' . __LINE__);
+  function tearDown() {
+    $this->deleteFromIDSArray();
   }
 
+  ///////////////// civicrm_tag_get methods
   /**
    * Test civicrm_tag_get with wrong params.
    */
   public function testGetWrongParams() {
     $params = array('name' => 'Wrong Tag Name');
     $result = $this->callAPISuccess('tag', 'get', $params);
-    $this->assertEquals(0, $result['count'], 'In line ' . __LINE__);
+    $this->assertEquals(0, $result['count']);
   }
 
   /**
    * Test civicrm_tag_get - success expected.
    */
   public function testGet() {
-    $tag = $this->tagCreate(NULL);
-
     $params = array(
-      'id' => $tag['id'],
-      'name' => $tag['values'][$tag['id']]['name'],
+      'id' => $this->tagID,
+      'name' => $this->tag['name'],
     );
     $result = $this->callAPIAndDocument('tag', 'get', $params, __FUNCTION__, __FILE__);
-    $this->assertEquals($tag['values'][$tag['id']]['description'], $result['values'][$tag['id']]['description'], 'In line ' . __LINE__);
-    $this->assertEquals($tag['values'][$tag['id']]['name'], $result['values'][$tag['id']]['name'], 'In line ' . __LINE__);
+    $this->assertEquals($this->tag['description'], $result['values'][$this->tagID]['description'], 'In line ' . __LINE__);
+    $this->assertEquals($this->tag['name'], $result['values'][$this->tagID]['name']);
   }
 
   /**
@@ -85,29 +88,19 @@ class api_v3_TagTest extends CiviUnitTestCase {
   public function testGetReturnArray() {
     $description = "demonstrates use of Return as an array";
     $subfile     = "getReturnArray";
-    $tag         = $this->tagCreate(NULL);
 
     $params = array(
-      'id' => $tag['id'],
-      'name' => $tag['values'][$tag['id']]['name'],
+      'id' => $this->tagID,
+      'name' => $this->tag['name'],
       'return' => array('name'),
     );
     $result = $this->callAPIAndDocument('tag', 'get', $params, __FUNCTION__, __FILE__, $description, $subfile);
-    $this->assertTrue(empty($result['values'][$tag['id']]['description']), 'In line ' . __LINE__);
-    $this->assertEquals($tag['values'][$tag['id']]['name'], $result['values'][$tag['id']]['name'], 'In line ' . __LINE__);
+    $this->assertTrue(empty($result['values'][$this->tagID]['description']));
+    $this->assertEquals($this->tag['name'], $result['values'][$this->tagID]['name']);
   }
 
   ///////////////// civicrm_tag_create methods
 
-  /**
-   * Test civicrm_tag_create with wrong params type.
-   */
-  function testCreateWrongParamsType() {
-    $params = 'a string';
-    $result = $this->callAPIFailure('tag', 'create', $params);
-    $this->assertEquals('Input variable `params` is not an array', $result['error_message'], 'In line ' . __LINE__);
-  }
-
   /**
    * Test civicrm_tag_create with empty params.
    */
@@ -133,10 +126,9 @@ class api_v3_TagTest extends CiviUnitTestCase {
    */
   function testCreate() {
     $params = array(
-      'name' => 'New Tag3',
-      'description' => 'This is description for New Tag 02',
+      'name' => 'Super Heros',
+      'description' => 'Outside undie-wearers',
     );
-
     $result = $this->callAPIAndDocument('tag', 'create', $params, __FUNCTION__, __FILE__);
     $this->assertNotNull($result['id'], 'In line ' . __LINE__);
     $params['used_for'] = 'civicrm_contact';
@@ -164,22 +156,6 @@ class api_v3_TagTest extends CiviUnitTestCase {
   }
   ///////////////// civicrm_tag_delete methods
 
-  /**
-   * Test civicrm_tag_delete with wrong parameters type.
-   */
-  function testDeleteWrongParamsType() {
-    $tag = 'is string';
-    $result = $this->callAPIFailure('tag', 'delete', $tag);
-    $this->assertEquals('Input variable `params` is not an array', $result['error_message'], 'In line ' . __LINE__);
-  }
-
-  /**
-   * Test civicrm_tag_delete with empty parameters.
-   */
-  function testDeleteEmptyParams() {
-    $result = $this->callAPIFailure('tag', 'delete', array(), 'Mandatory key(s) missing from params array: id');
-  }
-
   /**
    * Test civicrm_tag_delete without tag id.
    */
@@ -191,22 +167,22 @@ class api_v3_TagTest extends CiviUnitTestCase {
    * Test civicrm_tag_delete .
    */
   function testTagDeleteOldSyntax() {
-    $tagID = $this->tagCreate(NULL);
     $params = array(
-      'tag_id' => $tagID['id'],
+      'tag_id' => $this->tagID,
     );
     $result = $this->callAPISuccess('tag', 'delete', $params);
+    unset($this->ids['tag']);
   }
 
   /**
    * Test civicrm_tag_delete = $params['id'] is correct
    */
   function testTagDeleteCorrectSyntax() {
-    $tagID = $this->tagCreate(NULL);
     $params = array(
-      'id' => $tagID['id'],
+      'id' => $this->tagID,
     );
     $result = $this->callAPIAndDocument('tag', 'delete', $params, __FUNCTION__, __FILE__);
+    unset($this->ids['tag']);
   }
 
   function testTagGetfields() {
index 4681d7ecfb0e52cd791ab58c5aa890984f2db337..a13d722fa9a23d4708315f293654232fdce23d35 100644 (file)
@@ -52,4 +52,4 @@ function {$function}_expectedresult(){literal}{{/literal}
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/