1: <?php
2:
3: namespace tschiemer\Aspsms;
4:
5: /**
6: * Interface for service drivers, can be used as standalone components.
7: *
8: * @version 1.1.0
9: * @package aspsms
10: * @license LGPL v3 http://www.gnu.org/licenses/lgpl-3.0.txt
11: * @copyright 2013 Philip Tschiemer, <tschiemer@filou.se>
12: * @link https://github.com/tschiemer/aspsms-php
13: */
14: abstract class AbstractClient
15: {
16: /**
17: * List of satsfiable requests
18: *
19: * @var string[]
20: * @access protected
21: * @see canPerform()
22: */
23: var $requests = array(
24: 'getVersion' => NULL,
25: 'getCredits' => NULL,
26: 'getStatusCodeDescription' => NULL,
27:
28: 'sendText' => NULL,
29: 'sendWapPush' => NULL,
30:
31: 'sendToken' => NULL,
32: 'verifyToken' => NULL,
33:
34: 'getDeliveryStatus' => NULL,
35:
36: 'checkOriginator' => NULL,
37: 'sendOriginatorCode' => NULL,
38: 'unlockOriginator' => NULL,
39:
40: 'sendPicture' => NULL,
41: 'sendLogo' => NULL,
42: 'sendGroupLogo' => NULL,
43: 'sendRingtone' => NULL,
44: 'sendVCard' => NULL,
45: 'sendBinaryData' => NULL
46: );
47:
48:
49: /**
50: *
51: * @var \Aspsms\Request
52: */
53: var $request = NULL;
54:
55: /**
56: *
57: * @var \Aspsms\Response
58: */
59: var $response = NULL;
60:
61: // public function __construct($options=array());
62:
63: /**
64: * Can satisfy/perform the given request?
65: *
66: * @param string|\Aspsms\Request $requestName
67: * @return boolean
68: */
69: public function canProcess($request)
70: {
71: if ($request instanceof Request)
72: {
73: $request = $request->getRequestName();
74: }
75: return array_key_exists($request, $this->requests);
76: }
77:
78: /**
79: * @param array $request
80: * @return array
81: * @throws ServiceException
82: */
83: abstract public function send($request);
84:
85: /**
86: * @return \Aspsms\Response
87: */
88: public function getResponse()
89: {
90: return $this->response;
91: }
92:
93: /**
94: * Reset internal request and response
95: */
96: public function clear()
97: {
98: $this->request = NULL;
99: $this->response = NULL;
100: }
101: }
102:
103: