Merge pull request #5123 from eileenmcnaughton/CRM-15369
[civicrm-core.git] / api / v3 / examples / MessageTemplate / Get.php
CommitLineData
397e0e51 1<?php
50fb255d 2/**
3 * Test Generated example of using message_template get API.
4 *
50fb255d 5 * @return array
6 * API result array
7 */
8function message_template_get_example() {
9 $params = array(
10 'msg_title' => 'msg_title_166',
11 'msg_subject' => 'msg_subject_166',
12 'msg_text' => 'msg_text_166',
13 'msg_html' => 'msg_html_166',
14 'workflow_id' => 166,
15 'is_default' => '1',
16 'is_reserved' => 1,
17 );
397e0e51 18
50fb255d 19 try{
20 $result = civicrm_api3('message_template', 'get', $params);
21 }
22 catch (CiviCRM_API3_Exception $e) {
23 // Handle error here.
24 $errorMessage = $e->getMessage();
25 $errorCode = $e->getErrorCode();
26 $errorData = $e->getExtraParams();
27 return array(
28 'error' => $errorMessage,
29 'error_code' => $errorCode,
30 'error_data' => $errorData,
31 );
32 }
33
34 return $result;
397e0e51
EC
35}
36
37/**
50fb255d 38 * Function returns array of result expected from previous function.
39 *
40 * @return array
41 * API result array
397e0e51 42 */
50fb255d 43function message_template_get_expectedresult() {
397e0e51
EC
44
45 $expectedResult = array(
50fb255d 46 'is_error' => 0,
47 'version' => 3,
48 'count' => 1,
5c49fee0 49 'id' => 68,
50fb255d 50 'values' => array(
5c49fee0
CW
51 '68' => array(
52 'id' => '68',
50fb255d 53 'msg_title' => 'msg_title_166',
54 'msg_subject' => 'msg_subject_166',
55 'msg_text' => 'msg_text_166',
56 'msg_html' => 'msg_html_166',
57 'is_active' => '1',
58 'workflow_id' => '166',
59 'is_default' => '1',
60 'is_reserved' => '1',
61 'is_sms' => '1',
62 'pdf_format_id' => '166',
63 ),
397e0e51 64 ),
50fb255d 65 );
397e0e51
EC
66
67 return $expectedResult;
68}
69
50fb255d 70/**
71* This example has been generated from the API test suite.
72* The test that created it is called
73* testGet
74* and can be found in
69d79249 75* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MessageTemplateTest.php
397e0e51
EC
76*
77* You can see the outcome of the API tests at
69d79249 78* https://test.civicrm.org/job/CiviCRM-master-git/
397e0e51
EC
79*
80* To Learn about the API read
69d79249 81* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
397e0e51 82*
69d79249 83* Browse the api on your own site with the api explorer
41d4d31f 84* http://MYSITE.ORG/path/to/civicrm/api
397e0e51
EC
85*
86* Read more about testing here
87* http://wiki.civicrm.org/confluence/display/CRM/Testing
88*
89* API Standards documentation:
90* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 91*/