updated examples
[civicrm-core.git] / api / v3 / examples / MessageTemplateGet.php
CommitLineData
397e0e51
EC
1<?php
2/**
0a972ab7 3 * Test Generated example of using message_template get API
397e0e51
EC
4 * *
5 */
0a972ab7 6function message_template_get_example(){
397e0e51 7$params = array(
b259a4ab
EM
8 'msg_title' => 'msg_title_56',
9 'msg_subject' => 'msg_subject_56',
10 'msg_text' => 'msg_text_56',
11 'msg_html' => 'msg_html_56',
12 'workflow_id' => 56,
0a972ab7 13 'is_default' => '1',
397e0e51
EC
14 'is_reserved' => 1,
15 'pdf_format_id' => '1',
16);
17
18try{
0a972ab7 19 $result = civicrm_api3('message_template', 'get', $params);
397e0e51
EC
20}
21catch (CiviCRM_API3_Exception $e) {
22 // handle error here
23 $errorMessage = $e->getMessage();
24 $errorCode = $e->getErrorCode();
25 $errorData = $e->getExtraParams();
26 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
27}
28
29return $result;
30}
31
32/**
33 * Function returns array of result expected from previous function
34 */
0a972ab7 35function message_template_get_expectedresult(){
397e0e51
EC
36
37 $expectedResult = array(
38 'is_error' => 0,
39 'version' => 3,
40 'count' => 1,
41 'id' => 1,
42 'values' => array(
43 '1' => array(
44 'id' => '1',
b259a4ab
EM
45 'msg_title' => 'msg_title_56',
46 'msg_subject' => 'msg_subject_56',
47 'msg_text' => 'msg_text_56',
48 'msg_html' => 'msg_html_56',
0a972ab7 49 'is_active' => '1',
b259a4ab 50 'workflow_id' => '56',
0a972ab7 51 'is_default' => '1',
397e0e51
EC
52 'is_reserved' => '1',
53 'pdf_format_id' => '1',
54 ),
55 ),
56);
57
58 return $expectedResult;
59}
60
61
62/*
63* This example has been generated from the API test suite. The test that created it is called
64*
65* testGet and can be found in
0a972ab7 66* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/MessageTemplateTest.php
397e0e51
EC
67*
68* You can see the outcome of the API tests at
69* http://tests.dev.civicrm.org/trunk/results-api_v3
70*
71* To Learn about the API read
72* http://book.civicrm.org/developer/current/techniques/api/
73*
74* and review the wiki at
75* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
76*
77* Read more about testing here
78* http://wiki.civicrm.org/confluence/display/CRM/Testing
79*
80* API Standards documentation:
81* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 82*/