Ian province abbreviation patch - issue 724
[civicrm-core.git] / api / v3 / examples / MessageTemplate / Get.php
index 95e57c6be57e0ef91ba48adbd227f9b935d65caf..af55e83b253e33992d69f1e9bd429ad6e8452996 100644 (file)
@@ -1,67 +1,76 @@
 <?php
 /**
- * Test Generated example of using message_template get API
- * *
+ * Test Generated example demonstrating the MessageTemplate.get API.
+ *
+ * @return array
+ *   API result array
  */
-function message_template_get_example(){
-$params = array(
-  'msg_title' => 'msg_title_2',
-  'msg_subject' => 'msg_subject_2',
-  'msg_text' => 'msg_text_2',
-  'msg_html' => 'msg_html_2',
-  'workflow_id' => 2,
-  'is_default' => '1',
-  'is_reserved' => 1,
-);
+function message_template_get_example() {
+  $params = array(
+    'msg_title' => 'msg_title_166',
+    'msg_subject' => 'msg_subject_166',
+    'msg_text' => 'msg_text_166',
+    'msg_html' => 'msg_html_166',
+    'workflow_id' => 166,
+    'is_default' => '1',
+    'is_reserved' => 1,
+  );
 
-try{
-  $result = civicrm_api3('message_template', '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);
-}
+  try{
+    $result = civicrm_api3('MessageTemplate', '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 returns array of result expected from previous function.
+ *
+ * @return array
+ *   API result array
  */
-function message_template_get_expectedresult(){
+function message_template_get_expectedresult() {
 
   $expectedResult = array(
-  'is_error' => 0,
-  'version' => 3,
-  'count' => 1,
-  'id' => 1,
-  'values' => array(
-      '1' => array(
-          'id' => '1',
-          'msg_title' => 'msg_title_2',
-          'msg_subject' => 'msg_subject_2',
-          'msg_text' => 'msg_text_2',
-          'msg_html' => 'msg_html_2',
-          'is_active' => '1',
-          'workflow_id' => '2',
-          'is_default' => '1',
-          'is_reserved' => '1',
-          'pdf_format_id' => '1',
-        ),
+    'is_error' => 0,
+    'version' => 3,
+    'count' => 1,
+    'id' => 68,
+    'values' => array(
+      '68' => array(
+        'id' => '68',
+        'msg_title' => 'msg_title_166',
+        'msg_subject' => 'msg_subject_166',
+        'msg_text' => 'msg_text_166',
+        'msg_html' => 'msg_html_166',
+        'is_active' => '1',
+        'workflow_id' => '166',
+        'is_default' => '1',
+        'is_reserved' => '1',
+        'is_sms' => '1',
+        'pdf_format_id' => '166',
+      ),
     ),
-);
+  );
 
   return $expectedResult;
 }
 
-
 /*
-* This example has been generated from the API test suite. The test that created it is called
-*
-* testGet and can be found in
+* This example has been generated from the API test suite.
+* The test that created it is called "testGet"
+* and can be found at:
 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MessageTemplateTest.php
 *
 * You can see the outcome of the API tests at
@@ -71,7 +80,7 @@ function message_template_get_expectedresult(){
 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
 *
 * Browse the api on your own site with the api explorer
-* http://MYSITE.ORG/path/to/civicrm/api/explorer
+* http://MYSITE.ORG/path/to/civicrm/api
 *
 * Read more about testing here
 * http://wiki.civicrm.org/confluence/display/CRM/Testing