-
Notifications
You must be signed in to change notification settings - Fork 2
/
bsdapi.module
125 lines (96 loc) · 3.03 KB
/
bsdapi.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
/**
* Implementation of hook_menu().
*/
function bsdapi_menu() {
$items = array();
$items['admin/settings/bsdapi'] = array(
'title' => 'Blue State Digital API',
'page callback' => 'drupal_get_form',
'page arguments' => array('bsdapi_settings_form'),
'access callback' => 'user_access',
'access arguments' => array('administer site configuration'),
'file' => 'bsdapi.admin.inc',
);
return $items;
}
// constituents
/**
* Get constituents by id
* @param $cons_ids
* Array of constituents ids
* @param array $bundles
* Array of bundle names ('cons_addr', 'cons_phone', 'cons_email', 'cons_profile' etc. )
* @param unknown_type $filter
*/
function bsdapi_get_constituents_by_id($cons_ids, $bundles = array(), $filter= NULL){
module_load_include('inc', 'bsdapi', 'bsdapi.class');
$obj = new BsdApi();
$params = array();
$cons_ids = implode(',', $cons_ids);
$params['cons_ids'] = $cons_ids;
if (count($bundles)){
$bundles = implode(',', $bundles);
$params['bundles'] = $bundles;
}
if($filter){
$params['filter'] = filter;
}
$result = $obj->request('cons/get_constituents_by_id', $params);
return $result;
}
/**
* Get constituents give some filters
* @param $filter
* A filter string to apply
* @param array $bundles
* Array of bundle names ('cons_addr', 'cons_phone', 'cons_email', 'cons_profile' etc. )
*/
function bsdapi_get_constituents($filter, $bundles = array()){
module_load_include('inc', 'bsdapi', 'bsdapi.class');
$obj = new BsdApi();
$params['filter'] = $filter;
if (count($bundles)){
$bundles = implode(',', $bundles);
$params['bundles'] = $bundles;
}
$result = $obj->request('cons/get_constituents', $params);
return $result;
}
/**
* Takes one or more GUIDs (non-sequential, random, unique identifiers for constituents)
* as a parameter and returns the matching constituent records.
* @param $guids
* One or more (comma separated) GUIDs.
* @param array $bundles
* Array of bundle names ('cons_addr', 'cons_phone', 'cons_email', 'cons_profile' etc. )
* @param $filter
* The filter to apply to the resulting record
*/
function bsdapi_get_constituents_by_guid($guids, $bundles = array(), $filter = NULL){
module_load_include('inc', 'bsdapi', 'bsdapi.class');
$obj = new BsdApi();
$params = array();
$guids = implode(',', $guids);
$params['$guids'] = $cons_ids;
if (count($boundles)){
$bundles = implode(',', $bundles);
$params['bundles'] = $bundles;
}
if($filter){
$params['filter'] = filter;
}
$result = $obj->request('cons/get_constituents_by_guid', $params);
return $result;
}
/**
* allows creating or updating constituent records in BSD's system for one or more constituents
* @param $post
* XML string describing the constituent
*/
function bsdapi_set_constituent_data($post){
module_load_include('inc', 'bsdapi', 'bsdapi.class');
$obj = new BsdApi();
$result = $obj->request('cons/set_constituent_data', array(), $post);
return $result;
}