Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | |
3 | /* | |
4 | +--------------------------------------------------------------------+ | |
39de6fd5 | 5 | | CiviCRM version 4.6 | |
6a488035 | 6 | +--------------------------------------------------------------------+ |
731a0992 | 7 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
8 | +--------------------------------------------------------------------+ |
9 | | This file is a part of CiviCRM. | | |
10 | | | | |
11 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
12 | | under the terms of the GNU Affero General Public License | | |
13 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
14 | | | | |
15 | | CiviCRM is distributed in the hope that it will be useful, but | | |
16 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
17 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
18 | | See the GNU Affero General Public License for more details. | | |
19 | | | | |
20 | | You should have received a copy of the GNU Affero General Public | | |
21 | | License and the CiviCRM Licensing Exception along | | |
22 | | with this program; if not, contact CiviCRM LLC | | |
23 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
24 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
25 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
26 | +--------------------------------------------------------------------+ | |
27 | */ | |
28 | ||
29 | /** | |
30 | * new version of civicrm apis. See blog post at | |
31 | * http://civicrm.org/node/131 | |
32 | * | |
33 | * @package CiviCRM_APIv3 | |
34 | * @subpackage API_Contact | |
731a0992 | 35 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
36 | * $Id: PaymentProcessorType.php 30415 2010-10-29 12:02:47Z shot $ |
37 | * | |
38 | */ | |
39 | ||
40 | /** | |
41 | * Include common API util functions | |
42 | */ | |
6a488035 TO |
43 | |
44 | /** | |
c490a46a | 45 | * create payment_processor type |
6a488035 | 46 | * |
cf470720 TO |
47 | * @param array $params |
48 | * Associative array of property name/value pairs to insert in new payment_processor type. | |
6a488035 TO |
49 | * |
50 | * @return Newly created PaymentProcessor_type object | |
51 | * {@getfields PaymentProcessorType_create} | |
52 | * @access public | |
53 | * {@schema Core/PaymentProcessorType.xml} | |
54 | */ | |
55 | function civicrm_api3_payment_processor_type_create($params) { | |
6a488035 TO |
56 | $ids = array(); |
57 | if (isset($params['id']) && !CRM_Utils_Rule::integer($params['id'])) { | |
58 | return civicrm_api3_create_error('Invalid value for payment_processor type ID'); | |
59 | } | |
60 | ||
61 | $payProcType = new CRM_Financial_BAO_PaymentProcessorType(); | |
62 | $payProcType = CRM_Financial_BAO_PaymentProcessorType::create($params); | |
63 | ||
64 | $relType = array(); | |
65 | ||
66 | _civicrm_api3_object_to_array($payProcType, $relType[$payProcType->id]); | |
67 | ||
68 | return civicrm_api3_create_success($relType, $params, 'payment_processor_type', 'create', $payProcType); | |
69 | } | |
70 | ||
71 | /** | |
72 | * Adjust Metadata for Create action | |
73 | * | |
74 | * The metadata is used for setting defaults, documentation & validation | |
cf470720 TO |
75 | * @param array $params |
76 | * Array or parameters determined by getfields. | |
6a488035 TO |
77 | */ |
78 | function _civicrm_api3_payment_processor_type_create_spec(&$params) { | |
79 | $params['billing_mode']['api.required'] = 1; | |
80 | $params['class_name']['api.required'] = 1; | |
81 | $params['is_active']['api.default'] = 1; | |
82 | $params['is_recur']['api.default'] = FALSE; | |
83 | // FIXME bool support // $params['is_recur']['api.required'] = 1; | |
84 | $params['name']['api.required'] = 1; | |
85 | $params['title']['api.required'] = 1; | |
86 | } | |
87 | ||
88 | /** | |
c490a46a | 89 | * get all payment_processor type |
6a488035 TO |
90 | * retruns An array of PaymentProcessor_type |
91 | * @access public | |
92 | * {@getfields PaymentProcessorType_get} | |
93 | * @example PaymentProcessorTypeGet.php | |
94 | */ | |
95 | function civicrm_api3_payment_processor_type_get($params) { | |
96 | return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); | |
97 | } | |
98 | ||
99 | /** | |
100 | * Delete a payment_processor type delete | |
101 | * | |
cf470720 | 102 | * @param id of payment_processor type $id |
6a488035 TO |
103 | * |
104 | * @return array API Result Array | |
105 | * {@getfields PaymentProcessorType_delete} | |
106 | * @static void | |
107 | * @access public | |
108 | */ | |
109 | function civicrm_api3_payment_processor_type_delete($params) { | |
6a488035 TO |
110 | if ($params['id'] != NULL && !CRM_Utils_Rule::integer($params['id'])) { |
111 | return civicrm_api3_create_error('Invalid value for payment processor type ID'); | |
112 | } | |
113 | ||
114 | $payProcTypeBAO = new CRM_Financial_BAO_PaymentProcessorType(); | |
115 | $result = $payProcTypeBAO->del($params['id']); | |
116 | if (!$result) { | |
117 | return civicrm_api3_create_error('Could not delete payment processor type'); | |
118 | } | |
119 | return civicrm_api3_create_success($result, $params, 'payment_processor_type', 'delete', $payProcTypeBAO); | |
120 | } |