Overview

Namespaces

  • SmsOrange
    • Cruise

Classes

  • SmsOrange\Cruise
  • SmsOrange\Cruise\CostaCruisesWebservice
  • SmsOrange\Cruise\ManualCruisesWebservice
  • SmsOrange\Dispatcher
  • SmsOrange\Main

Interfaces

  • SmsOrange\Bookable
  • Overview
  • Namespace
  • Class
  1: <?php
  2: namespace SmsOrange;
  3: 
  4: /**
  5:  * Class Cruise
  6:  *
  7:  * Cruise booking service.
  8:  *
  9:  * @package SmsOrange
 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:      * Cruise constructor.
 21:      *
 22:      * Sets the service name, response type and prepares
 23:      * the api parameters.
 24:      *
 25:      * @param string $token
 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:      * Implementation of the Bookable contract's search method.
 45:      *
 46:      * Calls on the service API search.
 47:      *
 48:      * @param array $parameters
 49:      * @return object
 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:      * Implementation of the Bookable contract's select method.
 64:      *
 65:      * Calls on the service API cruise select.
 66:      *
 67:      * @param array $parameters
 68:      * @return object
 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:      * Implementation of the Bookable contract's getComponents method.
 85:      *
 86:      * Calls on the service API cruise getComponents.
 87:      *
 88:      * @param array $parameters
 89:      * @return object
 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:      * Implementation of the Bookable contract's getAvailableCategories method.
104:      *
105:      * Calls on the service API cruise getAvailableCategories.
106:      *
107:      * @param array $parameters
108:      * @return object
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:      * Implementation of the Bookable contract's getCabins method.
123:      *
124:      * Calls on the service API cruise getCabins.
125:      *
126:      * @param array $parameters
127:      * @return object
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:      * Implementation of the Bookable contract's getQuote method.
142:      *
143:      * Calls on the service API cruise getQuote.
144:      *
145:      * @param array $parameters
146:      * @return object
147:      */
148:     public function getQuote($parameters = [])
149:     {
150: 
151:     }
152: 
153:     /**
154:      * Implementation of the Bookable contract's holdCabin method.
155:      *
156:      * Calls on the service API cruise holdCabin.
157:      *
158:      * @param array $parameters
159:      * @return object
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:      * Implementation of the Bookable contract's book method.
174:      *
175:      * Calls on the service API cruise book.
176:      *
177:      * @param array $parameters
178:      * @return object
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: 
API documentation generated by ApiGen