hotels_pro 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +91 -0
- data/Rakefile +2 -0
- data/hotels_pro.gemspec +24 -0
- data/lib/hotels_pro.rb +69 -0
- data/lib/hotels_pro/api/api_method.rb +29 -0
- data/lib/hotels_pro/api/api_params.rb +29 -0
- data/lib/hotels_pro/api/elements/book_info.rb +27 -0
- data/lib/hotels_pro/api/elements/daily_rate.rb +12 -0
- data/lib/hotels_pro/api/elements/filter.rb +13 -0
- data/lib/hotels_pro/api/elements/hotel.rb +22 -0
- data/lib/hotels_pro/api/elements/lead_traveller.rb +15 -0
- data/lib/hotels_pro/api/elements/pax.rb +16 -0
- data/lib/hotels_pro/api/elements/pax_array.rb +17 -0
- data/lib/hotels_pro/api/elements/policy.rb +15 -0
- data/lib/hotels_pro/api/elements/room_response.rb +16 -0
- data/lib/hotels_pro/api/methods/allocate_hotel_code.rb +21 -0
- data/lib/hotels_pro/api/methods/amend_hotel_booking.rb +27 -0
- data/lib/hotels_pro/api/methods/cancel_hotel_booking.rb +20 -0
- data/lib/hotels_pro/api/methods/get_available_hotel.rb +28 -0
- data/lib/hotels_pro/api/methods/get_balance.rb +18 -0
- data/lib/hotels_pro/api/methods/get_hotel_booking_status.rb +21 -0
- data/lib/hotels_pro/api/methods/get_hotel_cancellation_policy.rb +19 -0
- data/lib/hotels_pro/api/methods/make_hotel_booking.rb +24 -0
- data/lib/hotels_pro/configuration.rb +14 -0
- data/lib/hotels_pro/query.rb +34 -0
- data/lib/hotels_pro/request.rb +43 -0
- data/lib/hotels_pro/response.rb +33 -0
- data/lib/hotels_pro/stubs.rb +66 -0
- data/lib/hotels_pro/stubs/stub.rb +23 -0
- data/lib/hotels_pro/underscorer.rb +21 -0
- data/lib/hotels_pro/version.rb +3 -0
- data/spec/api_params_helper.rb +8 -0
- data/spec/fixtures/allocate_hotel_code.json +1 -0
- data/spec/fixtures/amend_hotel_booking.json +1 -0
- data/spec/fixtures/cancel_hotel_booking.json +1 -0
- data/spec/fixtures/get_available_hotel.json +1 -0
- data/spec/fixtures/get_balance.json +1 -0
- data/spec/fixtures/get_hotel_booking_status.json +1 -0
- data/spec/fixtures/get_hotel_cancellation_policy.json +1 -0
- data/spec/fixtures/make_hotel_booking.json +1 -0
- data/spec/hotels_pro/api/.gitkeep +0 -0
- data/spec/hotels_pro/api/api_method_spec.rb +14 -0
- data/spec/hotels_pro/api/api_params_spec.rb +36 -0
- data/spec/hotels_pro/api/elements/pax_array_spec.rb +14 -0
- data/spec/hotels_pro/api/methods/allocate_hotel_code_spec.rb +34 -0
- data/spec/hotels_pro/api/methods/amend_hotel_booking_spec.rb +79 -0
- data/spec/hotels_pro/api/methods/cancel_hotel_booking_spec.rb +32 -0
- data/spec/hotels_pro/api/methods/get_available_hotel_spec.rb +83 -0
- data/spec/hotels_pro/api/methods/get_balance_spec.rb +26 -0
- data/spec/hotels_pro/api/methods/get_hotel_booking_status_spec.rb +31 -0
- data/spec/hotels_pro/api/methods/get_hotel_cancellation_policy_spec.rb +31 -0
- data/spec/hotels_pro/api/methods/make_hotel_booking_spec.rb +66 -0
- data/spec/hotels_pro/query_spec.rb +52 -0
- data/spec/hotels_pro/request_spec.rb +73 -0
- data/spec/hotels_pro/response_spec.rb +24 -0
- data/spec/hotels_pro/stubs/stub_spec.rb +41 -0
- data/spec/hotels_pro/stubs_spec.rb +37 -0
- data/spec/hotels_pro/underscorer_spec.rb +33 -0
- data/spec/request_helper.rb +6 -0
- data/spec/spec_helper.rb +15 -0
- metadata +222 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
module HotelsPro
|
2
|
+
module Underscorer
|
3
|
+
# Detect nested hashes and underscore their keys
|
4
|
+
def underscore(object)
|
5
|
+
case object
|
6
|
+
when Hash
|
7
|
+
object.inject({}) do |hash, (k, v)|
|
8
|
+
hash[k.underscore] = underscore(v)
|
9
|
+
hash
|
10
|
+
end
|
11
|
+
when Array
|
12
|
+
object.inject([]) do |arr, element|
|
13
|
+
arr << underscore(element)
|
14
|
+
arr
|
15
|
+
end
|
16
|
+
else
|
17
|
+
object
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"responseId":5752179,"hotelCode":"US6X5G","availableHotels":[{"processId":"HF-56017745","hotelCode":"US6X5G","availabilityStatus":"InstantConfirmation","totalPrice":335,"totalTax":0,"totalSalePrice":0,"currency":"USD","boardType":"Continental Breakfast","rooms":[{"roomCategory":"Double 1 Queen Bed","paxes":[{"paxType":"Adult","age":30}],"totalRoomRate":335,"ratesPerNight":[{"date":"2012-09-09","amount":112},{"date":"2012-09-10","amount":112},{"date":"2012-09-11","amount":111}]}]},{"processId":"HG-99198765","hotelCode":"US6X5G","availabilityStatus":"InstantConfirmation","totalPrice":392,"totalTax":0,"totalSalePrice":0,"currency":"USD","boardType":"Continental Breakfast","rooms":[{"roomCategory":"Double Two Queen Beds","paxes":[{"paxType":"Adult","age":30}],"totalRoomRate":392,"ratesPerNight":[{"date":"2012-09-09","amount":131},{"date":"2012-09-10","amount":131},{"date":"2012-09-11","amount":130}]}]}],"totalFound":2,"searchId":"VO-40164625"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"responseId":5762113,"trackingId":"XI-HW-82431210","agencyReferenceNumber":"999","amendStatus":"Pending","note":"Your amendment request has been received. You will be contacted regarding amendment results by email or by message in our online system."}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"responseId":5761559,"trackingId":"XI-HE-70838364","agencyReferenceNumber":"","bookingStatus":"Cancelled","note":"Booking has been cancelled successfully."}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"responseId":4214740,"availableHotels":[{"processId":"HM-99621850","hotelCode":"UKNZDJ","availabilityStatus":"InstantConfirmation","totalPrice":437,"totalTax":0,"totalSalePrice":0,"currency":"EUR","boardType":"English Breakfast","rooms":[{"roomCategory":"Triple Standard","paxes":[{"paxType":"Adult","age":30},{"paxType":"Adult","age":30},{"paxType":"Child","age":"6"}],"totalRoomRate":219,"ratesPerNight":[{"date":"2012-09-20","amount":0},{"date":"2012-09-21","amount":73},{"date":"2012-09-22","amount":73},{"date":"2012-09-23","amount":73}]},{"roomCategory":"Triple Standard","paxes":[{"paxType":"Adult","age":30},{"paxType":"Adult","age":30},{"paxType":"Child","age":"8"}],"totalRoomRate":218,"ratesPerNight":[{"date":"2012-09-20","amount":0},{"date":"2012-09-21","amount":73},{"date":"2012-09-22","amount":73},{"date":"2012-09-23","amount":72}]}]},{"processId":"HC-56363390","hotelCode":"UKSU69","availabilityStatus":"InstantConfirmation","totalPrice":471,"totalTax":0,"totalSalePrice":0,"currency":"EUR","boardType":"English Breakfast","rooms":[{"roomCategory":"Triple Standard","paxes":[{"paxType":"Adult","age":30},{"paxType":"Adult","age":30},{"paxType":"Child","age":"6"}],"totalRoomRate":235,"ratesPerNight":[{"date":"2012-09-20","amount":84},{"date":"2012-09-21","amount":0},{"date":"2012-09-22","amount":84},{"date":"2012-09-23","amount":67}]},{"roomCategory":"Triple Standard","paxes":[{"paxType":"Adult","age":30},{"paxType":"Adult","age":30},{"paxType":"Child","age":"8"}],"totalRoomRate":236,"ratesPerNight":[{"date":"2012-09-20","amount":84},{"date":"2012-09-21","amount":0},{"date":"2012-09-22","amount":84},{"date":"2012-09-23","amount":68}]}]}],"totalFound":2,"searchId":"SZ-91588250"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"responseId":5762226,"currency":"0.00","totalDeposit":"0.00","totalBookingAmount":"0.00","currentBalance":"0.00"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"responseId":5761428,"trackingId":"XI-HE-70838364","agencyReferenceNumber":null,"hotelBookingInfo":{"bookingStatus":5,"confirmationNumber":"TEST;0000000","hotelCode":"US2HZR","checkIn":"2012-10-04","checkOut":"2012-10-11","totalPrice":"528","currency":"EUR","totalSalePrice":0,"boardType":"Room Only","rooms":[{"roomCategory":"Double 1 Double Bed","paxes":[{"paxType":"Adult","age":30,"title":"Mr","firstName":"John","lastName":"Doe"},{"paxType":"Adult","age":30,"title":"Mrs","firstName":"Amanda","lastName":"Doe"}],"totalRoomRate":528,"ratesPerNight":[{"date":"2012-10-04","amount":75},{"date":"2012-10-05","amount":75},{"date":"2012-10-06","amount":75},{"date":"2012-10-07","amount":75},{"date":"2012-10-08","amount":75},{"date":"2012-10-09","amount":75},{"date":"2012-10-10","amount":78}]}],"cancellationPolicy":[{"cancellationDay":7,"feeType":"Night","feeAmount":"1","currency":null,"remarks":null},{"cancellationDay":0,"feeType":"Night","feeAmount":"1","currency":null,"remarks":null}],"agencyReferenceNumber":null,"comments":null}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"responseId":5761637,"trackingId":"XI-HE-70838364","agencyReferenceNumber":"","cancellationPolicy":[{"cancellationDay":7,"feeType":"Night","feeAmount":"1","currency":null,"remarks":""},{"cancellationDay":0,"feeType":"Night","feeAmount":"1","currency":null,"remarks":""}]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"responseId":5756635,"trackingId":"XI-HE-70838364","hotelBookingInfo":{"bookingStatus":5,"confirmationNumber":"TEST;0000000","supplier":null,"hotelCode":"US2HZR","checkIn":"2012-10-04","checkOut":"2012-10-11","totalPrice":"528","currency":"EUR","totalSalePrice":0,"boardType":"Room Only","rooms":[{"roomCategory":"Double 1 Double Bed","paxes":[{"paxType":"Adult","age":30,"title":"Mr","firstName":"John","lastName":"Doe"},{"paxType":"Adult","age":30,"title":"Mrs","firstName":"Amanda","lastName":"Doe"}],"totalRoomRate":528,"ratesPerNight":[{"date":"2012-10-04","amount":75},{"date":"2012-10-05","amount":75},{"date":"2012-10-06","amount":75},{"date":"2012-10-07","amount":75},{"date":"2012-10-08","amount":75},{"date":"2012-10-09","amount":75},{"date":"2012-10-10","amount":78}]}],"cancellationPolicy":[{"cancellationDay":7,"feeType":"Amount","feeAmount":80,"currency":"EUR","remarks":"Guest must notify the Front Desk upon check-in if depature date has changed.Double rooms has one double bed."},{"cancellationDay":0,"feeType":"Amount","feeAmount":80,"currency":"EUR","remarks":""}],"agencyReferenceNumber":"","comments":""}}
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HotelsPro::Api::ApiMethod do
|
4
|
+
let(:api_method) { HotelsPro::Api::ApiMethod.new }
|
5
|
+
|
6
|
+
it "should raise exception on error response" do
|
7
|
+
response = stub(:error? => true, :error => HotelsPro::ErrorResponse.new("Error occured."))
|
8
|
+
request = stub(:perform => response)
|
9
|
+
|
10
|
+
api_method.stub(:request => request)
|
11
|
+
|
12
|
+
lambda { api_method.perform }.should raise_error(HotelsPro::ErrorResponse, "Error occured.")
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HotelsPro::Api::ApiParams do
|
4
|
+
include ApiParamsHelper
|
5
|
+
|
6
|
+
before do
|
7
|
+
@object = mock_api_object({ :param_one => "value1", :param_two => "value2", :param_three => nil, :param_four => [], :param_five => {} })
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".to_api_params" do
|
11
|
+
it "should stringify and camelize attribute name" do
|
12
|
+
@object.api_param_name(:param_one).should == "paramOne"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should only include attributes with non-empty values" do
|
16
|
+
@object.to_api_params.should == { "paramOne" => "value1", "paramTwo" => "value2" }
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should try to call to_api_params on value" do
|
20
|
+
child_object = mock_api_object({ :param_one => "value1" })
|
21
|
+
|
22
|
+
@object.api_param_value(child_object).should == { "paramOne" => "value1" }
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should try to call to_api_params on all elements of value if value is Array" do
|
26
|
+
child_object1 = mock_api_object({ :param_one => "value1" })
|
27
|
+
child_object2 = mock_api_object({ :param_two => "value2" })
|
28
|
+
|
29
|
+
@object.api_param_value([child_object1, child_object2]).should == [{ "paramOne" => "value1" }, { "paramTwo" => "value2" }]
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should stringify attribute value if it does not respond to :to_api_params" do
|
33
|
+
@object.api_param_value(:value).should == "value"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HotelsPro::Api::Elements::PaxArray do
|
4
|
+
it "should return array of Pax elemements as api params" do
|
5
|
+
pax_arr = HotelsPro::Api::Elements::PaxArray.new
|
6
|
+
pax1 = HotelsPro::Api::Elements::Pax.new
|
7
|
+
pax2 = HotelsPro::Api::Elements::Pax.new
|
8
|
+
|
9
|
+
pax_arr.paxes << pax1
|
10
|
+
pax_arr.paxes << pax2
|
11
|
+
|
12
|
+
pax_arr.to_api_params.should == [pax1.to_api_params, pax2.to_api_params]
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HotelsPro::Api::Methods::AllocateHotelCode do
|
4
|
+
include RequestHelper
|
5
|
+
|
6
|
+
it "should build correct api params hash" do
|
7
|
+
method = HotelsPro::Api::Methods::AllocateHotelCode.new(
|
8
|
+
:search_id => "VO-40164625",
|
9
|
+
:hotel_code => "US6X5G"
|
10
|
+
)
|
11
|
+
|
12
|
+
method.to_api_params.should == {
|
13
|
+
"searchId" => "VO-40164625",
|
14
|
+
"hotelCode" => "US6X5G"
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return result when performed" do
|
19
|
+
HotelsPro::Stubs.allocate_hotel_code.response(fixture("allocate_hotel_code"))
|
20
|
+
|
21
|
+
method = HotelsPro::Api::Methods::AllocateHotelCode.new(
|
22
|
+
:search_id => "VO-40164625",
|
23
|
+
:hotel_code => "US6X5G"
|
24
|
+
)
|
25
|
+
|
26
|
+
result = method.perform
|
27
|
+
|
28
|
+
result.should be_instance_of HotelsPro::Api::Methods::AllocateHotelCode::Result
|
29
|
+
result.response_id.should == 5752179
|
30
|
+
result.total_found.should == 2
|
31
|
+
result.search_id.should == "VO-40164625"
|
32
|
+
result.hotel_code.should == "US6X5G"
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HotelsPro::Api::Methods::AmendHotelBooking do
|
4
|
+
include RequestHelper
|
5
|
+
|
6
|
+
it "should build correct api params hash" do
|
7
|
+
method = HotelsPro::Api::Methods::AmendHotelBooking.new(
|
8
|
+
:tracking_id => "XI-HW-82431210",
|
9
|
+
:check_in => Date.parse("2012-10-05"),
|
10
|
+
:check_out => Date.parse("2012-10-12"),
|
11
|
+
:lead_traveller_info => HotelsPro::Api::Elements::LeadTraveller.new(
|
12
|
+
:pax_info => HotelsPro::Api::Elements::Pax.new(:pax_type => "Adult", :title => "Mr", :first_name => "John", :last_name => "Doe"),
|
13
|
+
:nationality => "US"
|
14
|
+
),
|
15
|
+
:rooms => [
|
16
|
+
HotelsPro::Api::Elements::PaxArray.new(
|
17
|
+
:paxes => [
|
18
|
+
HotelsPro::Api::Elements::Pax.new(:pax_type => "Adult", :title => "Mr", :first_name => "John", :last_name => "Doe"),
|
19
|
+
HotelsPro::Api::Elements::Pax.new(:pax_type => "Adult", :age => 30, :title => "Mrs", :first_name => "Amanda", :last_name => "Doe")
|
20
|
+
]
|
21
|
+
)
|
22
|
+
],
|
23
|
+
:preferences => "nonSmoking",
|
24
|
+
:note => "I don't like french fries"
|
25
|
+
)
|
26
|
+
|
27
|
+
method.to_api_params.should == {
|
28
|
+
"trackingId" => "XI-HW-82431210",
|
29
|
+
"checkIn" => "2012-10-05",
|
30
|
+
"checkOut" => "2012-10-12",
|
31
|
+
"leadTravellerInfo" => {
|
32
|
+
"paxInfo" => {
|
33
|
+
"paxType" => "Adult",
|
34
|
+
"title" => "Mr",
|
35
|
+
"firstName" => "John",
|
36
|
+
"lastName" => "Doe"
|
37
|
+
},
|
38
|
+
"nationality" => "US"
|
39
|
+
},
|
40
|
+
"rooms" => [
|
41
|
+
[{ "paxType" => "Adult", "title" => "Mr", "firstName" => "John", "lastName" => "Doe" }, { "paxType" => "Adult", "age" => "30", "title" => "Mrs", "firstName" => "Amanda", "lastName" => "Doe" }]
|
42
|
+
],
|
43
|
+
"preferences" => "nonSmoking",
|
44
|
+
"note" => "I don't like french fries"
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should return result when performed" do
|
49
|
+
HotelsPro::Stubs.amend_hotel_booking.response(fixture('amend_hotel_booking'))
|
50
|
+
|
51
|
+
method = HotelsPro::Api::Methods::AmendHotelBooking.new(
|
52
|
+
:tracking_id => "XI-HW-82431210",
|
53
|
+
:check_in => Date.parse("2012-10-05"),
|
54
|
+
:check_out => Date.parse("2012-10-12"),
|
55
|
+
:lead_traveller_info => HotelsPro::Api::Elements::LeadTraveller.new(
|
56
|
+
:pax_info => HotelsPro::Api::Elements::Pax.new(:pax_type => "Adult", :title => "Mr", :first_name => "John", :last_name => "Doe"),
|
57
|
+
:nationality => "US"
|
58
|
+
),
|
59
|
+
:rooms => [
|
60
|
+
HotelsPro::Api::Elements::PaxArray.new(
|
61
|
+
:paxes => [
|
62
|
+
HotelsPro::Api::Elements::Pax.new(:pax_type => "Adult", :title => "Mr", :first_name => "John", :last_name => "Doe"),
|
63
|
+
HotelsPro::Api::Elements::Pax.new(:pax_type => "Adult", :age => 30, :title => "Mrs", :first_name => "Amanda", :last_name => "Doe")
|
64
|
+
]
|
65
|
+
)
|
66
|
+
],
|
67
|
+
:preferences => "nonSmoking",
|
68
|
+
:note => "I don't like french fries"
|
69
|
+
)
|
70
|
+
|
71
|
+
result = method.perform
|
72
|
+
|
73
|
+
result.should be_instance_of HotelsPro::Api::Methods::AmendHotelBooking::Result
|
74
|
+
result.response_id.should == 5762113
|
75
|
+
result.tracking_id.should == "XI-HW-82431210"
|
76
|
+
result.amend_status.should == "Pending"
|
77
|
+
result.note.should == "Your amendment request has been received. You will be contacted regarding amendment results by email or by message in our online system."
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HotelsPro::Api::Methods::CancelHotelBooking do
|
4
|
+
include RequestHelper
|
5
|
+
|
6
|
+
it "should build correct api params hash" do
|
7
|
+
method = HotelsPro::Api::Methods::CancelHotelBooking.new(
|
8
|
+
:tracking_id => "XI-HE-70838364"
|
9
|
+
)
|
10
|
+
|
11
|
+
method.to_api_params.should == {
|
12
|
+
"trackingId" => "XI-HE-70838364"
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return result when performed" do
|
17
|
+
HotelsPro::Stubs.cancel_hotel_booking.response(fixture('cancel_hotel_booking'))
|
18
|
+
|
19
|
+
method = HotelsPro::Api::Methods::CancelHotelBooking.new(
|
20
|
+
:tracking_id => "XI-HE-70838364"
|
21
|
+
)
|
22
|
+
|
23
|
+
result = method.perform
|
24
|
+
|
25
|
+
result.should be_instance_of HotelsPro::Api::Methods::CancelHotelBooking::Result
|
26
|
+
result.response_id.should == 5761559
|
27
|
+
result.tracking_id.should == "XI-HE-70838364"
|
28
|
+
result.agency_reference_number.should be_empty
|
29
|
+
result.booking_status.should == "Cancelled"
|
30
|
+
result.note.should == "Booking has been cancelled successfully."
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HotelsPro::Api::Methods::GetAvailableHotel do
|
4
|
+
include RequestHelper
|
5
|
+
|
6
|
+
it "should build correct api params hash" do
|
7
|
+
method = HotelsPro::Api::Methods::GetAvailableHotel.new(
|
8
|
+
:destination_id => "XXX",
|
9
|
+
:client_nationality => "US",
|
10
|
+
:currency => "EUR",
|
11
|
+
:check_in => Date.parse("2012-08-14"),
|
12
|
+
:check_out => Date.parse("2012-08-21"),
|
13
|
+
:rooms => [
|
14
|
+
HotelsPro::Api::Elements::PaxArray.new(
|
15
|
+
:paxes => [
|
16
|
+
HotelsPro::Api::Elements::Pax.new(:pax_type => "Adult"),
|
17
|
+
HotelsPro::Api::Elements::Pax.new(:pax_type => "Adult")
|
18
|
+
]
|
19
|
+
),
|
20
|
+
HotelsPro::Api::Elements::PaxArray.new(
|
21
|
+
:paxes => [
|
22
|
+
HotelsPro::Api::Elements::Pax.new(:pax_type => "Adult"),
|
23
|
+
HotelsPro::Api::Elements::Pax.new(:pax_type => "Child", :age => 10)
|
24
|
+
]
|
25
|
+
)
|
26
|
+
],
|
27
|
+
:filters => [
|
28
|
+
HotelsPro::Api::Elements::Filter.new(:filter_type => "hotelCode", :filter_value => "123"),
|
29
|
+
HotelsPro::Api::Elements::Filter.new(:filter_type => "limit", :filter_value => "10")
|
30
|
+
]
|
31
|
+
)
|
32
|
+
|
33
|
+
method.to_api_params.should == {
|
34
|
+
"destinationId" => "XXX",
|
35
|
+
"clientNationality" => "US",
|
36
|
+
"currency" => "EUR",
|
37
|
+
"checkIn" => "2012-08-14",
|
38
|
+
"checkOut" => "2012-08-21",
|
39
|
+
"rooms" => [
|
40
|
+
[{ "paxType" => "Adult" }, { "paxType" => "Adult" }],
|
41
|
+
[{ "paxType" => "Adult" }, { "paxType" => "Child", "age" => "10" }]
|
42
|
+
],
|
43
|
+
"filters" => [
|
44
|
+
{ "filterType" => "hotelCode", "filterValue" => "123" },
|
45
|
+
{ "filterType" => "limit", "filterValue" => "10" }
|
46
|
+
],
|
47
|
+
"onRequest" => "true"
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should return result when performed" do
|
52
|
+
HotelsPro::Stubs.get_available_hotel.response(fixture("get_available_hotel"))
|
53
|
+
|
54
|
+
method = HotelsPro::Api::Methods::GetAvailableHotel.new(
|
55
|
+
:destination_id => "XXX",
|
56
|
+
:client_nationality => "US",
|
57
|
+
:currency => "EUR",
|
58
|
+
:check_in => Date.parse("2012-08-14"),
|
59
|
+
:check_out => Date.parse("2012-08-21"),
|
60
|
+
:rooms => [
|
61
|
+
HotelsPro::Api::Elements::PaxArray.new(
|
62
|
+
:paxes => [
|
63
|
+
HotelsPro::Api::Elements::Pax.new(:pax_type => "Adult"),
|
64
|
+
HotelsPro::Api::Elements::Pax.new(:pax_type => "Adult")
|
65
|
+
]
|
66
|
+
),
|
67
|
+
HotelsPro::Api::Elements::PaxArray.new(
|
68
|
+
:paxes => [
|
69
|
+
HotelsPro::Api::Elements::Pax.new(:pax_type => "Adult"),
|
70
|
+
HotelsPro::Api::Elements::Pax.new(:pax_type => "Child", :age => 10)
|
71
|
+
]
|
72
|
+
)
|
73
|
+
]
|
74
|
+
)
|
75
|
+
|
76
|
+
result = method.perform
|
77
|
+
|
78
|
+
result.should be_instance_of HotelsPro::Api::Methods::GetAvailableHotel::Result
|
79
|
+
result.response_id.should == 4214740
|
80
|
+
result.total_found.should == 2
|
81
|
+
result.search_id.should == "SZ-91588250"
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HotelsPro::Api::Methods::GetBalance do
|
4
|
+
include RequestHelper
|
5
|
+
|
6
|
+
it "should build correct api params hash" do
|
7
|
+
method = HotelsPro::Api::Methods::GetBalance.new()
|
8
|
+
|
9
|
+
method.to_api_params.should == {}
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return result when performed" do
|
13
|
+
HotelsPro::Stubs.get_balance.response(fixture('get_balance'))
|
14
|
+
|
15
|
+
method = HotelsPro::Api::Methods::GetBalance.new()
|
16
|
+
|
17
|
+
result = method.perform
|
18
|
+
|
19
|
+
result.should be_instance_of HotelsPro::Api::Methods::GetBalance::Result
|
20
|
+
result.response_id.should == 5762226
|
21
|
+
result.currency.should == "0.00"
|
22
|
+
result.total_deposit.should == 0
|
23
|
+
result.total_booking_amount.should == 0
|
24
|
+
result.current_balance.should == 0
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HotelsPro::Api::Methods::GetHotelBookingStatus do
|
4
|
+
include RequestHelper
|
5
|
+
|
6
|
+
it "should build correct api params hash" do
|
7
|
+
method = HotelsPro::Api::Methods::GetHotelBookingStatus.new(
|
8
|
+
:tracking_id => "XI-HE-70838364"
|
9
|
+
)
|
10
|
+
|
11
|
+
method.to_api_params.should == {
|
12
|
+
"trackingId" => "XI-HE-70838364"
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return result when performed" do
|
17
|
+
HotelsPro::Stubs.get_hotel_booking_status.response(fixture('get_hotel_booking_status'))
|
18
|
+
|
19
|
+
method = HotelsPro::Api::Methods::GetHotelBookingStatus.new(
|
20
|
+
:tracking_id => "XI-HE-70838364"
|
21
|
+
)
|
22
|
+
|
23
|
+
result = method.perform
|
24
|
+
|
25
|
+
result.should be_instance_of HotelsPro::Api::Methods::GetHotelBookingStatus::Result
|
26
|
+
result.response_id.should == 5761428
|
27
|
+
result.tracking_id.should == "XI-HE-70838364"
|
28
|
+
result.hotel_booking_info.should be_instance_of HotelsPro::Api::Elements::BookInfo
|
29
|
+
result.hotel_booking_info.hotel_code.should == "US2HZR"
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HotelsPro::Api::Methods::GetHotelCancellationPolicy do
|
4
|
+
include RequestHelper
|
5
|
+
|
6
|
+
it "should build correct api params hash" do
|
7
|
+
method = HotelsPro::Api::Methods::GetHotelCancellationPolicy.new(
|
8
|
+
:tracking_id => "XI-HE-70838364"
|
9
|
+
)
|
10
|
+
|
11
|
+
method.to_api_params.should == {
|
12
|
+
"trackingId" => "XI-HE-70838364"
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return result when performed" do
|
17
|
+
HotelsPro::Stubs.get_hotel_cancellation_policy.response(fixture('get_hotel_cancellation_policy'))
|
18
|
+
|
19
|
+
method = HotelsPro::Api::Methods::GetHotelCancellationPolicy.new(
|
20
|
+
:tracking_id => "XI-HE-70838364"
|
21
|
+
)
|
22
|
+
|
23
|
+
result = method.perform
|
24
|
+
|
25
|
+
result.should be_instance_of HotelsPro::Api::Methods::GetHotelCancellationPolicy::Result
|
26
|
+
result.response_id.should == 5761637
|
27
|
+
result.tracking_id.should == "XI-HE-70838364"
|
28
|
+
result.agency_reference_number.should be_empty
|
29
|
+
result.cancellation_policy.size.should == 2
|
30
|
+
end
|
31
|
+
end
|