1: <?php
2: namespace SmsOrange\Cruise;
3:
4: use SmsOrange\Main;
5:
6: class CostaCruisesWebservice extends Main
7: {
8: private $apiUrl;
9: private $apiParams;
10:
11: public function __construct($apiUrl, $apiParams)
12: {
13: parent::__construct();
14:
15: $this->apiUrl = $apiUrl;
16: $this->apiParams = $apiParams;
17: }
18:
19: public function getComponents($parameters = false)
20: {
21: $method = $this->getApiMethod('Cruise', __FUNCTION__);
22:
23: parse_str($parameters['data'], $params);
24:
25: $selectUrl = 'CostaCruisesWebservice/' . $params['cruise-code'] . '/';
26:
27: $body = array_merge($this->apiParams, $params);
28:
29: $resp = $this->executeRequest($this->apiUrl . $selectUrl, $method, $body);
30:
31: return $resp;
32: }
33:
34: public function getAvailableCategories($parameters = false)
35: {
36: $method = $this->getApiMethod('Cruise', __FUNCTION__);
37:
38: parse_str($parameters['data'], $components);
39:
40: $selectUrl = 'CostaCruisesWebservice/' . $components['cruise-code'] . '/';
41:
42: $params['guests'] = $components['cruise-guests'];
43:
44: $params['components'][] = [
45: 'Type' => 'Cruise',
46: 'Code' => $components['cruise-code'],
47: 'Fare' => [
48: 'Code' => 'IND',
49: ],
50: ];
51:
52: $params['components'][] = $components;
53:
54: $body = array_merge($this->apiParams, $params);
55:
56: $resp = $this->executeRequest($this->apiUrl . $selectUrl, $method, $body);
57:
58: return $resp;
59: }
60:
61: public function getCabins($parameters = false)
62: {
63: $method = $this->getApiMethod('Cruise', __FUNCTION__);
64:
65: parse_str($parameters['data'], $components);
66:
67: $selectUrl = 'CostaCruisesWebservice/' . $components['cruise-code'] . '/';
68:
69: $params['guests'] = $components['cruise-guests'];
70:
71: $params['components'][] = [
72: 'Type' => 'Cruise',
73: 'Code' => $components['cruise-code'],
74: 'Fare' => [
75: 'Code' => 'IND',
76: ],
77: 'Category' => $components['category-code'],
78: ];
79:
80: $params['components'][] = $components;
81:
82: $body = array_merge($this->apiParams, $params);
83:
84: $resp = $this->executeRequest($this->apiUrl . $selectUrl, $method, $body);
85:
86: return $resp;
87: }
88:
89: public function getQuote($parameters = false)
90: {
91:
92: }
93:
94: public function holdCabin($parameters = false)
95: {
96: $method = $this->getApiMethod('Cruise', __FUNCTION__);
97:
98: parse_str($parameters['data'], $components);
99:
100: $selectUrl = 'CostaCruisesWebservice/' . $components['cruise-code'] . '/';
101:
102: $params['guests'] = $components['cruise-guests'];
103:
104: $params['components'][] = [
105: 'Type' => 'Cruise',
106: 'Code' => $components['cruise-code'],
107: 'Fare' => [
108: 'Code' => 'IND',
109: ],
110: 'Category' => $components['category-code'],
111: 'Cabin' => $components['cabin_number'],
112: 'DiningPreference' => $components['dining_preference'],
113: ];
114:
115: $params['components'][] = $components;
116:
117: $pc = array_merge($params, $components);
118: $body = array_merge($this->apiParams, $pc);
119:
120: $resp = $this->executeRequest($this->apiUrl . $selectUrl, $method, $body);
121:
122: return $resp;
123: }
124:
125: public function book($parameters = false)
126: {
127: $method = $this->getApiMethod('Cruise', __FUNCTION__);
128:
129: parse_str($parameters['data'], $components);
130:
131: $selectUrl = 'CostaCruisesWebservice/' . $components['cruise-code'] . '/';
132:
133: $params['guests'] = $components['cruise-guests'];
134:
135: $params['components'][] = [
136: 'Type' => 'Cruise',
137: 'Code' => $components['cruise-code'],
138: 'Fare' => [
139: 'Code' => 'IND',
140: ],
141: 'Category' => $components['category-code'],
142: 'Cabin' => $components['cabin-code'],
143: 'DiningPreference' => $components['dining-preference'],
144: ];
145:
146: $params['components'][] = $components;
147:
148: $pc = array_merge($params, $components);
149: $body = array_merge($this->apiParams, $pc);
150:
151: foreach($body['guest_data'] as $key => $guest){
152: $body['client_ids'][$key] = $guest['document_number'];
153: }
154:
155: $resp = $this->executeRequest($this->apiUrl . $selectUrl, $method, $body);
156:
157: return $resp;
158: }
159:
160: }
161: