public function __invoke() { try { $request_xml = $this->hotusa_xml->init(); $request_xml->addChild('tipo', self::HOTUSA_SERVICE); $params = $request_xml->addChild('parametros'); $params->addChild('comprimido', '2'); $params->addChild('codigo_hotel', $this->hotel_code); $params->addChild('nombre_cliente', $this->client_name); $params->addChild('observaciones', $this->requests); $params->addChild('num_mensaje', ''); $params->addChild('forma_pago', self::DEFAULT_PAYMENT_TYPE); $param_line = $params->addChild('res'); foreach ($this->rate_keys as $line) { $param_line->addChild('lin', $line); } $response = $this->service_request->send($request_xml); if ($response && isset($response->parametros->n_localizador)) { $locator = (array) $response->parametros->n_localizador; return ['locator' => $locator[0]]; } else { throw new ServiceHotelPreBookingException("Empty response from Hotusa"); } } catch (ServiceRequestException $e) { throw new ServiceHotelPreBookingException($e->getMessage()); } }
public function __invoke() { try { $request_xml = $this->hotusa_xml->init(); $request_xml->addChild('tipo', self::HOTUSA_SERVICE); $params = $request_xml->addChild('parametros'); $params->addChild('comprimido', '2'); $response = $this->service_request->send($request_xml); if ($response && isset($response->parametros->provincias)) { return (array) $response->parametros->provincias; } else { throw new ServiceProvincesException("Empty response from Hotusa"); } } catch (ServiceRequestException $e) { throw new ServiceProvincesException($e->getMessage()); } }
/** * @return array * @throws ServiceHotelRoomsException */ public function __invoke() { try { $request_xml = $this->hotusa_xml->init(); $request_xml->addChild('tipo', self::HOTUSA_SERVICE); $params = $request_xml->addChild('parametros'); $params->addChild('comprimido', '2'); $params->addChild('codhot', $this->hotel_code); $response = $this->service_request->send($request_xml); $hotusa_rooms = []; if (!isset($response->parametros->habitaciones)) { return $hotusa_rooms; } $hotusa_rooms = (array) $response->parametros->habitaciones; return $hotusa_rooms; } catch (ServiceRequestException $e) { throw new ServiceHotelRoomsException($e->getMessage()); } }
public function __invoke() { try { $request_xml = $this->hotusa_xml->init(); $request_xml->addChild('tipo', self::HOTUSA_SERVICE); $params = $request_xml->addChild('parametros'); $params->addChild('comprimido', '2'); $params->addChild('localizador', $this->locator); $response = $this->service_request->send($request_xml); if ($response && isset($response->parametros->reserva->localizador_largo)) { $book = (array) $response->parametros->reserva; $long_locator = $book['localizador_largo']; $short_locator = $book['localizador_corto']; return ["long_locator" => $long_locator, "short_locator" => $short_locator, "reference" => $long_locator, "raw_response" => json_encode((array) $response, true)]; } else { throw new ServiceHotelBookingVoucherException("Empty response from Hotusa"); } } catch (ServiceRequestException $e) { throw new ServiceHotelBookingVoucherException($e->getMessage()); } }
public function __invoke() { try { $request_xml = $this->hotusa_xml->init(); $request_xml->addChild('tipo', self::HOTUSA_SERVICE); $request_xml->addChild('datos_reserva'); $hotel = $request_xml->addChild('hotel', $this->hotel_code); foreach ($this->rate_keys as $line) { $hotel->addChild('lin', $line); } $params = $request_xml->addChild('parametros'); $params->addChild('comprimido', '2'); $response = $this->service_request->send($request_xml); if ($response && isset($response->parametros->politicaCanc)) { return (array) $response->parametros->politicaCanc; } else { throw new ServiceHotelCancellationPoliciesException("Empty response from Hotusa"); } } catch (ServiceRequestException $e) { throw new ServiceHotelCancellationPoliciesException($e->getMessage()); } }
public function __invoke() { try { $request_xml = $this->hotusa_xml->init(); $request_xml->addChild('peticion'); $request_xml->addChild('tipo', self::HOTUSA_SERVICE); $request_xml->addChild('parametros'); $request_xml->addChild('comprimido', '2'); $request_xml->addChild('localizador_largo', $this->long_locator); $request_xml->addChild('localizador_corto', $this->short_locator); $response = $this->service_request->send($request_xml); if ($response && isset($response->parametros->localizador)) { $long_locator = (array) $response->parametros->localizador; $short_locator = (array) $response->parametros->localizador_corto; return ["long_locator" => $long_locator[0], "short_locator" => $short_locator[0]]; } else { ServiceHotelBookingCancellationException::throwBecauseIncorrectResponse($response); } } catch (ServiceRequestException $e) { throw new ServiceHotelBookingCancellationException($e->getMessage()); } }
/** * @return mixed * @throws ServiceHotelsAvailabilityException */ public function __invoke() { try { $request_xml = $this->hotusa_xml->init(); $request_xml->addChild('tipo', self::HOTUSA_SERVICE); $request_xml->addChild('parametros'); $request_xml->addChild('comprimido', '2'); $request_xml->addChild('radio', '9'); $request_xml->addChild('tarifas_reembolsables', '1'); $request_xml->addChild('afiliacion', $this->request_configuration['afiliacio']); $request_xml->addChild('usuario', $this->request_configuration['codusu']); foreach ($this->request_params as $param_key => $param_value) { $param_value = $this->prepareHotelCodes($param_key, $param_value); if (in_array($param_key, $this->available_request_params)) { $request_xml->addChild($param_key, $param_value); } else { throw new ServiceHotelsAvailabilityException("Parameter '{$param_key}' isn't available for this service."); } } $response = $this->service_request->send($request_xml); if ($response && isset($response->param->hotls)) { $hotels = json_decode(json_encode($response->param->hotls), true); if (0 >= $hotels['@attributes']["num"]) { $hotels_codes = $this->request_params['hotel']; throw new ServiceHotelsAvailabilityException("No available rooms for the hotels {$hotels_codes}. Num: {$hotels['@attributes']["num"]}"); } elseif (1 >= $hotels['@attributes']["num"]) { return [$hotels['hot']]; } return $hotels['hot']; } elseif (isset($response->param->error->descripcion)) { throw new ServiceHotelsAvailabilityException($response->param->error->descripcion); } else { throw new ServiceHotelsAvailabilityException("Empty response from Hotusa"); } } catch (ServiceRequestException $e) { throw new ServiceHotelsAvailabilityException($e->getMessage()); } }
public function __invoke() { try { $request_xml = $this->hotusa_xml->init(); $request_xml->addChild('tipo', self::HOTUSA_SERVICE); $params = $request_xml->addChild('parametros'); $params->addChild('comprimido', '2'); $params->addChild('localizador', $this->locator); $params->addChild('accion', self::BOOKING_ACTION); $response = $this->service_request->send($request_xml); if ($response && isset($response->parametros->localizador)) { $long_locator = (array) $response->parametros->localizador; $short_locator = (array) $response->parametros->localizador_corto; $status = (array) $response->parametros->estado; $raw_response = json_decode(json_encode($response), true); return ["long_locator" => $long_locator[0], "short_locator" => $short_locator[0], "status" => "00" == $status[0] ? "confirmed" : "invalid", "raw_response" => $raw_response]; } else { throw new ServiceHotelBookingException("Empty response from Hotusa"); } } catch (ServiceRequestException $e) { throw new ServiceHotelBookingException($e->getMessage()); } }
public function __invoke() { try { $request_xml = $this->hotusa_xml->init(); $request_xml->addChild('tipo', self::HOTUSA_SERVICE); $params = $request_xml->addChild('parametros'); $params->addChild('comprimido', '2'); $params->addChild('localizador_largo', $this->long_locator); $params->addChild('localizador_corto', $this->short_locator); $response = $this->service_request->send($request_xml); if ($response && isset($response->parametros->localizador)) { $long_locator = (array) $response->parametros->localizador; $cancellation_reference = (array) $response->parametros->localizador_baja; $status = (array) $response->parametros->estado; $raw_response = json_encode($response); $cancelled_status = ["00", "09"]; return ["long_locator" => $long_locator[0], "cancellation_reference" => $cancellation_reference[0], "status" => in_array($status[0], $cancelled_status) ? static::CANCELLED_STATUS : static::INVALID_STATUS, "raw_response" => $raw_response]; } else { throw new ServiceHotelCancellationException("Empty response from Hotusa"); } } catch (ServiceRequestException $e) { throw new ServiceHotelCancellationException($e->getMessage()); } }