douhu2890 2016-08-11 06:44
浏览 73

Hotelbeds PHP API - 如何获得每日房价?

I am working with Hotelbeds APItude PHP API to find out the information of available hotel rooms.

Well, I am able to get all information of available hotels through the documentation

But, I am facing problem with getting daily rate of all available hotel rooms.

There is an option in documentation to send request attribute for getting daily rate of each room. Here is the request attribute -

availabilityRQ/@dailyRate -- Boolean -- Optional -- Display the rate day-by-day

dailyRate is an boolean value that confirms is the API ll send back daily rate info (I think so far).

So, in implementation, I send following request parameter -

                    $rqData = new \hotelbeds\hotel_api_sdk\helpers\Availability();
                $rqData->stay = new Stay(DateTime::createFromFormat("Y-m-d", "2016-09-01"),
                    DateTime::createFromFormat("Y-m-d", "2016-09-10"));

                $rqData->hotels = ["hotel" => [1067, 1070,]];

                //                    $rqData->destination = new Destination("PMI");
                $occupancy = new Occupancy();
                $occupancy->adults = 2;
                $occupancy->children = 1;
                $occupancy->rooms = 1;

                $occupancy->paxes = [new Pax(Pax::AD, 30, "Mike", "Doe"), new Pax(Pax::AD, 27, "Jane", "Doe"), new Pax(Pax::CH, 8, "Mack", "Doe")];
                $rqData->occupancies = [$occupancy];

                $rqData->dailyRate = TRUE;

                $availRS = $apiClient->Availability($rqData);

I checked, everything work fine except the $rqData->dailyRate = TRUE; parameter.

I get following error -

Bad Request: The request is not compliant with the specified version of the API. Error at property dailyRate: Can not construct instance of boolean from String value 'Y': only "true" or "false" recognized

I think, I am missing something like creating boolean parameter for the dailyRate attribute.

How can I solve the issue?

  • 写回答

1条回答 默认 最新

  • dongya767979565 2016-08-11 07:19
    关注

    This looks like a bug with their public API or their PHP library. File a bug report.

    class Availability extends ApiHelper. class ApiHelper extends DataContainer.

    In DataContainer, if (is_bool($item)) return $item ? "Y" : "N";.

    https://github.com/hotelbeds-sdk/hotel-api-sdk-php/blob/56b4621bbf488a878f1eb1a194f6a63d928dc9db/src/generic/DataContainer.php#L105

    Their DataContainer.php in their library casts boolean values to Y or N. As such, when you do your API request - any values which are true/false get converted to Y/N.

    But their API requires true/false.

    评论

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀