bookingsync-api 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile +2 -1
- data/Guardfile +3 -6
- data/README.md +11 -3
- data/bookingsync-api.gemspec +2 -2
- data/lib/bookingsync/api.rb +0 -2
- data/lib/bookingsync/api/client.rb +151 -54
- data/lib/bookingsync/api/client/amenities.rb +22 -0
- data/lib/bookingsync/api/client/billing_addresses.rb +22 -0
- data/lib/bookingsync/api/client/bookings.rb +7 -9
- data/lib/bookingsync/api/client/bookings_payments.rb +22 -0
- data/lib/bookingsync/api/client/clients.rb +43 -0
- data/lib/bookingsync/api/client/destinations.rb +22 -0
- data/lib/bookingsync/api/client/inquiries.rb +2 -2
- data/lib/bookingsync/api/client/payments.rb +53 -0
- data/lib/bookingsync/api/client/periods.rb +54 -0
- data/lib/bookingsync/api/client/photos.rb +22 -0
- data/lib/bookingsync/api/client/rates.rb +23 -0
- data/lib/bookingsync/api/client/rates_rules.rb +22 -0
- data/lib/bookingsync/api/client/rates_tables.rb +53 -0
- data/lib/bookingsync/api/client/rental_agreements.rb +50 -0
- data/lib/bookingsync/api/client/rentals.rb +39 -1
- data/lib/bookingsync/api/client/reviews.rb +31 -0
- data/lib/bookingsync/api/client/seasons.rb +53 -0
- data/lib/bookingsync/api/client/special_offers.rb +54 -0
- data/lib/bookingsync/api/relation.rb +87 -0
- data/lib/bookingsync/api/resource.rb +58 -0
- data/lib/bookingsync/api/response.rb +79 -0
- data/lib/bookingsync/api/serializer.rb +100 -0
- data/lib/bookingsync/api/version.rb +1 -1
- data/spec/bookingsync/api/client/amenities_spec.rb +12 -0
- data/spec/bookingsync/api/client/billing_addresses_spec.rb +12 -0
- data/spec/bookingsync/api/client/billings_payments_spec.rb +12 -0
- data/spec/bookingsync/api/client/bookings_spec.rb +10 -8
- data/spec/bookingsync/api/client/clients_spec.rb +55 -0
- data/spec/bookingsync/api/client/destinations_spec.rb +12 -0
- data/spec/bookingsync/api/client/inquiries_spec.rb +1 -1
- data/spec/bookingsync/api/client/payments_spec.rb +56 -0
- data/spec/bookingsync/api/client/periods_spec.rb +61 -0
- data/spec/bookingsync/api/client/photos_spec.rb +12 -0
- data/spec/bookingsync/api/client/rates_rules_spec.rb +13 -0
- data/spec/bookingsync/api/client/rates_spec.rb +12 -0
- data/spec/bookingsync/api/client/rates_tables_spec.rb +59 -0
- data/spec/bookingsync/api/client/rental_agreements_spec.rb +64 -0
- data/spec/bookingsync/api/client/rentals_spec.rb +56 -6
- data/spec/bookingsync/api/client/reviews_spec.rb +33 -0
- data/spec/bookingsync/api/client/seasons_spec.rb +61 -0
- data/spec/bookingsync/api/client/special_offers_spec.rb +63 -0
- data/spec/bookingsync/api/client_spec.rb +31 -10
- data/spec/bookingsync/api/relation_spec.rb +72 -0
- data/spec/bookingsync/api/resource_spec.rb +79 -0
- data/spec/bookingsync/api/response_spec.rb +66 -0
- data/spec/cassettes/BookingSync_API_Client_Amenities/_amenities/returns_amenities.yml +72 -0
- data/spec/cassettes/BookingSync_API_Client_BillingAddresses/_billing_addresses/returns_billing_addresses.yml +65 -0
- data/spec/cassettes/BookingSync_API_Client_Bookings/_bookings/pagination/with_a_block/yields_block_with_batch_of_bookings.yml +12 -12
- data/spec/cassettes/BookingSync_API_Client_Bookings/_bookings/pagination/with_auto_paginate_true/returns_all_bookings_joined_from_many_requests.yml +12 -12
- data/spec/cassettes/BookingSync_API_Client_Bookings/_bookings/pagination/with_per_page_setting/returns_limited_number_of_bookings.yml +3 -3
- data/spec/cassettes/BookingSync_API_Client_Bookings/_clients/returns_clients.yml +66 -0
- data/spec/cassettes/BookingSync_API_Client_Bookings/_create_booking/creates_a_booking.yml +1 -1
- data/spec/cassettes/BookingSync_API_Client_Bookings/_create_client/creates_a_new_client.yml +64 -0
- data/spec/cassettes/BookingSync_API_Client_Bookings/_edit_booking/updates_given_booking_by_ID.yml +18 -14
- data/spec/cassettes/BookingSync_API_Client_Bookings/_edit_client/updates_given_client_by_ID.yml +62 -0
- data/spec/cassettes/BookingSync_API_Client_BookingsPayments/_bookings_payments/returns_bookings_payments.yml +65 -0
- data/spec/cassettes/BookingSync_API_Client_Destinations/_destinations/returns_destinations.yml +64 -0
- data/spec/cassettes/BookingSync_API_Client_Inquiries/_create_inquiry/creates_a_new_inquiry.yml +1 -1
- data/spec/cassettes/BookingSync_API_Client_Inquiries/_inquiries/returns_inquiries.yml +1 -1
- data/spec/cassettes/BookingSync_API_Client_Payments/_cancel_payment/cancels_given_payment.yml +57 -0
- data/spec/cassettes/BookingSync_API_Client_Payments/_create_payment/creates_a_new_payment.yml +63 -0
- data/spec/cassettes/BookingSync_API_Client_Payments/_edit_payment/updates_given_payment_by_ID.yml +61 -0
- data/spec/cassettes/BookingSync_API_Client_Payments/_payments/returns_payments.yml +64 -0
- data/spec/cassettes/BookingSync_API_Client_Periods/_create_period/creates_a_new_period.yml +63 -0
- data/spec/cassettes/BookingSync_API_Client_Periods/_delete_period/deletes_given_period.yml +70 -0
- data/spec/cassettes/BookingSync_API_Client_Periods/_edit_period/updates_given_period_by_ID.yml +61 -0
- data/spec/cassettes/BookingSync_API_Client_Periods/_periods/returns_periods.yml +64 -0
- data/spec/cassettes/BookingSync_API_Client_Photos/_photos/returns_photos.yml +72 -0
- data/spec/cassettes/BookingSync_API_Client_Rates/_rates/returns_rates.yml +64 -0
- data/spec/cassettes/BookingSync_API_Client_RatesRules/_rates_rules/returns_rates_rules.yml +64 -0
- data/spec/cassettes/BookingSync_API_Client_RatesTables/_create_rates_table/creates_a_new_rates_table.yml +64 -0
- data/spec/cassettes/BookingSync_API_Client_RatesTables/_delete_rates_table/deletes_given_rates_table.yml +57 -0
- data/spec/cassettes/BookingSync_API_Client_RatesTables/_edit_rates_table/updates_given_rates_table_by_ID.yml +62 -0
- data/spec/cassettes/BookingSync_API_Client_RatesTables/_rates_tables/returns_rates_tables.yml +74 -0
- data/spec/cassettes/BookingSync_API_Client_RentalAgreements/_create_rental_agreement/creates_a_new_rental_agreement.yml +63 -0
- data/spec/cassettes/BookingSync_API_Client_RentalAgreements/_create_rental_agreement_for_booking/creates_a_new_rental_agreement.yml +63 -0
- data/spec/cassettes/BookingSync_API_Client_RentalAgreements/_create_rental_agreement_for_rental/creates_a_new_rental_agreement.yml +63 -0
- data/spec/cassettes/BookingSync_API_Client_RentalAgreements/_rental_agreements/returns_rental_agreements.yml +64 -0
- data/spec/cassettes/BookingSync_API_Client_Rentals/_cancel_rental/cancels_given_rental.yml +57 -0
- data/spec/cassettes/BookingSync_API_Client_Rentals/_create_rental/creates_a_new_rental.yml +64 -0
- data/spec/cassettes/BookingSync_API_Client_Rentals/_edit_rental/updates_given_rental_by_ID.yml +64 -0
- data/spec/cassettes/BookingSync_API_Client_Rentals/_rental/returns_a_single_rental.yml +67 -0
- data/spec/cassettes/BookingSync_API_Client_Rentals/_rentals/links/returns_associated_photos.yml +152 -0
- data/spec/cassettes/BookingSync_API_Client_Rentals/_rentals/links/returns_links_to_associated_resources.yml +91 -0
- data/spec/cassettes/BookingSync_API_Client_Rentals/_rentals/returns_rentals.yml +45 -20
- data/spec/cassettes/BookingSync_API_Client_Reviews/_create_review/creates_a_new_review.yml +64 -0
- data/spec/cassettes/BookingSync_API_Client_Reviews/_reviews/returns_reviews.yml +83 -0
- data/spec/cassettes/BookingSync_API_Client_Seasons/_create_season/creates_a_new_season.yml +64 -0
- data/spec/cassettes/BookingSync_API_Client_Seasons/_delete_season/deletes_given_season.yml +57 -0
- data/spec/cassettes/BookingSync_API_Client_Seasons/_edit_season/updates_given_season_by_ID.yml +62 -0
- data/spec/cassettes/BookingSync_API_Client_Seasons/_seasons/returns_seasons.yml +74 -0
- data/spec/cassettes/BookingSync_API_Client_SpecialOffers/_create_special_offer/creates_a_new_special_offer.yml +63 -0
- data/spec/cassettes/BookingSync_API_Client_SpecialOffers/_delete_special_offer/deletes_given_special_offer.yml +57 -0
- data/spec/cassettes/BookingSync_API_Client_SpecialOffers/_edit_special_offer/updates_given_special_offer_by_ID.yml +61 -0
- data/spec/cassettes/{BookingSync_API_Client_Rentals/_rentals/with_specified_fields_in_options/returns_rentals_with_filtered_fields.yml → BookingSync_API_Client_SpecialOffers/_special_offers/returns_special_offers.yml} +17 -10
- data/spec/spec_helper.rb +1 -0
- metadata +143 -7
- data/lib/bookingsync/ext/resource.rb +0 -9
@@ -0,0 +1,12 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BookingSync::API::Client::Amenities do
|
4
|
+
let(:client) { BookingSync::API::Client.new(test_access_token) }
|
5
|
+
|
6
|
+
describe ".amenities", :vcr do
|
7
|
+
it "returns amenities" do
|
8
|
+
expect(client.amenities).not_to be_empty
|
9
|
+
assert_requested :get, bs_url("amenities")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BookingSync::API::Client::BillingAddresses do
|
4
|
+
let(:client) { BookingSync::API::Client.new(test_access_token) }
|
5
|
+
|
6
|
+
describe ".billing_addresses", :vcr do
|
7
|
+
it "returns billing_addresses" do
|
8
|
+
expect(client.billing_addresses).not_to be_empty
|
9
|
+
assert_requested :get, bs_url("billing_addresses")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BookingSync::API::Client::BookingsPayments do
|
4
|
+
let(:client) { BookingSync::API::Client.new(test_access_token) }
|
5
|
+
|
6
|
+
describe ".bookings_payments", :vcr do
|
7
|
+
it "returns bookings_payments" do
|
8
|
+
expect(client.bookings_payments).not_to be_empty
|
9
|
+
assert_requested :get, bs_url("bookings_payments")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -5,7 +5,7 @@ describe BookingSync::API::Client::Bookings do
|
|
5
5
|
|
6
6
|
describe ".bookings", :vcr do
|
7
7
|
it "returns bookings" do
|
8
|
-
expect(client.bookings).not_to
|
8
|
+
expect(client.bookings).not_to be_empty
|
9
9
|
assert_requested :get, bs_url("bookings")
|
10
10
|
end
|
11
11
|
|
@@ -60,23 +60,25 @@ describe BookingSync::API::Client::Bookings do
|
|
60
60
|
|
61
61
|
describe ".edit_booking", :vcr do
|
62
62
|
it "updates given booking by ID" do
|
63
|
-
client.edit_booking(50, {
|
63
|
+
client.edit_booking(50, {end_at: "2019-03-25 21:45:00 UTC"})
|
64
64
|
assert_requested :put, bs_url("bookings/50"),
|
65
|
-
body: {bookings: [{
|
65
|
+
body: {bookings: [{end_at: "2019-03-25 21:45:00 UTC"}]}.to_json
|
66
66
|
end
|
67
67
|
|
68
|
-
it "returns
|
68
|
+
it "returns updated booking" do
|
69
69
|
VCR.use_cassette('BookingSync_API_Client_Bookings/_edit_booking/updates_given_booking_by_ID') do
|
70
|
-
|
70
|
+
booking = client.edit_booking(50, {end_at: "2019-03-25 21:45:00 UTC"})
|
71
|
+
expect(booking).to be_kind_of(BookingSync::API::Resource)
|
72
|
+
expect(booking.end_at).to eq(Time.parse("2019-03-25 21:45:00 UTC"))
|
71
73
|
end
|
72
74
|
end
|
73
75
|
|
74
76
|
it "updates given booking by Resource object" do
|
75
77
|
VCR.use_cassette('BookingSync_API_Client_Bookings/_edit_booking/updates_given_booking_by_ID') do
|
76
|
-
resource =
|
77
|
-
client.edit_booking(resource, {
|
78
|
+
resource = BookingSync::API::Resource.new(nil, {id: 50})
|
79
|
+
client.edit_booking(resource, {end_at: "2019-03-25 21:45:00 UTC"})
|
78
80
|
assert_requested :put, bs_url("bookings/50"),
|
79
|
-
body: {bookings: [{
|
81
|
+
body: {bookings: [{end_at: "2019-03-25 21:45:00 UTC"}]}.to_json
|
80
82
|
end
|
81
83
|
end
|
82
84
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BookingSync::API::Client::Bookings do
|
4
|
+
let(:api) { BookingSync::API::Client.new(test_access_token) }
|
5
|
+
|
6
|
+
describe ".clients", :vcr do
|
7
|
+
it "returns clients" do
|
8
|
+
expect(api.clients).not_to be_empty
|
9
|
+
assert_requested :get, bs_url("clients")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe ".create_client", :vcr do
|
14
|
+
let(:attributes) {{
|
15
|
+
fullname: "John Smith",
|
16
|
+
phone: "11111111",
|
17
|
+
mobile: "33333333",
|
18
|
+
email: "smith@example.com",
|
19
|
+
fax: "1111111",
|
20
|
+
address1: "Italy",
|
21
|
+
country_code: "IT",
|
22
|
+
city: "Rome"
|
23
|
+
}}
|
24
|
+
|
25
|
+
it "creates a new client" do
|
26
|
+
api.create_client(attributes)
|
27
|
+
assert_requested :post, bs_url("clients"),
|
28
|
+
body: {clients: [attributes]}.to_json
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns newly created client" do
|
32
|
+
VCR.use_cassette('BookingSync_API_Client_Bookings/_create_client/creates_a_new_client') do
|
33
|
+
client = api.create_client(attributes)
|
34
|
+
expect(client.email).to eql("smith@example.com")
|
35
|
+
expect(client.fullname).to eql("John Smith")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe ".edit_client", :vcr do
|
41
|
+
it "updates given client by ID" do
|
42
|
+
api.edit_client(2, fullname: "Gary Smith")
|
43
|
+
assert_requested :put, bs_url("clients/2"),
|
44
|
+
body: {clients: [{fullname: "Gary Smith"}]}.to_json
|
45
|
+
end
|
46
|
+
|
47
|
+
it "returns updated client" do
|
48
|
+
VCR.use_cassette('BookingSync_API_Client_Bookings/_edit_client/updates_given_client_by_ID') do
|
49
|
+
client = api.edit_client(2, fullname: "Gary Smith")
|
50
|
+
expect(client).to be_kind_of(BookingSync::API::Resource)
|
51
|
+
expect(client.fullname).to eq("Gary Smith")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BookingSync::API::Client::Destinations do
|
4
|
+
let(:client) { BookingSync::API::Client.new(test_access_token) }
|
5
|
+
|
6
|
+
describe ".destinations", :vcr do
|
7
|
+
it "returns destinations" do
|
8
|
+
expect(client.destinations).not_to be_empty
|
9
|
+
assert_requested :get, bs_url("destinations")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BookingSync::API::Client::Payments do
|
4
|
+
let(:api) { BookingSync::API::Client.new(test_access_token) }
|
5
|
+
|
6
|
+
describe ".payments", :vcr do
|
7
|
+
it "returns payments" do
|
8
|
+
expect(api.payments).not_to be_empty
|
9
|
+
assert_requested :get, bs_url("payments")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe ".create_payment", :vcr do
|
14
|
+
let(:attributes) {{
|
15
|
+
amount: 200,
|
16
|
+
kind: 'cash'
|
17
|
+
}}
|
18
|
+
|
19
|
+
it "creates a new payment" do
|
20
|
+
api.create_payment(1, attributes)
|
21
|
+
assert_requested :post, bs_url("payments"),
|
22
|
+
body: { booking_id: 1, payments: [attributes]}.to_json
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns newly created payment" do
|
26
|
+
VCR.use_cassette('BookingSync_API_Client_Payments/_create_payment/creates_a_new_payment') do
|
27
|
+
payment = api.create_payment(1, attributes)
|
28
|
+
expect(payment.amount).to eql(200)
|
29
|
+
expect(payment.kind).to eql("cash")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe ".edit_payment", :vcr do
|
35
|
+
it "updates given payment by ID" do
|
36
|
+
api.edit_payment(2, kind: 'cash')
|
37
|
+
assert_requested :put, bs_url("payments/2"),
|
38
|
+
body: {payments: [{kind: 'cash'}]}.to_json
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns updated payment" do
|
42
|
+
VCR.use_cassette('BookingSync_API_Client_Payments/_edit_payment/updates_given_payment_by_ID') do
|
43
|
+
payment = api.edit_payment(2, kind: 'cash')
|
44
|
+
expect(payment).to be_kind_of(BookingSync::API::Resource)
|
45
|
+
expect(payment.kind).to eq('cash')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe ".cancel_payment", :vcr do
|
51
|
+
it "cancels given payment" do
|
52
|
+
api.cancel_payment(10)
|
53
|
+
assert_requested :delete, bs_url("payments/10")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BookingSync::API::Client::Periods do
|
4
|
+
|
5
|
+
let(:client) { BookingSync::API::Client.new(test_access_token) }
|
6
|
+
|
7
|
+
describe ".periods", :vcr do
|
8
|
+
it "returns periods" do
|
9
|
+
expect(client.periods).not_to be_empty
|
10
|
+
assert_requested :get, bs_url("periods")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".create_period", :vcr do
|
15
|
+
let(:attributes) { {
|
16
|
+
start_at: "2013-04-10",
|
17
|
+
end_at: "2013-04-22"
|
18
|
+
} }
|
19
|
+
|
20
|
+
it "creates a new period" do
|
21
|
+
client.create_period(9, attributes)
|
22
|
+
assert_requested :post, bs_url("periods"),
|
23
|
+
body: { season_id: 9, periods: [attributes] }.to_json
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns newly created period" do
|
27
|
+
VCR.use_cassette('BookingSync_API_Client_Periods/_create_period/creates_a_new_period') do
|
28
|
+
period = client.create_period(9, attributes)
|
29
|
+
expect(period.start_at).to eql(Time.parse(attributes[:start_at]))
|
30
|
+
expect(period.end_at).to eql(Time.parse(attributes[:end_at]))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ".edit_period", :vcr do
|
36
|
+
let(:attributes) {
|
37
|
+
{ end_at: '2014-07-15' }
|
38
|
+
}
|
39
|
+
|
40
|
+
it "updates given period by ID" do
|
41
|
+
client.edit_period(6, attributes)
|
42
|
+
assert_requested :put, bs_url("periods/6"),
|
43
|
+
body: { periods: [attributes] }.to_json
|
44
|
+
end
|
45
|
+
|
46
|
+
it "returns updated period" do
|
47
|
+
VCR.use_cassette('BookingSync_API_Client_Periods/_edit_period/updates_given_period_by_ID') do
|
48
|
+
period = client.edit_period(6, attributes)
|
49
|
+
expect(period).to be_kind_of(BookingSync::API::Resource)
|
50
|
+
expect(period.end_at).to eq(Time.parse(attributes[:end_at]))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe ".delete_period", :vcr do
|
56
|
+
it "deletes given period" do
|
57
|
+
client.delete_period(10)
|
58
|
+
assert_requested :delete, bs_url("periods/10")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BookingSync::API::Client::Photos do
|
4
|
+
let(:client) { BookingSync::API::Client.new(test_access_token) }
|
5
|
+
|
6
|
+
describe ".photos", :vcr do
|
7
|
+
it "returns photos" do
|
8
|
+
expect(client.photos).not_to be_empty
|
9
|
+
assert_requested :get, bs_url("photos")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BookingSync::API::Client::RatesRules do
|
4
|
+
|
5
|
+
let(:client) { BookingSync::API::Client.new(test_access_token) }
|
6
|
+
|
7
|
+
describe ".rates_rules", :vcr do
|
8
|
+
it "returns rates rules" do
|
9
|
+
expect(client.rates_rules).not_to be_empty
|
10
|
+
assert_requested :get, bs_url("rates_rules")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BookingSync::API::Client::Rates do
|
4
|
+
let(:client) { BookingSync::API::Client.new(test_access_token) }
|
5
|
+
|
6
|
+
describe ".rates", :vcr do
|
7
|
+
it "returns rates" do
|
8
|
+
expect(client.rates).not_to be_empty
|
9
|
+
assert_requested :get, bs_url("rates")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BookingSync::API::Client::RatesTables do
|
4
|
+
|
5
|
+
let(:client) { BookingSync::API::Client.new(test_access_token) }
|
6
|
+
|
7
|
+
describe ".rates_tables", :vcr do
|
8
|
+
it "returns rates tables" do
|
9
|
+
expect(client.rates_tables).not_to be_empty
|
10
|
+
assert_requested :get, bs_url("rates_tables")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".create_rates_table", :vcr do
|
15
|
+
let(:attributes) {
|
16
|
+
{ name: 'New rate table' }
|
17
|
+
}
|
18
|
+
|
19
|
+
it "creates a new rates_table" do
|
20
|
+
client.create_rates_table(attributes)
|
21
|
+
assert_requested :post, bs_url("rates_tables"),
|
22
|
+
body: { rates_tables: [attributes] }.to_json
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns newly created rates_table" do
|
26
|
+
VCR.use_cassette('BookingSync_API_Client_RatesTables/_create_rates_table/creates_a_new_rates_table') do
|
27
|
+
rates_table = client.create_rates_table(attributes)
|
28
|
+
expect(rates_table.name).to eql(attributes[:name])
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe ".edit_rates_table", :vcr do
|
34
|
+
let(:attributes) {
|
35
|
+
{ name: 'Updated rate table' }
|
36
|
+
}
|
37
|
+
|
38
|
+
it "updates given rates_table by ID" do
|
39
|
+
client.edit_rates_table(11, attributes)
|
40
|
+
assert_requested :put, bs_url("rates_tables/11"),
|
41
|
+
body: { rates_tables: [attributes] }.to_json
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns updated rates_table" do
|
45
|
+
VCR.use_cassette('BookingSync_API_Client_RatesTables/_edit_rates_table/updates_given_rates_table_by_ID') do
|
46
|
+
rates_table = client.edit_rates_table(11, attributes)
|
47
|
+
expect(rates_table).to be_kind_of(BookingSync::API::Resource)
|
48
|
+
expect(rates_table.name).to eql(attributes[:name])
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe ".delete_rates_table", :vcr do
|
54
|
+
it "deletes given rates_table" do
|
55
|
+
client.delete_rates_table(7)
|
56
|
+
assert_requested :delete, bs_url("rates_tables/7")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BookingSync::API::Client::RentalAgreements do
|
4
|
+
let(:client) { BookingSync::API::Client.new(test_access_token) }
|
5
|
+
let(:attributes) {
|
6
|
+
{ body: "Lorem ipsum" }
|
7
|
+
}
|
8
|
+
|
9
|
+
describe ".rental_agreements", :vcr do
|
10
|
+
it "returns rental agreements" do
|
11
|
+
expect(client.rental_agreements).not_to be_empty
|
12
|
+
assert_requested :get, bs_url("rental_agreements")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe ".create_rental_agreement", :vcr do
|
17
|
+
it "creates a new rental agreement" do
|
18
|
+
client.create_rental_agreement(attributes)
|
19
|
+
assert_requested :post, bs_url("rental_agreements"),
|
20
|
+
body: { rental_agreements: [attributes] }.to_json
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns newly created rental agreement" do
|
24
|
+
VCR.use_cassette('BookingSync_API_Client_RentalAgreements/_create_rental_agreement/creates_a_new_rental_agreement') do
|
25
|
+
rental_agreement = client.create_rental_agreement(attributes)
|
26
|
+
expect(rental_agreement.body).to eql(attributes[:body])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe ".create_rental_agreement_for_booking", :vcr do
|
32
|
+
let(:booking_id) { 2 }
|
33
|
+
|
34
|
+
it "creates a new rental agreement" do
|
35
|
+
client.create_rental_agreement_for_booking(booking_id, attributes)
|
36
|
+
assert_requested :post, bs_url("rental_agreements"),
|
37
|
+
body: { booking_id: booking_id, rental_agreements: [attributes] }.to_json
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns newly created rental agreement" do
|
41
|
+
VCR.use_cassette('BookingSync_API_Client_RentalAgreements/_create_rental_agreement_for_booking/creates_a_new_rental_agreement') do
|
42
|
+
rental_agreement = client.create_rental_agreement_for_booking(booking_id, attributes)
|
43
|
+
expect(rental_agreement.body).to eql(attributes[:body])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe ".create_rental_agreement_for_rental", :vcr do
|
49
|
+
let(:rental_id) { 20 }
|
50
|
+
|
51
|
+
it "creates a new rental agreement" do
|
52
|
+
client.create_rental_agreement_for_rental(rental_id, attributes)
|
53
|
+
assert_requested :post, bs_url("rental_agreements"),
|
54
|
+
body: { rental_id: rental_id, rental_agreements: [attributes] }.to_json
|
55
|
+
end
|
56
|
+
|
57
|
+
it "returns newly created rental agreement" do
|
58
|
+
VCR.use_cassette('BookingSync_API_Client_RentalAgreements/_create_rental_agreement_for_rental/creates_a_new_rental_agreement') do
|
59
|
+
rental_agreement = client.create_rental_agreement_for_rental(rental_id, attributes)
|
60
|
+
expect(rental_agreement.body).to eql(attributes[:body])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|