forked from hugowetterberg/cbisimport
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCbisClient.php
More file actions
54 lines (47 loc) · 1.33 KB
/
CbisClient.php
File metadata and controls
54 lines (47 loc) · 1.33 KB
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
<?php
/**
* Helper class that manages the API key for the CBIS API.
*
* @package cbisimport
*/
class CbisClient extends SoapClient {
function __construct($service, $options) {
$url = variable_get('cbisimport_api_url', '');
$this->service = $service;
$this->apiKey = variable_get('cbisimport_api_key', '');
$wsdl = sprintf('%s/%s.asmx?WSDL', $url, $service);
// Enable logging of last request
$options['trace'] = 1;
try {
parent::__construct($wsdl, $options);
} catch (Exception $e) {
drupal_set_message(t('Failed to access CBIS: @message', array(
'@message' => $e->getMessage(),
)));
}
}
public function __call($method, $arguments) {
if (empty($arguments)) {
$arguments[] = array(
'apiKey' => $this->apiKey
);
}
else {
$arguments[0] = array_merge(array(
'apiKey' => $this->apiKey
), $arguments[0]);
}
$result = NULL;
try {
$result = parent::__call($method, $arguments);
// Log the raw xml from CBIS in our transaction
CbisTransaction::getCurrentTransaction()
->addState('raw_xml.xml', self::__getLastResponse());
} catch (Exception $e) {
drupal_set_message(t('Failed to access CBIS: @message', array(
'@message' => $e->getMessage(),
)));
}
return $result;
}
}