1: <?php
2: namespace SmsOrange;
3:
4: 5: 6: 7: 8: 9: 10:
11: class Cruise extends Main implements Bookable
12: {
13: private $serviceName;
14: private $responseType;
15: private $apiUrl;
16: private $apiParams;
17: private $token;
18:
19: 20: 21: 22: 23: 24: 25: 26:
27: public function __construct($token)
28: {
29: parent::__construct();
30:
31: $this->token = $token;
32:
33: $this->responseType = $this->config->get("app.Cruise.response_type");
34:
35: $this->apiUrl = $this->config->get("app.Cruise.url");
36:
37: $this->apiParams = [
38: 'api_token' => $token,
39: 'api_type' => $this->config->get("app.Cruise.response_type"),
40: ];
41: }
42:
43: 44: 45: 46: 47: 48: 49: 50:
51: public function search($parameters = [])
52: {
53: $method = $this->getApiMethod($this->serviceName, __FUNCTION__);
54:
55: $body = array_merge($parameters, $this->apiParams);
56:
57: $resp = $this->executeRequest($this->apiUrl, $method, $body);
58:
59: return $resp;
60: }
61:
62: 63: 64: 65: 66: 67: 68: 69:
70: public function select($parameters = [])
71: {
72: $method = $this->getApiMethod($this->serviceName, __FUNCTION__);
73:
74: parse_str($parameters['data'], $params);
75:
76: $selectUrl = $method . $params['webservice'] . '/' . $params['cruise-code'];
77:
78: $resp = $this->executeRequest($this->apiUrl . $selectUrl, $method, $this->apiParams);
79:
80: return $resp;
81: }
82:
83: 84: 85: 86: 87: 88: 89: 90:
91: public function getComponents($parameters = [])
92: {
93: $webserviceName = $this->config->get("app.Cruise.webservices.{$parameters['webservice']}");
94:
95: $webserviceClass = "\\SmsOrange\\Cruise\\$webserviceName";
96:
97: $ws = new $webserviceClass($this->apiUrl, $this->apiParams);
98:
99: return $ws->getComponents($parameters);
100: }
101:
102: 103: 104: 105: 106: 107: 108: 109:
110: public function getAvailableCategories($parameters = [])
111: {
112: $webserviceName = $this->config->get("app.Cruise.webservices.{$parameters['webservice']}");
113:
114: $webserviceClass = "\\SmsOrange\\Cruise\\$webserviceName";
115:
116: $ws = new $webserviceClass($this->apiUrl, $this->apiParams);
117:
118: return $ws->getAvailableCategories($parameters);
119: }
120:
121: 122: 123: 124: 125: 126: 127: 128:
129: public function getCabins($parameters = [])
130: {
131: $webserviceName = $this->config->get("app.Cruise.webservices.{$parameters['webservice']}");
132:
133: $webserviceClass = "\\SmsOrange\\Cruise\\$webserviceName";
134:
135: $ws = new $webserviceClass($this->apiUrl, $this->apiParams);
136:
137: return $ws->getCabins($parameters);
138: }
139:
140: 141: 142: 143: 144: 145: 146: 147:
148: public function getQuote($parameters = [])
149: {
150:
151: }
152:
153: 154: 155: 156: 157: 158: 159: 160:
161: public function holdCabin($parameters = [])
162: {
163: $webserviceName = $this->config->get("app.Cruise.webservices.{$parameters['webservice']}");
164:
165: $webserviceClass = "\\SmsOrange\\Cruise\\$webserviceName";
166:
167: $ws = new $webserviceClass($this->apiUrl, $this->apiParams);
168:
169: return $ws->holdCabin($parameters);
170: }
171:
172: 173: 174: 175: 176: 177: 178: 179:
180: public function book($parameters = [])
181: {
182: $webserviceName = $this->config->get("app.Cruise.webservices.{$parameters['webservice']}");
183:
184: $webserviceClass = "\\SmsOrange\\Cruise\\$webserviceName";
185:
186: $ws = new $webserviceClass($this->apiUrl, $this->apiParams);
187:
188: return $ws->book($parameters);
189: }
190:
191: }
192: