-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathSimProxy.class.php
88 lines (71 loc) · 2.01 KB
/
SimProxy.class.php
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
<?php
namespace SimClient;
/**
* @file
* Provides a proxy for the Selligent Individual service.
*/
abstract class SimProxy {
// Password to access the API
private $password = '';
// Login username to access the API
private $login = '';
private $emsecure_name = '';
private $client = FALSE;
protected $individualURL = '';
protected $broadcastURL = '';
// @todo document this function.
public function __construct($config) {
if (isset($config['individual_url'])) {
$this->individualURL = $config['individual_url'];
} else {
throw new \Exception('Credentials not set.');
}
if (isset($config['broadcast_url'])) {
$this->broadcastURL = $config['broadcast_url'];
} else {
throw new \Exception('Credentials not set.');
}
if (isset($config['login'])) {
$this->login = $config['login'];
} else {
throw new \Exception('Credentials not set.');
}
if (isset($config['password'])) {
$this->password = $config['password'];
} else {
throw new \Exception('Credentials not set.');
}
$this->connect();
}
// @todo document this function.
public function connect() {
try {
$this->client = new \SoapClient($this->getSoapUrl());
$this->client->__setSoapHeaders($this->getHeader());
} catch (\Exception $e) {
throw new \Exception('Could not connect: ' . $e->getMessage());
}
}
// @todo document this function.
public function getClient() {
return $this->client;
}
/**
* Get the Soapheader
*/
protected function getHeader() {
return new \SoapHeader('http://tempuri.org/', 'AutomationAuthHeader', array('Login' => $this->login, 'Password' => $this->password));
}
// @todo document this function.
protected abstract function getSoapUrl();
/**
* Do the Soap call.
*/
public function call($method, $param = '') {
if ($this->client) {
return $this->client->{$method}($param);
} else {
throw new \Exception(t('SOAP Client unavailable'));
}
}
}