Skip to content

Commit c66221c

Browse files
author
przemyslaw kedzierski
committed
Add booking create with bookings_fees and bookings_taxes
1 parent 16e0e80 commit c66221c

File tree

4 files changed

+88
-2
lines changed

4 files changed

+88
-2
lines changed

content/reference/endpoints/bookings.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ POST /rentals/:rental_id/bookings
187187
{ bookings_write: "bookings_read-bookings_write" }
188188
] %>
189189

190+
You can pass booking additional parameters: `bookings_fees` and `bookings_taxes`:
191+
<%= render 'json_response', endpoint: "bookings", request: "request_with_fees_and_taxes",
192+
scopes: [
193+
{ bookings_write: "bookings_read-bookings_write_with_fees_and_taxes" }
194+
] %>
195+
You need to remember that sum of `bookings_fees` (`price * times_booked`) and `bookings_taxes` (`amount`) minus `discount` must equal the given `final_price`. Otherwise booking is not valid. Given `rental` (`rental_type` and `rental_id`) in `bookings_taxes` must belong to your account. Also `rentals_fee_id` must point to `rentals_fee` that belongs to you.
196+
190197
## Update a booking
191198

192199
Returns an updated booking identified by ID.

responses/bookings/bookings_read-bookings_write-scope.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
"bookings.rental": "https://www.bookingsync.com/api/v3/rentals/{bookings.rental}",
55
"bookings.client": "https://www.bookingsync.com/api/v3/clients/{bookings.client}",
66
"bookings.rental_agreement": "https://www.bookingsync.com/api/v3/rental_agreements/{bookings.rental_agreement}",
7-
"bookings.source": "https://www.bookingsync.com/api/v3/sources/{bookings.source}"
7+
"bookings.source": "https://www.bookingsync.com/api/v3/sources/{bookings.source}",
8+
"bookings.bookings_fees": "https://www.bookingsync.com/api/v3/bookings_fees/{bookings.bookings_fees}",
9+
"bookings.bookings_taxes": "https://www.bookingsync.com/api/v3/bookings_taxes/{bookings.bookings_taxes}",
10+
"bookings.bookings_tags": "https://www.bookingsync.com/api/v3/bookings_tags/{bookings.bookings_tags}"
811
},
912
"bookings": [
1013
{
@@ -13,7 +16,10 @@
1316
"rental": 16,
1417
"client": 37,
1518
"rental_agreement": null,
16-
"source": 1
19+
"source": null,
20+
"bookings_fees": [],
21+
"bookings_taxes": [],
22+
"bookings_tags": []
1723
},
1824
"id": 80,
1925
"start_at": "START_AT",
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"links": {
3+
"bookings.account": "https://www.bookingsync.com/api/v3/accounts/{bookings.account}",
4+
"bookings.rental": "https://www.bookingsync.com/api/v3/rentals/{bookings.rental}",
5+
"bookings.client": "https://www.bookingsync.com/api/v3/clients/{bookings.client}",
6+
"bookings.rental_agreement": "https://www.bookingsync.com/api/v3/rental_agreements/{bookings.rental_agreement}",
7+
"bookings.source": "https://www.bookingsync.com/api/v3/sources/{bookings.source}",
8+
"bookings.bookings_fees": "https://www.bookingsync.com/api/v3/bookings_fees/{bookings.bookings_fees}",
9+
"bookings.bookings_taxes": "https://www.bookingsync.com/api/v3/bookings_taxes/{bookings.bookings_taxes}",
10+
"bookings.bookings_tags": "https://www.bookingsync.com/api/v3/bookings_tags/{bookings.bookings_tags}"
11+
},
12+
"bookings": [
13+
{
14+
"links": {
15+
"account": 1,
16+
"rental": 16,
17+
"client": 37,
18+
"rental_agreement": null,
19+
"source": null,
20+
"bookings_fees": [10, 11],
21+
"bookings_taxes": [22, 23],
22+
"bookings_tags": []
23+
},
24+
"id": 80,
25+
"start_at": "START_AT",
26+
"end_at": "END_AT",
27+
"status": "Booked",
28+
"updated_at": "UPDATED_AT",
29+
"booked": true,
30+
"unavailable": false,
31+
"tentative_expires_at": null,
32+
"initial_price": "3000.0",
33+
"discount": "10%",
34+
"final_price": "2700.0",
35+
"downpayment": null,
36+
"paid_amount": "0.0",
37+
"currency": "USD",
38+
"notes": "",
39+
"adults": 5,
40+
"children": null,
41+
"bookings_payments_count": 0,
42+
"review_requests_count": 0,
43+
"locked": null,
44+
"created_at": "CREATED_AT",
45+
"canceled_at": null
46+
}
47+
],
48+
"meta": {
49+
}
50+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"bookings": [
3+
{
4+
"booked": true,
5+
"client_id": 37,
6+
"adults": 5,
7+
"currency": "USD",
8+
"discount": "10%",
9+
"final_price": "2930.0",
10+
"initial_price": "3000.0",
11+
"start_at": "START_AT",
12+
"end_at": "END_AT",
13+
"bookings_fees": [
14+
{ "price": "50", "times_booked": "2", "rentals_fee_id": "10" },
15+
{ "price": "30", "times_booked": "1", "rentals_fee_id": "10" }
16+
],
17+
"bookings_taxes": [
18+
{ "taxable_type": "Rental", "taxable_id": "1", "amount": "60", "tax_id": "5" },
19+
{ "taxable_type": "Rental", "taxable_id": "1", "amount": "40", "tax_id": "7" }
20+
]
21+
}
22+
]
23+
}

0 commit comments

Comments
 (0)