From fb32de45a2f42247703980bb3a68eb63eca177df Mon Sep 17 00:00:00 2001 From: eileen Date: Sun, 28 Jul 2013 21:58:02 +1200 Subject: [PATCH] CRM-13072 Update examples --- .../Activity/ContactRefCustomField.php | 24 +- .../Activity/ContactRefCustomFieldGet.php | 24 +- api/v3/examples/Activity/DateTimeHigh.php | 24 +- api/v3/examples/Activity/DateTimeLow.php | 24 +- .../Activity/GetTargetandAssignee.php | 24 +- .../Activity/ReturnAssigneeContact.php | 24 +- api/v3/examples/ActivityCreate.php | 24 +- api/v3/examples/ActivityDelete.php | 24 +- api/v3/examples/ActivityGet.php | 24 +- api/v3/examples/ActivityGetfields.php | 24 +- api/v3/examples/ActivityTypeCreate.php | 24 +- api/v3/examples/ActivityTypeGet.php | 27 +- api/v3/examples/Address/AddressLike.php | 24 +- api/v3/examples/Address/AddressParse.php | 24 +- api/v3/examples/Address/AddressSort.php | 24 +- api/v3/examples/AddressCreate.php | 24 +- api/v3/examples/AddressDelete.php | 34 +-- api/v3/examples/AddressGet.php | 24 +- api/v3/examples/BatchCreate.php | 27 +- api/v3/examples/BatchDelete.php | 25 +- api/v3/examples/BatchGet.php | 25 +- api/v3/examples/BatchUpdate.php | 27 +- api/v3/examples/CampaignCreate.php | 26 +- api/v3/examples/CampaignDelete.php | 24 +- api/v3/examples/CampaignGet.php | 26 +- api/v3/examples/ConstantGet.php | 24 +- api/v3/examples/Contact/APIChainedArray.php | 24 +- .../Contact/APIChainedArrayFormats.php | 26 +- .../Contact/APIChainedArrayMultipleCustom.php | 57 ++-- ...IChainedArrayValuesFromSiblingFunction.php | 30 ++- api/v3/examples/Contact/ChainTwoWebsites.php | 28 +- .../Contact/ChainTwoWebsitesSyntax2.php | 28 +- api/v3/examples/Contact/CustomFieldCreate.php | 27 +- api/v3/examples/Contact/CustomFieldGet.php | 34 ++- .../CustomFieldGetReturnSyntaxVariation.php | 30 ++- .../examples/Contact/FormatIsSuccess_Fail.php | 26 +- .../examples/Contact/FormatIsSuccess_True.php | 26 +- api/v3/examples/Contact/FormatOnlyID.php | 26 +- api/v3/examples/Contact/FormatSingleValue.php | 26 +- api/v3/examples/Contact/GetCountContact.php | 28 +- api/v3/examples/Contact/GetFieldsOptions.php | 80 +++--- api/v3/examples/Contact/GetSingleContact.php | 26 +- .../Contact/GroupFilterUsingContactAPI.php | 24 +- api/v3/examples/ContactCreate.php | 248 ++++++------------ api/v3/examples/ContactDelete.php | 26 +- api/v3/examples/ContactGet.php | 24 +- api/v3/examples/ContactGetoptions.php | 24 +- .../ContributionCreateWithNote.php | 24 +- .../ContributionCreateWithSoftCredit.php | 24 +- .../CreateWithNestedLineItems.php | 25 +- api/v3/examples/ContributionCreate.php | 24 +- api/v3/examples/ContributionDelete.php | 24 +- api/v3/examples/ContributionGet.php | 25 +- api/v3/examples/ContributionPageCreate.php | 26 +- api/v3/examples/ContributionPageDelete.php | 24 +- api/v3/examples/ContributionPageGet.php | 24 +- api/v3/examples/ContributionRecurCreate.php | 26 +- api/v3/examples/ContributionRecurDelete.php | 24 +- api/v3/examples/ContributionRecurGet.php | 26 +- api/v3/examples/ContributionSoftCreate.php | 24 +- api/v3/examples/ContributionSoftDelete.php | 24 +- api/v3/examples/ContributionSoftGet.php | 26 +- api/v3/examples/CustomFieldCreate.php | 144 +++++----- api/v3/examples/CustomFieldDelete.php | 24 +- api/v3/examples/CustomGroupCreate.php | 26 +- api/v3/examples/CustomGroupDelete.php | 24 +- api/v3/examples/CustomGroupGet.php | 28 +- .../examples/CustomValue/formatFieldName.php | 25 +- api/v3/examples/CustomValueCreate.php | 28 +- api/v3/examples/CustomValueGet.php | 25 +- api/v3/examples/DomainCreate.php | 24 +- api/v3/examples/DomainGet.php | 28 +- api/v3/examples/Email/NestedReplaceEmail.php | 24 +- api/v3/examples/EmailCreate.php | 24 +- api/v3/examples/EmailDelete.php | 29 +- api/v3/examples/EmailReplace.php | 24 +- api/v3/examples/EntityTagCreate.php | 26 +- api/v3/examples/EntityTagDelete.php | 26 +- api/v3/examples/EntityTagGet.php | 62 +++++ api/v3/examples/Event/IsCurrentOption.php | 35 ++- api/v3/examples/Event/IsFullOption.php | 26 +- api/v3/examples/EventCreate.php | 26 +- api/v3/examples/EventDelete.php | 24 +- api/v3/examples/EventGet.php | 27 +- api/v3/examples/EventUpdate.php | 122 --------- api/v3/examples/GrantCreate.php | 28 +- api/v3/examples/GrantDelete.php | 33 +-- api/v3/examples/GrantGet.php | 35 +-- api/v3/examples/Group/getfields.php | 24 +- api/v3/examples/GroupContact.php | 31 --- .../examples/GroupContact/GetWithGroupID.php | 24 +- api/v3/examples/GroupContactCreate.php | 24 +- api/v3/examples/GroupContactDelete.php | 24 +- api/v3/examples/GroupContactGet.php | 26 +- api/v3/examples/GroupGet.php | 40 +-- api/v3/examples/GroupNestingCreate.php | 24 +- api/v3/examples/GroupNestingDelete.php | 24 +- api/v3/examples/GroupNestingGet.php | 24 +- api/v3/examples/GroupOrganizationCreate.php | 24 +- api/v3/examples/GroupOrganizationDelete.php | 24 +- api/v3/examples/GroupOrganizationGet.php | 24 +- api/v3/examples/ImCreate.php | 24 +- api/v3/examples/ImDelete.php | 24 +- api/v3/examples/ImGet.php | 24 +- api/v3/examples/JobCreate.php | 24 +- api/v3/examples/JobDelete.php | 24 +- api/v3/examples/LineItemCreate.php | 40 ++- api/v3/examples/LineItemDelete.php | 24 +- api/v3/examples/LineItemGet.php | 26 +- api/v3/examples/LocBlockCreate.php | 28 +- api/v3/examples/LocBlockCreateEntities.php | 25 +- api/v3/examples/LocBlockGet.php | 24 +- .../MailSettings/ChainedGetDelete.php | 24 +- api/v3/examples/MailSettingsCreate.php | 24 +- api/v3/examples/MailSettingsDelete.php | 32 +-- api/v3/examples/MailSettingsGet.php | 24 +- api/v3/examples/MailingCreate.php | 32 ++- ...tivityTypeDelete.php => MailingDelete.php} | 40 +-- api/v3/examples/MailingGroupSubscribe.php | 26 +- .../examples/Membership/filterIsCurrent.php | 24 +- api/v3/examples/MembershipCreate.php | 38 +-- api/v3/examples/MembershipDelete.php | 26 +- api/v3/examples/MembershipGet.php | 24 +- api/v3/examples/MembershipPaymentCreate.php | 24 +- api/v3/examples/MembershipPaymentGet.php | 24 +- api/v3/examples/MembershipStatusCreate.php | 30 ++- api/v3/examples/MembershipStatusGet.php | 30 ++- api/v3/examples/MembershipTypeCreate.php | 24 +- api/v3/examples/MembershipTypeDelete.php | 24 +- api/v3/examples/MembershipTypeGet.php | 24 +- api/v3/examples/MembershipUpdate.php | 38 +-- api/v3/examples/NoteCreate.php | 24 +- api/v3/examples/NoteDelete.php | 24 +- api/v3/examples/NoteGet.php | 28 +- api/v3/examples/OptionGroupCreate.php | 31 ++- api/v3/examples/OptionGroupDelete.php | 27 +- api/v3/examples/OptionGroupGet.php | 25 +- api/v3/examples/OptionValue/SortOption.php | 24 +- api/v3/examples/OptionValueGet.php | 24 +- .../Participant/CreateParticipantPayment.php | 32 ++- api/v3/examples/Participant/NestedDelete.php | 28 +- .../examples/Participant/NestedEventGet.php | 26 +- api/v3/examples/ParticipantCreate.php | 24 +- api/v3/examples/ParticipantGet.php | 24 +- api/v3/examples/ParticipantPaymentCreate.php | 24 +- api/v3/examples/ParticipantPaymentDelete.php | 24 +- api/v3/examples/ParticipantPaymentGet.php | 24 +- .../examples/ParticipantStatusTypeCreate.php | 24 +- .../examples/ParticipantStatusTypeDelete.php | 33 +-- api/v3/examples/ParticipantStatusTypeGet.php | 24 +- api/v3/examples/PaymentProcessorCreate.php | 24 +- api/v3/examples/PaymentProcessorDelete.php | 24 +- .../examples/PaymentProcessorTypeCreate.php | 24 +- .../examples/PaymentProcessorTypeDelete.php | 24 +- api/v3/examples/PhoneCreate.php | 24 +- api/v3/examples/PhoneDelete.php | 30 ++- api/v3/examples/PhoneGet.php | 30 ++- api/v3/examples/Pledge/GetFilterHighDate.php | 28 +- api/v3/examples/PledgeCreate.php | 34 ++- api/v3/examples/PledgeDelete.php | 24 +- api/v3/examples/PledgeGet.php | 28 +- api/v3/examples/PledgePaymentCreate.php | 24 +- api/v3/examples/PledgePaymentDelete.php | 24 +- api/v3/examples/PledgePaymentGet.php | 37 +-- api/v3/examples/PledgePaymentUpdate.php | 32 ++- api/v3/examples/PriceFieldCreate.php | 24 +- api/v3/examples/PriceFieldDelete.php | 24 +- api/v3/examples/PriceFieldGet.php | 24 +- api/v3/examples/PriceFieldValueCreate.php | 24 +- api/v3/examples/PriceFieldValueDelete.php | 24 +- api/v3/examples/PriceFieldValueGet.php | 24 +- api/v3/examples/PriceSetCreate.php | 30 ++- api/v3/examples/PriceSetDelete.php | 26 +- api/v3/examples/PriceSetGet.php | 24 +- api/v3/examples/PriceSetSet.php | 30 ++- api/v3/examples/ProfileApply.php | 24 +- api/v3/examples/ProfileGet.php | 24 +- api/v3/examples/ProfileSet.php | 34 ++- .../Relationship/BetweenRelationshipType.php | 47 ++-- .../Relationship/INRelationshipType.php | 41 +-- .../NotBetweenRelationshipType.php | 35 ++- .../Relationship/NotInRelationshipType.php | 41 +-- .../examples/Relationship/filterIsCurrent.php | 31 ++- api/v3/examples/RelationshipCreate.php | 37 +-- api/v3/examples/RelationshipDelete.php | 25 +- api/v3/examples/RelationshipGet.php | 31 ++- api/v3/examples/RelationshipTypeCreate.php | 24 +- api/v3/examples/RelationshipTypeDelete.php | 26 +- api/v3/examples/Setting/CreateAllDomains.php | 24 +- .../Setting/CreateSettingCurrentDomain.php | 24 +- .../Setting/CreateSpecifiedDomains.php | 24 +- api/v3/examples/Setting/GetAllDomains.php | 24 +- api/v3/examples/Setting/GetDefaults.php | 24 +- .../Setting/GetSettingCurrentDomain.php | 24 +- .../examples/Setting/GetSpecifiedDomains.php | 24 +- api/v3/examples/SettingCreate.php | 24 +- api/v3/examples/SettingGet.php | 24 +- api/v3/examples/SettingGetValue.php | 24 +- api/v3/examples/SettingGetfields.php | 108 +++++--- api/v3/examples/SettingRevert.php | 24 +- api/v3/examples/Survey/ChainedGetDelete.php | 27 +- api/v3/examples/SurveyCreate.php | 27 +- api/v3/examples/SurveyDelete.php | 25 +- api/v3/examples/SurveyGet.php | 27 +- api/v3/examples/SurveyRespondantGet.php | 24 +- api/v3/examples/System/Flush.php | 27 +- api/v3/examples/Tag/getReturnArray.php | 36 ++- api/v3/examples/TagCreate.php | 40 +-- api/v3/examples/TagDelete.php | 26 +- api/v3/examples/TagGet.php | 40 +-- api/v3/examples/TagGetfields.php | 123 +++++++++ api/v3/examples/UFFieldCreate.php | 24 +- api/v3/examples/UFFieldDelete.php | 25 +- api/v3/examples/UFFieldGet.php | 28 +- api/v3/examples/UFFieldReplace.php | 24 +- api/v3/examples/UFGroupCreate.php | 26 +- api/v3/examples/UFGroupDelete.php | 24 +- api/v3/examples/UFGroupGet.php | 26 +- api/v3/examples/UFJoinCreate.php | 24 +- api/v3/examples/UFJoinGet.php | 24 +- api/v3/examples/UFMatchGet.php | 24 +- api/v3/examples/WebsiteCreate.php | 24 +- api/v3/examples/WebsiteDelete.php | 24 +- api/v3/examples/WebsiteGet.php | 24 +- api/v3/utils.php | 6 +- tests/phpunit/CiviTest/CiviUnitTestCase.php | 41 +-- tests/phpunit/api/v3/ContactTest.php | 2 +- tests/phpunit/api/v3/CustomFieldTest.php | 2 +- tests/phpunit/api/v3/CustomValueTest.php | 5 +- tests/phpunit/api/v3/EntityTagTest.php | 4 +- tests/phpunit/api/v3/EventTest.php | 2 +- tests/phpunit/api/v3/TagTest.php | 86 +++--- tests/templates/documentFunction.tpl | 2 +- 233 files changed, 4229 insertions(+), 2605 deletions(-) delete mode 100644 api/v3/examples/EventUpdate.php delete mode 100644 api/v3/examples/GroupContact.php rename api/v3/examples/{ActivityTypeDelete.php => MailingDelete.php} (55%) create mode 100644 api/v3/examples/TagGetfields.php diff --git a/api/v3/examples/Activity/ContactRefCustomField.php b/api/v3/examples/Activity/ContactRefCustomField.php index 01df6b00ba..812322f37b 100644 --- a/api/v3/examples/Activity/ContactRefCustomField.php +++ b/api/v3/examples/Activity/ContactRefCustomField.php @@ -1,7 +1,7 @@ 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; } diff --git a/api/v3/examples/Activity/ContactRefCustomFieldGet.php b/api/v3/examples/Activity/ContactRefCustomFieldGet.php index cb43f90574..fb684c6992 100644 --- a/api/v3/examples/Activity/ContactRefCustomFieldGet.php +++ b/api/v3/examples/Activity/ContactRefCustomFieldGet.php @@ -1,7 +1,7 @@ 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; } diff --git a/api/v3/examples/Activity/DateTimeHigh.php b/api/v3/examples/Activity/DateTimeHigh.php index 31fa3ab788..e5b1d98402 100644 --- a/api/v3/examples/Activity/DateTimeHigh.php +++ b/api/v3/examples/Activity/DateTimeHigh.php @@ -1,22 +1,30 @@ 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; } diff --git a/api/v3/examples/Activity/DateTimeLow.php b/api/v3/examples/Activity/DateTimeLow.php index a15ded6182..06112d8e66 100644 --- a/api/v3/examples/Activity/DateTimeLow.php +++ b/api/v3/examples/Activity/DateTimeLow.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/Activity/GetTargetandAssignee.php b/api/v3/examples/Activity/GetTargetandAssignee.php index f19a5719d9..8b83ea741d 100644 --- a/api/v3/examples/Activity/GetTargetandAssignee.php +++ b/api/v3/examples/Activity/GetTargetandAssignee.php @@ -1,7 +1,7 @@ '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; } diff --git a/api/v3/examples/Activity/ReturnAssigneeContact.php b/api/v3/examples/Activity/ReturnAssigneeContact.php index a69aea08ad..dd5f904239 100644 --- a/api/v3/examples/Activity/ReturnAssigneeContact.php +++ b/api/v3/examples/Activity/ReturnAssigneeContact.php @@ -1,12 +1,11 @@ 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; } diff --git a/api/v3/examples/ActivityCreate.php b/api/v3/examples/ActivityCreate.php index 3c58cdf409..38c3dd6ca1 100644 --- a/api/v3/examples/ActivityCreate.php +++ b/api/v3/examples/ActivityCreate.php @@ -1,7 +1,7 @@ 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; } diff --git a/api/v3/examples/ActivityDelete.php b/api/v3/examples/ActivityDelete.php index 1f01607de8..19b198d1dc 100644 --- a/api/v3/examples/ActivityDelete.php +++ b/api/v3/examples/ActivityDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/ActivityGet.php b/api/v3/examples/ActivityGet.php index 81f92c4e69..ca2aec0e30 100644 --- a/api/v3/examples/ActivityGet.php +++ b/api/v3/examples/ActivityGet.php @@ -1,23 +1,31 @@ 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; } diff --git a/api/v3/examples/ActivityGetfields.php b/api/v3/examples/ActivityGetfields.php index ae9f6996ed..7e493fb8cf 100644 --- a/api/v3/examples/ActivityGetfields.php +++ b/api/v3/examples/ActivityGetfields.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/ActivityTypeCreate.php b/api/v3/examples/ActivityTypeCreate.php index 9ae09772d1..1f06df0f0a 100644 --- a/api/v3/examples/ActivityTypeCreate.php +++ b/api/v3/examples/ActivityTypeCreate.php @@ -1,25 +1,33 @@ '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; } diff --git a/api/v3/examples/ActivityTypeGet.php b/api/v3/examples/ActivityTypeGet.php index 250250e7f2..ea32e955cc 100644 --- a/api/v3/examples/ActivityTypeGet.php +++ b/api/v3/examples/ActivityTypeGet.php @@ -1,19 +1,26 @@ 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; } diff --git a/api/v3/examples/Address/AddressLike.php b/api/v3/examples/Address/AddressLike.php index 26bfd074df..33c263ee08 100644 --- a/api/v3/examples/Address/AddressLike.php +++ b/api/v3/examples/Address/AddressLike.php @@ -1,23 +1,31 @@ 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; } diff --git a/api/v3/examples/Address/AddressParse.php b/api/v3/examples/Address/AddressParse.php index 192e08894f..8fe23d354e 100644 --- a/api/v3/examples/Address/AddressParse.php +++ b/api/v3/examples/Address/AddressParse.php @@ -1,23 +1,31 @@ 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; } diff --git a/api/v3/examples/Address/AddressSort.php b/api/v3/examples/Address/AddressSort.php index 56e54f582c..15a83157b4 100644 --- a/api/v3/examples/Address/AddressSort.php +++ b/api/v3/examples/Address/AddressSort.php @@ -1,7 +1,7 @@ '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; } diff --git a/api/v3/examples/AddressCreate.php b/api/v3/examples/AddressCreate.php index 4a5a648007..51fd3683d4 100644 --- a/api/v3/examples/AddressCreate.php +++ b/api/v3/examples/AddressCreate.php @@ -1,7 +1,7 @@ '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; } diff --git a/api/v3/examples/AddressDelete.php b/api/v3/examples/AddressDelete.php index c1e9507756..49e7010415 100644 --- a/api/v3/examples/AddressDelete.php +++ b/api/v3/examples/AddressDelete.php @@ -1,28 +1,28 @@ 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; } diff --git a/api/v3/examples/AddressGet.php b/api/v3/examples/AddressGet.php index 502aa18115..9db7840060 100644 --- a/api/v3/examples/AddressGet.php +++ b/api/v3/examples/AddressGet.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/BatchCreate.php b/api/v3/examples/BatchCreate.php index 6b83ee7df9..55e2297d3a 100644 --- a/api/v3/examples/BatchCreate.php +++ b/api/v3/examples/BatchCreate.php @@ -1,7 +1,7 @@ '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; } diff --git a/api/v3/examples/BatchDelete.php b/api/v3/examples/BatchDelete.php index 9830a487fb..6149e3fcac 100644 --- a/api/v3/examples/BatchDelete.php +++ b/api/v3/examples/BatchDelete.php @@ -1,21 +1,28 @@ 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; } diff --git a/api/v3/examples/BatchGet.php b/api/v3/examples/BatchGet.php index 2b5c737023..449cf74db4 100644 --- a/api/v3/examples/BatchGet.php +++ b/api/v3/examples/BatchGet.php @@ -1,21 +1,28 @@ 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; } diff --git a/api/v3/examples/BatchUpdate.php b/api/v3/examples/BatchUpdate.php index 2b2fa50889..109789ce94 100644 --- a/api/v3/examples/BatchUpdate.php +++ b/api/v3/examples/BatchUpdate.php @@ -1,7 +1,7 @@ '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; } diff --git a/api/v3/examples/CampaignCreate.php b/api/v3/examples/CampaignCreate.php index 8fd508ba4b..e5094280f5 100644 --- a/api/v3/examples/CampaignCreate.php +++ b/api/v3/examples/CampaignCreate.php @@ -1,22 +1,30 @@ 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; } diff --git a/api/v3/examples/CampaignDelete.php b/api/v3/examples/CampaignDelete.php index e929d20327..8ae1877d77 100644 --- a/api/v3/examples/CampaignDelete.php +++ b/api/v3/examples/CampaignDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/CampaignGet.php b/api/v3/examples/CampaignGet.php index 5a61b38983..2fac41eaae 100644 --- a/api/v3/examples/CampaignGet.php +++ b/api/v3/examples/CampaignGet.php @@ -1,22 +1,30 @@ 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; } diff --git a/api/v3/examples/ConstantGet.php b/api/v3/examples/ConstantGet.php index 2a2b8fe60b..42f6a59b59 100644 --- a/api/v3/examples/ConstantGet.php +++ b/api/v3/examples/ConstantGet.php @@ -1,20 +1,28 @@ '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; } diff --git a/api/v3/examples/Contact/APIChainedArray.php b/api/v3/examples/Contact/APIChainedArray.php index a14c048fde..4436fb8d27 100644 --- a/api/v3/examples/Contact/APIChainedArray.php +++ b/api/v3/examples/Contact/APIChainedArray.php @@ -1,12 +1,11 @@ 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; } diff --git a/api/v3/examples/Contact/APIChainedArrayFormats.php b/api/v3/examples/Contact/APIChainedArrayFormats.php index 576cbbed3e..02c3231881 100644 --- a/api/v3/examples/Contact/APIChainedArrayFormats.php +++ b/api/v3/examples/Contact/APIChainedArrayFormats.php @@ -1,13 +1,12 @@ 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; } diff --git a/api/v3/examples/Contact/APIChainedArrayMultipleCustom.php b/api/v3/examples/Contact/APIChainedArrayMultipleCustom.php index 320c448a73..3409d3538a 100644 --- a/api/v3/examples/Contact/APIChainedArrayMultipleCustom.php +++ b/api/v3/examples/Contact/APIChainedArrayMultipleCustom.php @@ -1,12 +1,11 @@ 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; } diff --git a/api/v3/examples/Contact/APIChainedArrayValuesFromSiblingFunction.php b/api/v3/examples/Contact/APIChainedArrayValuesFromSiblingFunction.php index d1fb46798a..e303628b40 100644 --- a/api/v3/examples/Contact/APIChainedArrayValuesFromSiblingFunction.php +++ b/api/v3/examples/Contact/APIChainedArrayValuesFromSiblingFunction.php @@ -1,12 +1,11 @@ 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; } diff --git a/api/v3/examples/Contact/ChainTwoWebsites.php b/api/v3/examples/Contact/ChainTwoWebsites.php index 3f7afaa34b..fcc1bacb27 100644 --- a/api/v3/examples/Contact/ChainTwoWebsites.php +++ b/api/v3/examples/Contact/ChainTwoWebsites.php @@ -1,7 +1,7 @@ '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; } diff --git a/api/v3/examples/Contact/ChainTwoWebsitesSyntax2.php b/api/v3/examples/Contact/ChainTwoWebsitesSyntax2.php index a6480efee9..83acfc5f8d 100644 --- a/api/v3/examples/Contact/ChainTwoWebsitesSyntax2.php +++ b/api/v3/examples/Contact/ChainTwoWebsitesSyntax2.php @@ -1,7 +1,7 @@ '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; } diff --git a/api/v3/examples/Contact/CustomFieldCreate.php b/api/v3/examples/Contact/CustomFieldCreate.php index 6c2442336e..1e885ef8e6 100644 --- a/api/v3/examples/Contact/CustomFieldCreate.php +++ b/api/v3/examples/Contact/CustomFieldCreate.php @@ -1,23 +1,32 @@ '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; } diff --git a/api/v3/examples/Contact/CustomFieldGet.php b/api/v3/examples/Contact/CustomFieldGet.php index 5806b7cb4c..7076ac7373 100644 --- a/api/v3/examples/Contact/CustomFieldGet.php +++ b/api/v3/examples/Contact/CustomFieldGet.php @@ -1,23 +1,29 @@ '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; } diff --git a/api/v3/examples/Contact/CustomFieldGetReturnSyntaxVariation.php b/api/v3/examples/Contact/CustomFieldGetReturnSyntaxVariation.php index 3a1e9694ba..2d69422671 100644 --- a/api/v3/examples/Contact/CustomFieldGetReturnSyntaxVariation.php +++ b/api/v3/examples/Contact/CustomFieldGetReturnSyntaxVariation.php @@ -1,21 +1,29 @@ '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; } diff --git a/api/v3/examples/Contact/FormatIsSuccess_Fail.php b/api/v3/examples/Contact/FormatIsSuccess_Fail.php index 481580e94f..8ba618db7e 100644 --- a/api/v3/examples/Contact/FormatIsSuccess_Fail.php +++ b/api/v3/examples/Contact/FormatIsSuccess_Fail.php @@ -1,29 +1,37 @@ 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; } diff --git a/api/v3/examples/Contact/FormatIsSuccess_True.php b/api/v3/examples/Contact/FormatIsSuccess_True.php index 51ae3d5c10..77b6f35eea 100644 --- a/api/v3/examples/Contact/FormatIsSuccess_True.php +++ b/api/v3/examples/Contact/FormatIsSuccess_True.php @@ -1,29 +1,37 @@ 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; } diff --git a/api/v3/examples/Contact/FormatOnlyID.php b/api/v3/examples/Contact/FormatOnlyID.php index e777c6e940..3acbd4dc3a 100644 --- a/api/v3/examples/Contact/FormatOnlyID.php +++ b/api/v3/examples/Contact/FormatOnlyID.php @@ -1,30 +1,38 @@ 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; } diff --git a/api/v3/examples/Contact/FormatSingleValue.php b/api/v3/examples/Contact/FormatSingleValue.php index 252829cdde..2e9b14250c 100644 --- a/api/v3/examples/Contact/FormatSingleValue.php +++ b/api/v3/examples/Contact/FormatSingleValue.php @@ -1,30 +1,38 @@ 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; } diff --git a/api/v3/examples/Contact/GetCountContact.php b/api/v3/examples/Contact/GetCountContact.php index f022c50db1..d9b8e566e2 100644 --- a/api/v3/examples/Contact/GetCountContact.php +++ b/api/v3/examples/Contact/GetCountContact.php @@ -1,28 +1,36 @@ 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; } diff --git a/api/v3/examples/Contact/GetFieldsOptions.php b/api/v3/examples/Contact/GetFieldsOptions.php index fac0bae4e7..032ddc9c02 100644 --- a/api/v3/examples/Contact/GetFieldsOptions.php +++ b/api/v3/examples/Contact/GetFieldsOptions.php @@ -1,23 +1,31 @@ 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; } diff --git a/api/v3/examples/Contact/GetSingleContact.php b/api/v3/examples/Contact/GetSingleContact.php index 9512633955..6b22a2f9a1 100644 --- a/api/v3/examples/Contact/GetSingleContact.php +++ b/api/v3/examples/Contact/GetSingleContact.php @@ -1,22 +1,30 @@ 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; } diff --git a/api/v3/examples/Contact/GroupFilterUsingContactAPI.php b/api/v3/examples/Contact/GroupFilterUsingContactAPI.php index 6e11f1bfb6..3c76bda6af 100644 --- a/api/v3/examples/Contact/GroupFilterUsingContactAPI.php +++ b/api/v3/examples/Contact/GroupFilterUsingContactAPI.php @@ -1,7 +1,7 @@ 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; } diff --git a/api/v3/examples/ContactCreate.php b/api/v3/examples/ContactCreate.php index 44c0afe0d7..9f9e0b8438 100644 --- a/api/v3/examples/ContactCreate.php +++ b/api/v3/examples/ContactCreate.php @@ -1,191 +1,113 @@ '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 diff --git a/api/v3/examples/ContactDelete.php b/api/v3/examples/ContactDelete.php index 01bc26c2ec..f299e0244b 100644 --- a/api/v3/examples/ContactDelete.php +++ b/api/v3/examples/ContactDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/ContactGet.php b/api/v3/examples/ContactGet.php index b4dc0bbe9a..a597b7bbf8 100644 --- a/api/v3/examples/ContactGet.php +++ b/api/v3/examples/ContactGet.php @@ -1,20 +1,28 @@ '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; } diff --git a/api/v3/examples/ContactGetoptions.php b/api/v3/examples/ContactGetoptions.php index 12f2272acf..2497092f17 100644 --- a/api/v3/examples/ContactGetoptions.php +++ b/api/v3/examples/ContactGetoptions.php @@ -1,20 +1,28 @@ '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; } diff --git a/api/v3/examples/Contribution/ContributionCreateWithNote.php b/api/v3/examples/Contribution/ContributionCreateWithNote.php index 95cf55adc7..efd3a0c1bd 100644 --- a/api/v3/examples/Contribution/ContributionCreateWithNote.php +++ b/api/v3/examples/Contribution/ContributionCreateWithNote.php @@ -1,7 +1,7 @@ 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; } diff --git a/api/v3/examples/Contribution/ContributionCreateWithSoftCredit.php b/api/v3/examples/Contribution/ContributionCreateWithSoftCredit.php index 7dda9bfe72..5517820800 100644 --- a/api/v3/examples/Contribution/ContributionCreateWithSoftCredit.php +++ b/api/v3/examples/Contribution/ContributionCreateWithSoftCredit.php @@ -1,7 +1,7 @@ '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; } diff --git a/api/v3/examples/Contribution/CreateWithNestedLineItems.php b/api/v3/examples/Contribution/CreateWithNestedLineItems.php index 19950dd494..4f00ff1846 100644 --- a/api/v3/examples/Contribution/CreateWithNestedLineItems.php +++ b/api/v3/examples/Contribution/CreateWithNestedLineItems.php @@ -1,7 +1,7 @@ 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; } diff --git a/api/v3/examples/ContributionCreate.php b/api/v3/examples/ContributionCreate.php index 5eece67eae..196512eaf8 100644 --- a/api/v3/examples/ContributionCreate.php +++ b/api/v3/examples/ContributionCreate.php @@ -1,7 +1,7 @@ 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; } diff --git a/api/v3/examples/ContributionDelete.php b/api/v3/examples/ContributionDelete.php index 76bcf2e3e1..f2586828a5 100644 --- a/api/v3/examples/ContributionDelete.php +++ b/api/v3/examples/ContributionDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/ContributionGet.php b/api/v3/examples/ContributionGet.php index b1f1f37052..41f8714c28 100644 --- a/api/v3/examples/ContributionGet.php +++ b/api/v3/examples/ContributionGet.php @@ -1,21 +1,28 @@ 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; } diff --git a/api/v3/examples/ContributionPageCreate.php b/api/v3/examples/ContributionPageCreate.php index 4ac57e44a9..b2ae487b57 100644 --- a/api/v3/examples/ContributionPageCreate.php +++ b/api/v3/examples/ContributionPageCreate.php @@ -1,23 +1,31 @@ 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; } diff --git a/api/v3/examples/ContributionPageDelete.php b/api/v3/examples/ContributionPageDelete.php index 49735c77b1..dc3a05d59c 100644 --- a/api/v3/examples/ContributionPageDelete.php +++ b/api/v3/examples/ContributionPageDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/ContributionPageGet.php b/api/v3/examples/ContributionPageGet.php index aba7ccea51..bdb335613a 100644 --- a/api/v3/examples/ContributionPageGet.php +++ b/api/v3/examples/ContributionPageGet.php @@ -1,22 +1,30 @@ 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; } diff --git a/api/v3/examples/ContributionRecurCreate.php b/api/v3/examples/ContributionRecurCreate.php index 722de8ea18..c83fb85f74 100644 --- a/api/v3/examples/ContributionRecurCreate.php +++ b/api/v3/examples/ContributionRecurCreate.php @@ -1,11 +1,10 @@ 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; } diff --git a/api/v3/examples/ContributionRecurDelete.php b/api/v3/examples/ContributionRecurDelete.php index 70848d36d9..2f4a8e0ce4 100644 --- a/api/v3/examples/ContributionRecurDelete.php +++ b/api/v3/examples/ContributionRecurDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/ContributionRecurGet.php b/api/v3/examples/ContributionRecurGet.php index b1d1ebdda5..6158d65a30 100644 --- a/api/v3/examples/ContributionRecurGet.php +++ b/api/v3/examples/ContributionRecurGet.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/ContributionSoftCreate.php b/api/v3/examples/ContributionSoftCreate.php index 3f042d8df8..c9e12465f1 100644 --- a/api/v3/examples/ContributionSoftCreate.php +++ b/api/v3/examples/ContributionSoftCreate.php @@ -1,7 +1,7 @@ 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; } diff --git a/api/v3/examples/ContributionSoftDelete.php b/api/v3/examples/ContributionSoftDelete.php index 1948ac716c..5ca7d1b92d 100644 --- a/api/v3/examples/ContributionSoftDelete.php +++ b/api/v3/examples/ContributionSoftDelete.php @@ -1,27 +1,35 @@ 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; } diff --git a/api/v3/examples/ContributionSoftGet.php b/api/v3/examples/ContributionSoftGet.php index ec8044630d..93625387da 100644 --- a/api/v3/examples/ContributionSoftGet.php +++ b/api/v3/examples/ContributionSoftGet.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/CustomFieldCreate.php b/api/v3/examples/CustomFieldCreate.php index fa6d263de2..c0496c093c 100644 --- a/api/v3/examples/CustomFieldCreate.php +++ b/api/v3/examples/CustomFieldCreate.php @@ -1,89 +1,103 @@ 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 diff --git a/api/v3/examples/CustomFieldDelete.php b/api/v3/examples/CustomFieldDelete.php index 696de1ac1d..db4437fccb 100644 --- a/api/v3/examples/CustomFieldDelete.php +++ b/api/v3/examples/CustomFieldDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/CustomGroupCreate.php b/api/v3/examples/CustomGroupCreate.php index c03dd48761..c570893247 100644 --- a/api/v3/examples/CustomGroupCreate.php +++ b/api/v3/examples/CustomGroupCreate.php @@ -1,7 +1,7 @@ '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; } diff --git a/api/v3/examples/CustomGroupDelete.php b/api/v3/examples/CustomGroupDelete.php index 0c2d0aefe7..e5b7dc15e6 100644 --- a/api/v3/examples/CustomGroupDelete.php +++ b/api/v3/examples/CustomGroupDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/CustomGroupGet.php b/api/v3/examples/CustomGroupGet.php index 6195030bca..35d4217897 100644 --- a/api/v3/examples/CustomGroupGet.php +++ b/api/v3/examples/CustomGroupGet.php @@ -1,19 +1,26 @@ 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; } diff --git a/api/v3/examples/CustomValue/formatFieldName.php b/api/v3/examples/CustomValue/formatFieldName.php index 3279ad8db1..e88d7b454f 100644 --- a/api/v3/examples/CustomValue/formatFieldName.php +++ b/api/v3/examples/CustomValue/formatFieldName.php @@ -1,22 +1,30 @@ 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; } diff --git a/api/v3/examples/CustomValueCreate.php b/api/v3/examples/CustomValueCreate.php index 92c75ced3b..fb8e0479f4 100644 --- a/api/v3/examples/CustomValueCreate.php +++ b/api/v3/examples/CustomValueCreate.php @@ -1,33 +1,41 @@ '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; } diff --git a/api/v3/examples/CustomValueGet.php b/api/v3/examples/CustomValueGet.php index 80cb01fcc1..4ca42103af 100644 --- a/api/v3/examples/CustomValueGet.php +++ b/api/v3/examples/CustomValueGet.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/DomainCreate.php b/api/v3/examples/DomainCreate.php index 71316d270d..5de8ff77cc 100644 --- a/api/v3/examples/DomainCreate.php +++ b/api/v3/examples/DomainCreate.php @@ -1,23 +1,31 @@ '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; } diff --git a/api/v3/examples/DomainGet.php b/api/v3/examples/DomainGet.php index 8fcfb516db..2456fea48c 100644 --- a/api/v3/examples/DomainGet.php +++ b/api/v3/examples/DomainGet.php @@ -1,20 +1,28 @@ 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" ', @@ -77,7 +85,7 @@ function domain_get_expectedresult(){ ), ); - return $expectedResult ; + return $expectedResult; } diff --git a/api/v3/examples/Email/NestedReplaceEmail.php b/api/v3/examples/Email/NestedReplaceEmail.php index 9a0a46eab3..0e11d25e25 100644 --- a/api/v3/examples/Email/NestedReplaceEmail.php +++ b/api/v3/examples/Email/NestedReplaceEmail.php @@ -1,11 +1,10 @@ 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; } diff --git a/api/v3/examples/EmailCreate.php b/api/v3/examples/EmailCreate.php index dedf7bfc91..cfeb2745da 100644 --- a/api/v3/examples/EmailCreate.php +++ b/api/v3/examples/EmailCreate.php @@ -1,7 +1,7 @@ 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; } diff --git a/api/v3/examples/EmailDelete.php b/api/v3/examples/EmailDelete.php index 40bf993c6e..cd07fdbd4e 100644 --- a/api/v3/examples/EmailDelete.php +++ b/api/v3/examples/EmailDelete.php @@ -1,23 +1,28 @@ 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; } diff --git a/api/v3/examples/EmailReplace.php b/api/v3/examples/EmailReplace.php index f6a6c4cdb8..fac5569782 100644 --- a/api/v3/examples/EmailReplace.php +++ b/api/v3/examples/EmailReplace.php @@ -1,11 +1,10 @@ 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; } diff --git a/api/v3/examples/EntityTagCreate.php b/api/v3/examples/EntityTagCreate.php index 9eda49f51d..13c837eab8 100644 --- a/api/v3/examples/EntityTagCreate.php +++ b/api/v3/examples/EntityTagCreate.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/EntityTagDelete.php b/api/v3/examples/EntityTagDelete.php index 1315022fb3..5abd8fea0d 100644 --- a/api/v3/examples/EntityTagDelete.php +++ b/api/v3/examples/EntityTagDelete.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/EntityTagGet.php b/api/v3/examples/EntityTagGet.php index e69de29bb2..59841bee8d 100644 --- a/api/v3/examples/EntityTagGet.php +++ b/api/v3/examples/EntityTagGet.php @@ -0,0 +1,62 @@ + 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 diff --git a/api/v3/examples/Event/IsCurrentOption.php b/api/v3/examples/Event/IsCurrentOption.php index 1e4acedb90..35e38236b3 100644 --- a/api/v3/examples/Event/IsCurrentOption.php +++ b/api/v3/examples/Event/IsCurrentOption.php @@ -1,21 +1,28 @@ 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; } diff --git a/api/v3/examples/Event/IsFullOption.php b/api/v3/examples/Event/IsFullOption.php index 3cb158cb0a..24d7e2ec6f 100644 --- a/api/v3/examples/Event/IsFullOption.php +++ b/api/v3/examples/Event/IsFullOption.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/EventCreate.php b/api/v3/examples/EventCreate.php index 1c04b164e6..bee390e79c 100644 --- a/api/v3/examples/EventCreate.php +++ b/api/v3/examples/EventCreate.php @@ -1,7 +1,7 @@ 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; } diff --git a/api/v3/examples/EventDelete.php b/api/v3/examples/EventDelete.php index 75d5b0e2b6..e851cd6f32 100644 --- a/api/v3/examples/EventDelete.php +++ b/api/v3/examples/EventDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/EventGet.php b/api/v3/examples/EventGet.php index 7174320716..cd349e32d7 100644 --- a/api/v3/examples/EventGet.php +++ b/api/v3/examples/EventGet.php @@ -1,22 +1,29 @@ '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 index 64b46e3e1e..0000000000 --- a/api/v3/examples/EventUpdate.php +++ /dev/null @@ -1,122 +0,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 diff --git a/api/v3/examples/GrantCreate.php b/api/v3/examples/GrantCreate.php index 5053fe603f..37d928094e 100644 --- a/api/v3/examples/GrantCreate.php +++ b/api/v3/examples/GrantCreate.php @@ -1,11 +1,10 @@ 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; } diff --git a/api/v3/examples/GrantDelete.php b/api/v3/examples/GrantDelete.php index 92b6487a60..d0a7214771 100644 --- a/api/v3/examples/GrantDelete.php +++ b/api/v3/examples/GrantDelete.php @@ -1,27 +1,28 @@ 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; } diff --git a/api/v3/examples/GrantGet.php b/api/v3/examples/GrantGet.php index 9a90bb4f61..65319a465f 100644 --- a/api/v3/examples/GrantGet.php +++ b/api/v3/examples/GrantGet.php @@ -1,27 +1,28 @@ 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; } diff --git a/api/v3/examples/Group/getfields.php b/api/v3/examples/Group/getfields.php index 42375a5015..5a769c9056 100644 --- a/api/v3/examples/Group/getfields.php +++ b/api/v3/examples/Group/getfields.php @@ -1,20 +1,28 @@ 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 index 944e989a4f..0000000000 --- a/api/v3/examples/GroupContact.php +++ /dev/null @@ -1,31 +0,0 @@ - '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; -} - diff --git a/api/v3/examples/GroupContact/GetWithGroupID.php b/api/v3/examples/GroupContact/GetWithGroupID.php index c8e8772afc..f41d8fb6f7 100644 --- a/api/v3/examples/GroupContact/GetWithGroupID.php +++ b/api/v3/examples/GroupContact/GetWithGroupID.php @@ -1,22 +1,30 @@ 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; } diff --git a/api/v3/examples/GroupContactCreate.php b/api/v3/examples/GroupContactCreate.php index 1dc180c0a4..309c0edfcf 100644 --- a/api/v3/examples/GroupContactCreate.php +++ b/api/v3/examples/GroupContactCreate.php @@ -1,22 +1,30 @@ 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; } diff --git a/api/v3/examples/GroupContactDelete.php b/api/v3/examples/GroupContactDelete.php index 87ab9e311f..44efa758da 100644 --- a/api/v3/examples/GroupContactDelete.php +++ b/api/v3/examples/GroupContactDelete.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/GroupContactGet.php b/api/v3/examples/GroupContactGet.php index aabe20108d..d808dc118a 100644 --- a/api/v3/examples/GroupContactGet.php +++ b/api/v3/examples/GroupContactGet.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/GroupGet.php b/api/v3/examples/GroupGet.php index f3506f99ae..ce5e3093d1 100644 --- a/api/v3/examples/GroupGet.php +++ b/api/v3/examples/GroupGet.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/GroupNestingCreate.php b/api/v3/examples/GroupNestingCreate.php index 50634eabd0..d6464fb8df 100644 --- a/api/v3/examples/GroupNestingCreate.php +++ b/api/v3/examples/GroupNestingCreate.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/GroupNestingDelete.php b/api/v3/examples/GroupNestingDelete.php index 6fe5997088..f62acbbe7b 100644 --- a/api/v3/examples/GroupNestingDelete.php +++ b/api/v3/examples/GroupNestingDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/GroupNestingGet.php b/api/v3/examples/GroupNestingGet.php index ccf2b2e113..331b593c06 100644 --- a/api/v3/examples/GroupNestingGet.php +++ b/api/v3/examples/GroupNestingGet.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/GroupOrganizationCreate.php b/api/v3/examples/GroupOrganizationCreate.php index 44f51c73ad..a90fe3f51b 100644 --- a/api/v3/examples/GroupOrganizationCreate.php +++ b/api/v3/examples/GroupOrganizationCreate.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/GroupOrganizationDelete.php b/api/v3/examples/GroupOrganizationDelete.php index ca3656287d..bda6975173 100644 --- a/api/v3/examples/GroupOrganizationDelete.php +++ b/api/v3/examples/GroupOrganizationDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/GroupOrganizationGet.php b/api/v3/examples/GroupOrganizationGet.php index 46bce4da70..aab63bb6f8 100644 --- a/api/v3/examples/GroupOrganizationGet.php +++ b/api/v3/examples/GroupOrganizationGet.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/ImCreate.php b/api/v3/examples/ImCreate.php index db62ed7487..260d0a83a9 100644 --- a/api/v3/examples/ImCreate.php +++ b/api/v3/examples/ImCreate.php @@ -1,23 +1,31 @@ 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; } diff --git a/api/v3/examples/ImDelete.php b/api/v3/examples/ImDelete.php index e9558581df..d74fc3ab49 100644 --- a/api/v3/examples/ImDelete.php +++ b/api/v3/examples/ImDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/ImGet.php b/api/v3/examples/ImGet.php index d8451607bd..eec5230a7c 100644 --- a/api/v3/examples/ImGet.php +++ b/api/v3/examples/ImGet.php @@ -1,23 +1,31 @@ 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; } diff --git a/api/v3/examples/JobCreate.php b/api/v3/examples/JobCreate.php index 7a3eb49161..3ab7c9bbc1 100644 --- a/api/v3/examples/JobCreate.php +++ b/api/v3/examples/JobCreate.php @@ -1,11 +1,10 @@ 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; } diff --git a/api/v3/examples/JobDelete.php b/api/v3/examples/JobDelete.php index 970993faf1..9e548d9805 100644 --- a/api/v3/examples/JobDelete.php +++ b/api/v3/examples/JobDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/LineItemCreate.php b/api/v3/examples/LineItemCreate.php index fd0ce15f35..610970e489 100644 --- a/api/v3/examples/LineItemCreate.php +++ b/api/v3/examples/LineItemCreate.php @@ -1,11 +1,10 @@ 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; } diff --git a/api/v3/examples/LineItemDelete.php b/api/v3/examples/LineItemDelete.php index ded11f5298..4df6f07b5f 100644 --- a/api/v3/examples/LineItemDelete.php +++ b/api/v3/examples/LineItemDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/LineItemGet.php b/api/v3/examples/LineItemGet.php index 3e94135dba..d31b9e8474 100644 --- a/api/v3/examples/LineItemGet.php +++ b/api/v3/examples/LineItemGet.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/LocBlockCreate.php b/api/v3/examples/LocBlockCreate.php index a2716516ee..61ecaaf53c 100644 --- a/api/v3/examples/LocBlockCreate.php +++ b/api/v3/examples/LocBlockCreate.php @@ -1,7 +1,7 @@ 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; } diff --git a/api/v3/examples/LocBlockCreateEntities.php b/api/v3/examples/LocBlockCreateEntities.php index a71bf66096..c205135a92 100644 --- a/api/v3/examples/LocBlockCreateEntities.php +++ b/api/v3/examples/LocBlockCreateEntities.php @@ -1,7 +1,7 @@ 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; } diff --git a/api/v3/examples/LocBlockGet.php b/api/v3/examples/LocBlockGet.php index 86e7d42ab7..870dbe84d5 100644 --- a/api/v3/examples/LocBlockGet.php +++ b/api/v3/examples/LocBlockGet.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/MailSettings/ChainedGetDelete.php b/api/v3/examples/MailSettings/ChainedGetDelete.php index bb6a60a6ce..7c8690d76c 100644 --- a/api/v3/examples/MailSettings/ChainedGetDelete.php +++ b/api/v3/examples/MailSettings/ChainedGetDelete.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/MailSettingsCreate.php b/api/v3/examples/MailSettingsCreate.php index b8f246187f..072e60d2a5 100644 --- a/api/v3/examples/MailSettingsCreate.php +++ b/api/v3/examples/MailSettingsCreate.php @@ -1,7 +1,7 @@ '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; } diff --git a/api/v3/examples/MailSettingsDelete.php b/api/v3/examples/MailSettingsDelete.php index bcd66dfcb7..b062459b55 100644 --- a/api/v3/examples/MailSettingsDelete.php +++ b/api/v3/examples/MailSettingsDelete.php @@ -1,26 +1,28 @@ 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; } diff --git a/api/v3/examples/MailSettingsGet.php b/api/v3/examples/MailSettingsGet.php index c5090886c5..69959acc52 100644 --- a/api/v3/examples/MailSettingsGet.php +++ b/api/v3/examples/MailSettingsGet.php @@ -1,7 +1,7 @@ '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; } diff --git a/api/v3/examples/MailingCreate.php b/api/v3/examples/MailingCreate.php index 8ef2f999f9..7fab57269c 100644 --- a/api/v3/examples/MailingCreate.php +++ b/api/v3/examples/MailingCreate.php @@ -1,23 +1,31 @@ '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; } diff --git a/api/v3/examples/ActivityTypeDelete.php b/api/v3/examples/MailingDelete.php similarity index 55% rename from api/v3/examples/ActivityTypeDelete.php rename to api/v3/examples/MailingDelete.php index b087ac58e7..17282a221b 100644 --- a/api/v3/examples/ActivityTypeDelete.php +++ b/api/v3/examples/MailingDelete.php @@ -1,38 +1,48 @@ 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 diff --git a/api/v3/examples/MailingGroupSubscribe.php b/api/v3/examples/MailingGroupSubscribe.php index 6ed2b2c18a..99821a9f64 100644 --- a/api/v3/examples/MailingGroupSubscribe.php +++ b/api/v3/examples/MailingGroupSubscribe.php @@ -1,24 +1,32 @@ '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; } diff --git a/api/v3/examples/Membership/filterIsCurrent.php b/api/v3/examples/Membership/filterIsCurrent.php index db786971a9..2bf364e3ab 100644 --- a/api/v3/examples/Membership/filterIsCurrent.php +++ b/api/v3/examples/Membership/filterIsCurrent.php @@ -1,7 +1,7 @@ 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; } diff --git a/api/v3/examples/MembershipCreate.php b/api/v3/examples/MembershipCreate.php index 82fbdfe3f9..47ec1be3ba 100644 --- a/api/v3/examples/MembershipCreate.php +++ b/api/v3/examples/MembershipCreate.php @@ -1,28 +1,36 @@ 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; } diff --git a/api/v3/examples/MembershipDelete.php b/api/v3/examples/MembershipDelete.php index 610dbcdc65..cd2426bcb8 100644 --- a/api/v3/examples/MembershipDelete.php +++ b/api/v3/examples/MembershipDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/MembershipGet.php b/api/v3/examples/MembershipGet.php index 2a02a7cf35..fe5bcf0904 100644 --- a/api/v3/examples/MembershipGet.php +++ b/api/v3/examples/MembershipGet.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/MembershipPaymentCreate.php b/api/v3/examples/MembershipPaymentCreate.php index 73e675b554..d58e0e1346 100644 --- a/api/v3/examples/MembershipPaymentCreate.php +++ b/api/v3/examples/MembershipPaymentCreate.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/MembershipPaymentGet.php b/api/v3/examples/MembershipPaymentGet.php index 42e5b15a49..c1bc97bc87 100644 --- a/api/v3/examples/MembershipPaymentGet.php +++ b/api/v3/examples/MembershipPaymentGet.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/MembershipStatusCreate.php b/api/v3/examples/MembershipStatusCreate.php index 970706cb3b..fd17f85497 100644 --- a/api/v3/examples/MembershipStatusCreate.php +++ b/api/v3/examples/MembershipStatusCreate.php @@ -1,20 +1,28 @@ '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; } diff --git a/api/v3/examples/MembershipStatusGet.php b/api/v3/examples/MembershipStatusGet.php index 7e21356c0d..3de04001fe 100644 --- a/api/v3/examples/MembershipStatusGet.php +++ b/api/v3/examples/MembershipStatusGet.php @@ -1,20 +1,28 @@ '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; } diff --git a/api/v3/examples/MembershipTypeCreate.php b/api/v3/examples/MembershipTypeCreate.php index a48de6940f..3eca2da079 100644 --- a/api/v3/examples/MembershipTypeCreate.php +++ b/api/v3/examples/MembershipTypeCreate.php @@ -1,7 +1,7 @@ '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; } diff --git a/api/v3/examples/MembershipTypeDelete.php b/api/v3/examples/MembershipTypeDelete.php index 584d6d7892..8baab176e2 100644 --- a/api/v3/examples/MembershipTypeDelete.php +++ b/api/v3/examples/MembershipTypeDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/MembershipTypeGet.php b/api/v3/examples/MembershipTypeGet.php index 482b6d59d3..8bcb08be2a 100644 --- a/api/v3/examples/MembershipTypeGet.php +++ b/api/v3/examples/MembershipTypeGet.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/MembershipUpdate.php b/api/v3/examples/MembershipUpdate.php index b0b17bcbf9..53ecc5e652 100644 --- a/api/v3/examples/MembershipUpdate.php +++ b/api/v3/examples/MembershipUpdate.php @@ -1,28 +1,36 @@ 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; } diff --git a/api/v3/examples/NoteCreate.php b/api/v3/examples/NoteCreate.php index 43a4a16454..469f408736 100644 --- a/api/v3/examples/NoteCreate.php +++ b/api/v3/examples/NoteCreate.php @@ -1,7 +1,7 @@ 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; } diff --git a/api/v3/examples/NoteDelete.php b/api/v3/examples/NoteDelete.php index 07d637bfdc..e8933772c0 100644 --- a/api/v3/examples/NoteDelete.php +++ b/api/v3/examples/NoteDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/NoteGet.php b/api/v3/examples/NoteGet.php index 51fca52077..ebd17d2fe4 100644 --- a/api/v3/examples/NoteGet.php +++ b/api/v3/examples/NoteGet.php @@ -1,25 +1,29 @@ '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; } diff --git a/api/v3/examples/OptionGroupCreate.php b/api/v3/examples/OptionGroupCreate.php index 716e59c914..32097c1682 100644 --- a/api/v3/examples/OptionGroupCreate.php +++ b/api/v3/examples/OptionGroupCreate.php @@ -1,11 +1,10 @@ 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; } diff --git a/api/v3/examples/OptionGroupDelete.php b/api/v3/examples/OptionGroupDelete.php index 2c2d23f228..5a40f3e5ab 100644 --- a/api/v3/examples/OptionGroupDelete.php +++ b/api/v3/examples/OptionGroupDelete.php @@ -1,21 +1,28 @@ 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; } diff --git a/api/v3/examples/OptionGroupGet.php b/api/v3/examples/OptionGroupGet.php index d0e10240f3..735b639689 100644 --- a/api/v3/examples/OptionGroupGet.php +++ b/api/v3/examples/OptionGroupGet.php @@ -1,21 +1,28 @@ '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; } diff --git a/api/v3/examples/OptionValue/SortOption.php b/api/v3/examples/OptionValue/SortOption.php index 6003443243..367e3ce6b0 100644 --- a/api/v3/examples/OptionValue/SortOption.php +++ b/api/v3/examples/OptionValue/SortOption.php @@ -1,24 +1,32 @@ 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; } diff --git a/api/v3/examples/OptionValueGet.php b/api/v3/examples/OptionValueGet.php index dbce441a53..9e02dc309f 100644 --- a/api/v3/examples/OptionValueGet.php +++ b/api/v3/examples/OptionValueGet.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/Participant/CreateParticipantPayment.php b/api/v3/examples/Participant/CreateParticipantPayment.php index 4c9df79844..64b9ea3f95 100644 --- a/api/v3/examples/Participant/CreateParticipantPayment.php +++ b/api/v3/examples/Participant/CreateParticipantPayment.php @@ -1,16 +1,15 @@ '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; } diff --git a/api/v3/examples/Participant/NestedDelete.php b/api/v3/examples/Participant/NestedDelete.php index d786d42fe2..a2a9bc18f3 100644 --- a/api/v3/examples/Participant/NestedDelete.php +++ b/api/v3/examples/Participant/NestedDelete.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/Participant/NestedEventGet.php b/api/v3/examples/Participant/NestedEventGet.php index aeb472a37b..d4b3cf5cfe 100644 --- a/api/v3/examples/Participant/NestedEventGet.php +++ b/api/v3/examples/Participant/NestedEventGet.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/ParticipantCreate.php b/api/v3/examples/ParticipantCreate.php index 5506ab3fea..735322b0c9 100644 --- a/api/v3/examples/ParticipantCreate.php +++ b/api/v3/examples/ParticipantCreate.php @@ -1,7 +1,7 @@ 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; } diff --git a/api/v3/examples/ParticipantGet.php b/api/v3/examples/ParticipantGet.php index 79bf437500..9e4e31a827 100644 --- a/api/v3/examples/ParticipantGet.php +++ b/api/v3/examples/ParticipantGet.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/ParticipantPaymentCreate.php b/api/v3/examples/ParticipantPaymentCreate.php index f6be119603..3e1b68ed03 100644 --- a/api/v3/examples/ParticipantPaymentCreate.php +++ b/api/v3/examples/ParticipantPaymentCreate.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/ParticipantPaymentDelete.php b/api/v3/examples/ParticipantPaymentDelete.php index dbe3135873..b0a938ff2c 100644 --- a/api/v3/examples/ParticipantPaymentDelete.php +++ b/api/v3/examples/ParticipantPaymentDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/ParticipantPaymentGet.php b/api/v3/examples/ParticipantPaymentGet.php index 455d1470d1..4f2d73a8ee 100644 --- a/api/v3/examples/ParticipantPaymentGet.php +++ b/api/v3/examples/ParticipantPaymentGet.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/ParticipantStatusTypeCreate.php b/api/v3/examples/ParticipantStatusTypeCreate.php index 086accb61b..8ddd44e15d 100644 --- a/api/v3/examples/ParticipantStatusTypeCreate.php +++ b/api/v3/examples/ParticipantStatusTypeCreate.php @@ -1,11 +1,10 @@ 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; } diff --git a/api/v3/examples/ParticipantStatusTypeDelete.php b/api/v3/examples/ParticipantStatusTypeDelete.php index 21c69628e3..7f40197884 100644 --- a/api/v3/examples/ParticipantStatusTypeDelete.php +++ b/api/v3/examples/ParticipantStatusTypeDelete.php @@ -1,27 +1,28 @@ 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; } diff --git a/api/v3/examples/ParticipantStatusTypeGet.php b/api/v3/examples/ParticipantStatusTypeGet.php index 4272c2b032..1b170f6adf 100644 --- a/api/v3/examples/ParticipantStatusTypeGet.php +++ b/api/v3/examples/ParticipantStatusTypeGet.php @@ -1,11 +1,10 @@ 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; } diff --git a/api/v3/examples/PaymentProcessorCreate.php b/api/v3/examples/PaymentProcessorCreate.php index 0a14438360..3553356190 100644 --- a/api/v3/examples/PaymentProcessorCreate.php +++ b/api/v3/examples/PaymentProcessorCreate.php @@ -1,11 +1,10 @@ 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; } diff --git a/api/v3/examples/PaymentProcessorDelete.php b/api/v3/examples/PaymentProcessorDelete.php index 5ab82e1a70..392986fa5b 100644 --- a/api/v3/examples/PaymentProcessorDelete.php +++ b/api/v3/examples/PaymentProcessorDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/PaymentProcessorTypeCreate.php b/api/v3/examples/PaymentProcessorTypeCreate.php index 37d49d6c0b..3159cd3a41 100644 --- a/api/v3/examples/PaymentProcessorTypeCreate.php +++ b/api/v3/examples/PaymentProcessorTypeCreate.php @@ -1,11 +1,10 @@ 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; } diff --git a/api/v3/examples/PaymentProcessorTypeDelete.php b/api/v3/examples/PaymentProcessorTypeDelete.php index 3deaf5ce54..2d8b47f8d3 100644 --- a/api/v3/examples/PaymentProcessorTypeDelete.php +++ b/api/v3/examples/PaymentProcessorTypeDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/PhoneCreate.php b/api/v3/examples/PhoneCreate.php index c6c79295f3..7a2b6c8604 100644 --- a/api/v3/examples/PhoneCreate.php +++ b/api/v3/examples/PhoneCreate.php @@ -1,7 +1,7 @@ 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; } diff --git a/api/v3/examples/PhoneDelete.php b/api/v3/examples/PhoneDelete.php index c2df8d4289..d5dc2f2d9b 100644 --- a/api/v3/examples/PhoneDelete.php +++ b/api/v3/examples/PhoneDelete.php @@ -1,24 +1,28 @@ 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; } diff --git a/api/v3/examples/PhoneGet.php b/api/v3/examples/PhoneGet.php index b8f6c15b0b..a590a57046 100644 --- a/api/v3/examples/PhoneGet.php +++ b/api/v3/examples/PhoneGet.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/Pledge/GetFilterHighDate.php b/api/v3/examples/Pledge/GetFilterHighDate.php index df3d7f8b4a..7ab91d0fc5 100644 --- a/api/v3/examples/Pledge/GetFilterHighDate.php +++ b/api/v3/examples/Pledge/GetFilterHighDate.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/PledgeCreate.php b/api/v3/examples/PledgeCreate.php index b90a03fb5f..70b6ad5317 100644 --- a/api/v3/examples/PledgeCreate.php +++ b/api/v3/examples/PledgeCreate.php @@ -1,14 +1,14 @@ 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; } diff --git a/api/v3/examples/PledgeDelete.php b/api/v3/examples/PledgeDelete.php index 56ef1f5803..d83fa0e8bd 100644 --- a/api/v3/examples/PledgeDelete.php +++ b/api/v3/examples/PledgeDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/PledgeGet.php b/api/v3/examples/PledgeGet.php index 4d532c777e..c50cb5bba8 100644 --- a/api/v3/examples/PledgeGet.php +++ b/api/v3/examples/PledgeGet.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/PledgePaymentCreate.php b/api/v3/examples/PledgePaymentCreate.php index 063c697262..d7b10206c8 100644 --- a/api/v3/examples/PledgePaymentCreate.php +++ b/api/v3/examples/PledgePaymentCreate.php @@ -1,24 +1,32 @@ 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; } diff --git a/api/v3/examples/PledgePaymentDelete.php b/api/v3/examples/PledgePaymentDelete.php index 6fef9b82d0..2ef5a94adb 100644 --- a/api/v3/examples/PledgePaymentDelete.php +++ b/api/v3/examples/PledgePaymentDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/PledgePaymentGet.php b/api/v3/examples/PledgePaymentGet.php index 77ffe9fbbb..44d4c0ac62 100644 --- a/api/v3/examples/PledgePaymentGet.php +++ b/api/v3/examples/PledgePaymentGet.php @@ -1,19 +1,26 @@ 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; } diff --git a/api/v3/examples/PledgePaymentUpdate.php b/api/v3/examples/PledgePaymentUpdate.php index 8897f4e78d..8905465e25 100644 --- a/api/v3/examples/PledgePaymentUpdate.php +++ b/api/v3/examples/PledgePaymentUpdate.php @@ -1,23 +1,29 @@ 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; } diff --git a/api/v3/examples/PriceFieldCreate.php b/api/v3/examples/PriceFieldCreate.php index 16dac7adcb..1af45a971a 100644 --- a/api/v3/examples/PriceFieldCreate.php +++ b/api/v3/examples/PriceFieldCreate.php @@ -1,11 +1,10 @@ 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; } diff --git a/api/v3/examples/PriceFieldDelete.php b/api/v3/examples/PriceFieldDelete.php index 58c1bc24d9..bfcdba8ef5 100644 --- a/api/v3/examples/PriceFieldDelete.php +++ b/api/v3/examples/PriceFieldDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/PriceFieldGet.php b/api/v3/examples/PriceFieldGet.php index 12a97c7eb6..88d364e84b 100644 --- a/api/v3/examples/PriceFieldGet.php +++ b/api/v3/examples/PriceFieldGet.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/PriceFieldValueCreate.php b/api/v3/examples/PriceFieldValueCreate.php index 21e6cb2821..ba01b11d00 100644 --- a/api/v3/examples/PriceFieldValueCreate.php +++ b/api/v3/examples/PriceFieldValueCreate.php @@ -1,11 +1,10 @@ 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; } diff --git a/api/v3/examples/PriceFieldValueDelete.php b/api/v3/examples/PriceFieldValueDelete.php index 6d0fc244cb..434665edb1 100644 --- a/api/v3/examples/PriceFieldValueDelete.php +++ b/api/v3/examples/PriceFieldValueDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/PriceFieldValueGet.php b/api/v3/examples/PriceFieldValueGet.php index 8b21d15266..c24d21c681 100644 --- a/api/v3/examples/PriceFieldValueGet.php +++ b/api/v3/examples/PriceFieldValueGet.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/PriceSetCreate.php b/api/v3/examples/PriceSetCreate.php index c041e0b8cc..76fae688e5 100644 --- a/api/v3/examples/PriceSetCreate.php +++ b/api/v3/examples/PriceSetCreate.php @@ -1,11 +1,10 @@ 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; } diff --git a/api/v3/examples/PriceSetDelete.php b/api/v3/examples/PriceSetDelete.php index aec0a29b07..bd84ef81e3 100644 --- a/api/v3/examples/PriceSetDelete.php +++ b/api/v3/examples/PriceSetDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/PriceSetGet.php b/api/v3/examples/PriceSetGet.php index dcfc788986..8e9f32090f 100644 --- a/api/v3/examples/PriceSetGet.php +++ b/api/v3/examples/PriceSetGet.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/PriceSetSet.php b/api/v3/examples/PriceSetSet.php index 694bdb89c9..3ee493991a 100644 --- a/api/v3/examples/PriceSetSet.php +++ b/api/v3/examples/PriceSetSet.php @@ -1,11 +1,10 @@ 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; } diff --git a/api/v3/examples/ProfileApply.php b/api/v3/examples/ProfileApply.php index 0363c2a3ca..768386e948 100644 --- a/api/v3/examples/ProfileApply.php +++ b/api/v3/examples/ProfileApply.php @@ -1,13 +1,12 @@ 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; } diff --git a/api/v3/examples/ProfileGet.php b/api/v3/examples/ProfileGet.php index 6699c3310f..c639ae6ea2 100644 --- a/api/v3/examples/ProfileGet.php +++ b/api/v3/examples/ProfileGet.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/ProfileSet.php b/api/v3/examples/ProfileSet.php index cb67f48975..2e4426892a 100644 --- a/api/v3/examples/ProfileSet.php +++ b/api/v3/examples/ProfileSet.php @@ -1,13 +1,12 @@ 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; } diff --git a/api/v3/examples/Relationship/BetweenRelationshipType.php b/api/v3/examples/Relationship/BetweenRelationshipType.php index 5cd8d920c1..e3191c4aee 100644 --- a/api/v3/examples/Relationship/BetweenRelationshipType.php +++ b/api/v3/examples/Relationship/BetweenRelationshipType.php @@ -1,26 +1,33 @@ 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; } diff --git a/api/v3/examples/Relationship/INRelationshipType.php b/api/v3/examples/Relationship/INRelationshipType.php index 8014f90a1e..8d03eb93d5 100644 --- a/api/v3/examples/Relationship/INRelationshipType.php +++ b/api/v3/examples/Relationship/INRelationshipType.php @@ -1,26 +1,33 @@ 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; } diff --git a/api/v3/examples/Relationship/NotBetweenRelationshipType.php b/api/v3/examples/Relationship/NotBetweenRelationshipType.php index d81e512007..03a843963c 100644 --- a/api/v3/examples/Relationship/NotBetweenRelationshipType.php +++ b/api/v3/examples/Relationship/NotBetweenRelationshipType.php @@ -1,26 +1,33 @@ 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; } diff --git a/api/v3/examples/Relationship/NotInRelationshipType.php b/api/v3/examples/Relationship/NotInRelationshipType.php index 531f30fa08..fa3bc4ee0b 100644 --- a/api/v3/examples/Relationship/NotInRelationshipType.php +++ b/api/v3/examples/Relationship/NotInRelationshipType.php @@ -1,26 +1,33 @@ 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; } diff --git a/api/v3/examples/Relationship/filterIsCurrent.php b/api/v3/examples/Relationship/filterIsCurrent.php index 9e441ac4eb..14eae6c90b 100644 --- a/api/v3/examples/Relationship/filterIsCurrent.php +++ b/api/v3/examples/Relationship/filterIsCurrent.php @@ -1,23 +1,30 @@ 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; } diff --git a/api/v3/examples/RelationshipCreate.php b/api/v3/examples/RelationshipCreate.php index 5181ba72e5..56ec1672f3 100644 --- a/api/v3/examples/RelationshipCreate.php +++ b/api/v3/examples/RelationshipCreate.php @@ -1,27 +1,34 @@ 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; } diff --git a/api/v3/examples/RelationshipDelete.php b/api/v3/examples/RelationshipDelete.php index 06187c027b..daa948f180 100644 --- a/api/v3/examples/RelationshipDelete.php +++ b/api/v3/examples/RelationshipDelete.php @@ -1,21 +1,28 @@ 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; } diff --git a/api/v3/examples/RelationshipGet.php b/api/v3/examples/RelationshipGet.php index b47bd7f526..70c830844b 100644 --- a/api/v3/examples/RelationshipGet.php +++ b/api/v3/examples/RelationshipGet.php @@ -1,21 +1,28 @@ 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; } diff --git a/api/v3/examples/RelationshipTypeCreate.php b/api/v3/examples/RelationshipTypeCreate.php index 4f3135605c..46ffddb422 100644 --- a/api/v3/examples/RelationshipTypeCreate.php +++ b/api/v3/examples/RelationshipTypeCreate.php @@ -1,7 +1,7 @@ '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; } diff --git a/api/v3/examples/RelationshipTypeDelete.php b/api/v3/examples/RelationshipTypeDelete.php index 522cff97be..0d68292bf8 100644 --- a/api/v3/examples/RelationshipTypeDelete.php +++ b/api/v3/examples/RelationshipTypeDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/Setting/CreateAllDomains.php b/api/v3/examples/Setting/CreateAllDomains.php index 78351d2ded..fb82eb3c7f 100644 --- a/api/v3/examples/Setting/CreateAllDomains.php +++ b/api/v3/examples/Setting/CreateAllDomains.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/Setting/CreateSettingCurrentDomain.php b/api/v3/examples/Setting/CreateSettingCurrentDomain.php index d41cd0383c..78d29eeb58 100644 --- a/api/v3/examples/Setting/CreateSettingCurrentDomain.php +++ b/api/v3/examples/Setting/CreateSettingCurrentDomain.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/Setting/CreateSpecifiedDomains.php b/api/v3/examples/Setting/CreateSpecifiedDomains.php index df11acabfb..4cc8712470 100644 --- a/api/v3/examples/Setting/CreateSpecifiedDomains.php +++ b/api/v3/examples/Setting/CreateSpecifiedDomains.php @@ -1,11 +1,10 @@ 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; } diff --git a/api/v3/examples/Setting/GetAllDomains.php b/api/v3/examples/Setting/GetAllDomains.php index bf363cc43c..32af9a1a66 100644 --- a/api/v3/examples/Setting/GetAllDomains.php +++ b/api/v3/examples/Setting/GetAllDomains.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/Setting/GetDefaults.php b/api/v3/examples/Setting/GetDefaults.php index 4b5efa7526..5084c159ce 100644 --- a/api/v3/examples/Setting/GetDefaults.php +++ b/api/v3/examples/Setting/GetDefaults.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/Setting/GetSettingCurrentDomain.php b/api/v3/examples/Setting/GetSettingCurrentDomain.php index d619b4ad02..b5b43f9741 100644 --- a/api/v3/examples/Setting/GetSettingCurrentDomain.php +++ b/api/v3/examples/Setting/GetSettingCurrentDomain.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/Setting/GetSpecifiedDomains.php b/api/v3/examples/Setting/GetSpecifiedDomains.php index 9389205ee0..f839e0934c 100644 --- a/api/v3/examples/Setting/GetSpecifiedDomains.php +++ b/api/v3/examples/Setting/GetSpecifiedDomains.php @@ -1,11 +1,10 @@ 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; } diff --git a/api/v3/examples/SettingCreate.php b/api/v3/examples/SettingCreate.php index 1aa00f62c5..1463355532 100644 --- a/api/v3/examples/SettingCreate.php +++ b/api/v3/examples/SettingCreate.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/SettingGet.php b/api/v3/examples/SettingGet.php index ec76f9a9a7..714ae6d338 100644 --- a/api/v3/examples/SettingGet.php +++ b/api/v3/examples/SettingGet.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/SettingGetValue.php b/api/v3/examples/SettingGetValue.php index 8afd44908d..c48517dd99 100644 --- a/api/v3/examples/SettingGetValue.php +++ b/api/v3/examples/SettingGetValue.php @@ -1,28 +1,36 @@ 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; } diff --git a/api/v3/examples/SettingGetfields.php b/api/v3/examples/SettingGetfields.php index 147b2e546e..0fc2752ad6 100644 --- a/api/v3/examples/SettingGetfields.php +++ b/api/v3/examples/SettingGetfields.php @@ -1,19 +1,26 @@ 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; } diff --git a/api/v3/examples/SettingRevert.php b/api/v3/examples/SettingRevert.php index 509c0ca111..ffacc49fd4 100644 --- a/api/v3/examples/SettingRevert.php +++ b/api/v3/examples/SettingRevert.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/Survey/ChainedGetDelete.php b/api/v3/examples/Survey/ChainedGetDelete.php index 28e453667f..d2db10179a 100644 --- a/api/v3/examples/Survey/ChainedGetDelete.php +++ b/api/v3/examples/Survey/ChainedGetDelete.php @@ -1,22 +1,29 @@ '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; } diff --git a/api/v3/examples/SurveyCreate.php b/api/v3/examples/SurveyCreate.php index 39f6d61138..763f377116 100644 --- a/api/v3/examples/SurveyCreate.php +++ b/api/v3/examples/SurveyCreate.php @@ -1,7 +1,7 @@ '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; } diff --git a/api/v3/examples/SurveyDelete.php b/api/v3/examples/SurveyDelete.php index 04ace82588..74a36e4893 100644 --- a/api/v3/examples/SurveyDelete.php +++ b/api/v3/examples/SurveyDelete.php @@ -1,21 +1,28 @@ 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; } diff --git a/api/v3/examples/SurveyGet.php b/api/v3/examples/SurveyGet.php index af565277af..322815ef92 100644 --- a/api/v3/examples/SurveyGet.php +++ b/api/v3/examples/SurveyGet.php @@ -1,7 +1,7 @@ '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; } diff --git a/api/v3/examples/SurveyRespondantGet.php b/api/v3/examples/SurveyRespondantGet.php index c77a550999..202ada504c 100644 --- a/api/v3/examples/SurveyRespondantGet.php +++ b/api/v3/examples/SurveyRespondantGet.php @@ -1,21 +1,29 @@ 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; } diff --git a/api/v3/examples/System/Flush.php b/api/v3/examples/System/Flush.php index e57a8e0c3f..497e84c14c 100644 --- a/api/v3/examples/System/Flush.php +++ b/api/v3/examples/System/Flush.php @@ -1,19 +1,26 @@ 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; } diff --git a/api/v3/examples/Tag/getReturnArray.php b/api/v3/examples/Tag/getReturnArray.php index 20632a7876..7d115c00df 100644 --- a/api/v3/examples/Tag/getReturnArray.php +++ b/api/v3/examples/Tag/getReturnArray.php @@ -1,24 +1,32 @@ 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; } diff --git a/api/v3/examples/TagCreate.php b/api/v3/examples/TagCreate.php index 682b6aecb3..be58d0e7a2 100644 --- a/api/v3/examples/TagCreate.php +++ b/api/v3/examples/TagCreate.php @@ -1,21 +1,29 @@ '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; } diff --git a/api/v3/examples/TagDelete.php b/api/v3/examples/TagDelete.php index 428a72757c..5bc3483337 100644 --- a/api/v3/examples/TagDelete.php +++ b/api/v3/examples/TagDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/TagGet.php b/api/v3/examples/TagGet.php index 2b9bcd4db6..76d9f9167b 100644 --- a/api/v3/examples/TagGet.php +++ b/api/v3/examples/TagGet.php @@ -1,21 +1,29 @@ 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 index 0000000000..a1bb2bab47 --- /dev/null +++ b/api/v3/examples/TagGetfields.php @@ -0,0 +1,123 @@ + '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 diff --git a/api/v3/examples/UFFieldCreate.php b/api/v3/examples/UFFieldCreate.php index 1b374826d1..1c7350982d 100644 --- a/api/v3/examples/UFFieldCreate.php +++ b/api/v3/examples/UFFieldCreate.php @@ -1,7 +1,7 @@ 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; } diff --git a/api/v3/examples/UFFieldDelete.php b/api/v3/examples/UFFieldDelete.php index 134cdf34a9..0c639a7bc8 100644 --- a/api/v3/examples/UFFieldDelete.php +++ b/api/v3/examples/UFFieldDelete.php @@ -1,21 +1,28 @@ 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; } diff --git a/api/v3/examples/UFFieldGet.php b/api/v3/examples/UFFieldGet.php index 87704345eb..1d9382cdd4 100644 --- a/api/v3/examples/UFFieldGet.php +++ b/api/v3/examples/UFFieldGet.php @@ -1,20 +1,26 @@ 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; } diff --git a/api/v3/examples/UFFieldReplace.php b/api/v3/examples/UFFieldReplace.php index f71855a22c..4c31a0e387 100644 --- a/api/v3/examples/UFFieldReplace.php +++ b/api/v3/examples/UFFieldReplace.php @@ -1,11 +1,10 @@ 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; } diff --git a/api/v3/examples/UFGroupCreate.php b/api/v3/examples/UFGroupCreate.php index 9f075c7eeb..866e7be469 100644 --- a/api/v3/examples/UFGroupCreate.php +++ b/api/v3/examples/UFGroupCreate.php @@ -1,7 +1,7 @@ '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; } diff --git a/api/v3/examples/UFGroupDelete.php b/api/v3/examples/UFGroupDelete.php index aeeeb6d316..4b190d4faf 100644 --- a/api/v3/examples/UFGroupDelete.php +++ b/api/v3/examples/UFGroupDelete.php @@ -1,7 +1,7 @@ '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; } diff --git a/api/v3/examples/UFGroupGet.php b/api/v3/examples/UFGroupGet.php index 39a3586ab7..64c5ac1ab6 100644 --- a/api/v3/examples/UFGroupGet.php +++ b/api/v3/examples/UFGroupGet.php @@ -1,7 +1,7 @@ '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; } diff --git a/api/v3/examples/UFJoinCreate.php b/api/v3/examples/UFJoinCreate.php index a22f0b1249..6ac8c89213 100644 --- a/api/v3/examples/UFJoinCreate.php +++ b/api/v3/examples/UFJoinCreate.php @@ -1,7 +1,7 @@ 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; } diff --git a/api/v3/examples/UFJoinGet.php b/api/v3/examples/UFJoinGet.php index b3427fa54e..e8e7351595 100644 --- a/api/v3/examples/UFJoinGet.php +++ b/api/v3/examples/UFJoinGet.php @@ -1,22 +1,30 @@ '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; } diff --git a/api/v3/examples/UFMatchGet.php b/api/v3/examples/UFMatchGet.php index 852b15c6c7..2e664f4be6 100644 --- a/api/v3/examples/UFMatchGet.php +++ b/api/v3/examples/UFMatchGet.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/WebsiteCreate.php b/api/v3/examples/WebsiteCreate.php index 8468367a0b..06aa440fc7 100644 --- a/api/v3/examples/WebsiteCreate.php +++ b/api/v3/examples/WebsiteCreate.php @@ -1,22 +1,30 @@ 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; } diff --git a/api/v3/examples/WebsiteDelete.php b/api/v3/examples/WebsiteDelete.php index e7ace8c42c..254b6a233d 100644 --- a/api/v3/examples/WebsiteDelete.php +++ b/api/v3/examples/WebsiteDelete.php @@ -1,20 +1,28 @@ 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; } diff --git a/api/v3/examples/WebsiteGet.php b/api/v3/examples/WebsiteGet.php index 47c81b08ae..914c0c67a1 100644 --- a/api/v3/examples/WebsiteGet.php +++ b/api/v3/examples/WebsiteGet.php @@ -1,22 +1,30 @@ 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; } diff --git a/api/v3/utils.php b/api/v3/utils.php index d25d43750a..a9f0762464 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -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'); } /** diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index e37c76dc21..e3ecb795f9 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -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('/(? '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) { diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index 37779fba56..7559e76f85 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -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__); diff --git a/tests/phpunit/api/v3/CustomFieldTest.php b/tests/phpunit/api/v3/CustomFieldTest.php index d6d3e7ef1f..7ea7951b61 100644 --- a/tests/phpunit/api/v3/CustomFieldTest.php +++ b/tests/phpunit/api/v3/CustomFieldTest.php @@ -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); diff --git a/tests/phpunit/api/v3/CustomValueTest.php b/tests/phpunit/api/v3/CustomValueTest.php index 1b0c86aa4b..530f965490 100644 --- a/tests/phpunit/api/v3/CustomValueTest.php +++ b/tests/phpunit/api/v3/CustomValueTest.php @@ -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( diff --git a/tests/phpunit/api/v3/EntityTagTest.php b/tests/phpunit/api/v3/EntityTagTest.php index 253e9e9b4e..a559cac704 100644 --- a/tests/phpunit/api/v3/EntityTagTest.php +++ b/tests/phpunit/api/v3/EntityTagTest.php @@ -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( diff --git a/tests/phpunit/api/v3/EventTest.php b/tests/phpunit/api/v3/EventTest.php index 0c1819b2e6..c97a56e82b 100644 --- a/tests/phpunit/api/v3/EventTest.php +++ b/tests/phpunit/api/v3/EventTest.php @@ -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'])); diff --git a/tests/phpunit/api/v3/TagTest.php b/tests/phpunit/api/v3/TagTest.php index 3d78b53217..152d742404 100644 --- a/tests/phpunit/api/v3/TagTest.php +++ b/tests/phpunit/api/v3/TagTest.php @@ -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() { diff --git a/tests/templates/documentFunction.tpl b/tests/templates/documentFunction.tpl index 4681d7ecfb..a13d722fa9 100644 --- a/tests/templates/documentFunction.tpl +++ b/tests/templates/documentFunction.tpl @@ -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 +*/ -- 2.25.1