### Vhost Configuration
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/guides/getting-started-with-php.md
Example Apache Vhost configuration for setting up a local development environment.
```apache
ServerName bsa-rest-php.dev
DocumentRoot /var/www/rest-request-php/examples/api-v3/
AllowOverride All
Order Allow,Deny
Allow from All
```
--------------------------------
### Installation
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/README.md
Command to install project dependencies.
```bash
bundle install
```
--------------------------------
### Customize availability maps - Example 2
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/availabilities.md
Mapping parameters allow to customize availability start point and status display.
```http
GET /availabilities/1?include_tentative=false&boolean=true&from=20140324
```
--------------------------------
### Customize availability maps - Example 1
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/availabilities.md
Mapping parameters allow to customize availability start point and status display.
```http
GET /availabilities?include_tentative=false&boolean=true&from=20140324
```
--------------------------------
### cURL POST Request Example
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/index.md
Example of how to make a POST request to create a rental using cURL.
```bash
curl --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' --header 'Content-Type: application/vnd.api+json'
--data '{"rentals":[{"name":"Name"}]}' https://www.bookingsync.com/api/v3/rentals
```
--------------------------------
### Install github_changelog_generator
Source: https://github.com/bookingsync/bookingsync-api-docs/wiki/How-to-release-a-new-version
Command to install the github_changelog_generator gem.
```bash
gem install github_changelog_generator
```
--------------------------------
### List applications
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/applications.md
List all installed applications for a given account.
```http
GET /applications
```
--------------------------------
### Live Quote Response Example
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/guides/pricing-concepts.md
Example JSON response from the /rentals/search endpoint when requesting a live quote for a rental, including price breakdown with taxes and fees.
```json
{
"rentals": [
{
"id": 1,
"currency": "EUR",
"damage_deposit": 35.5,
"final_price": 858.33,
"initial_price": 700.0,
"price_details": {
"taxes": [
{
"name": {
"en": "VAT"
},
"percentage": "10.0",
"amount": "58.33",
"taxable_type": "Rental",
"taxable_id": 2,
"tax_id": 1,
"included": false
}
],
"fees": [
{
"name": {
"en": "some fee"
},
"required": true,
"price": "100.0",
"quantity": 1,
"id": 10,
"rentals_fee_id": 12
}
]
},
"price_to_pay_now": 858.33,
"taxes": [
{
"name": {
"en": "VAT"
},
"percentage": "10.0",
"amount": "58.33"
}
],
"updated_at": "2014-01-21T11:46:15Z",
"links": {
"rentals_fees": "http://www.bookingsync.com/api/v3/rentals_fees/{rentals.rentals_fees}"
}
}
]
}
```
--------------------------------
### Ruby Signature Computation Example
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/guides/webhook-subscriptions.md
Example code in Ruby to compute the X-Content-Signature header value.
```ruby
encoded_body = Base64.encode64(json_body) # assuming `json_body` comes from the request
OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha1"), YOUR_APPLICATION_SECRET, encoded_body)
```
--------------------------------
### cURL PUT Request Example
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/index.md
Example of how to make a PUT request to update a rental using cURL.
```bash
curl --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' --header 'Content-Type: application/vnd.api+json'
--request PUT --data '{"rentals":[{"name":"New Name"}]}' https://www.bookingsync.com/api/v3/rentals/RENTAL_ID
```
--------------------------------
### Get Client Credential Token with CURL
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/guides/read-all-authorized-accounts-at-once.md
Example using CURL to make a POST request to get an authentication token.
```bash
curl -X POST -d "client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=client_credentials" "https://www.bookingsync.com/oauth/token"
```
--------------------------------
### Midterm Rate Map Example
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/guides/understanding-midterm-pricing.md
An example of a midterm rate map object, showing the start date and a string of prices for consecutive days.
```json
{
"start_date": "2020-05-02",
"map": "0,0,0,0,0,100,100,100,100,100,100,100,100,100,100,50,50,50,50,50,50,50,50,50,50,300,300,100,100,100,100,100,100,100,100,100,100,0,100,100,100,100,100,100,100,100,100,100,50,50,50,50,50,50,50,50,50,50,300,300,100,100,100,100,100,100,100,100,100,100",
...
}
```
--------------------------------
### Sideloading Associations Example
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/index.md
Example of how to sideload associations in a request to reduce the number of API calls.
```http
GET https://www.bookingsync.com/api/v3/rentals?include=availability
```
--------------------------------
### Limiting Fields Example
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/index.md
Example of how to limit the fields returned in a collection request.
```http
GET https://www.bookingsync.com/api/v3/accounts?fields=id,business_name
```
--------------------------------
### Rate Limiting Header Example
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/index.md
Example of the headers returned to indicate rate limiting information.
```text
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1395140400
```
--------------------------------
### Pagination Link Header Example
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/index.md
Example of the 'Link' header format for paginated responses, including total pages.
```text
Link: ; rel="first", ; rel="next", ; rel="last"
X-Total-Pages: 3
```
--------------------------------
### Webhook Request Header Example
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/guides/webhook-subscriptions.md
An example of the expected header format for incoming webhook requests.
```json
{
"content_type": "application/json",
"X-Content-Signature": "SIGNATURE",
"user_agent": "BookingSync Webhook Delivery"
}
```
--------------------------------
### Example JSON Request
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/layouts/json_response.html
An example of a JSON request structure.
```json
{
"key": "value"
}
```
--------------------------------
### Example Webhook Request Body (client_created event)
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/guides/webhook-subscriptions.md
A concrete example of a webhook request body for the 'client_created' event.
```json
{
"account_id": 1059638630,
"event": "client_created",
"resource": {
"links": {
"clients.account": "https://www.bookingsync.com/api/v3/accounts/{clients.account}"
},
"client": {
"links": {
"account": 1059638630
},
"id": 995923932,
"addresses": [],
"emails": [{"label": "default", "email": "client_5@example.com"}],
"phones": [],
"created_at": "2017-10-10T11:00:00Z",
"updated_at": "2017-10-10T11:00:00Z",
"fullname": "Robt Braun",
"firstname": "",
"lastname": "",
"notes": null,
"preferred_locale": null,
"passport": null,
"company": "",
"vat_number": ""
}
}
```
--------------------------------
### cURL DELETE Request Example
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/index.md
Example of how to make a DELETE request to remove a rental using cURL.
```bash
curl --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' --request DELETE
https://www.bookingsync.com/api/v3/rentals/RENTAL_ID
```
--------------------------------
### Search LOS records example
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/los_records.md
An example of how to search for LOS records using query parameters.
```http
GET /los_records?rental_id=1&kinds=rental_price_before_special_offers,rental_price&exchange_currency_to=EUR
```
--------------------------------
### Destroy a rental
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/rentals.md
This example shows how to delete a rental using the DELETE method.
```http
DELETE /rentals/:rental_id
```
--------------------------------
### Get a single application
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/applications.md
Returns a single application identified by ID.
```http
GET /applications/:application_id
```
--------------------------------
### Create a new client
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/clients.md
Returns a newly created client.
```http
POST /clients
```
--------------------------------
### Development Server
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/README.md
Command to start a development server that recompiles the page on changes.
```bash
bundle exec guard
```
--------------------------------
### Alternative Development Commands
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/README.md
Alternative commands for development if guard is not working.
```bash
nanoc compile
nanoc view
```
--------------------------------
### List Sources
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/guides/create-a-booking-with-a-source.md
This GET request lists existing sources. You can use this to find the ID of a source.
```http
GET /sources
```
--------------------------------
### List availabilities
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/availabilities.md
List all availabilities for a given account.
```http
GET /availabilities
```
--------------------------------
### Sample Response for Token Request
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/guides/read-all-authorized-accounts-at-once.md
Example JSON response containing the access token and other details.
```json
{
"access_token": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"token_type": "bearer",
"expires_in": 7200,
"scope": "public",
"created_at": 1466671142
}
```
--------------------------------
### Search Rentals Endpoint Example
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/rentals.md
This snippet demonstrates how to search for rentals within a specific date range.
```http
GET /rentals/search?start_at=20140324&end_at=20140330
```
--------------------------------
### Create a new Host
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/hosts.md
Creates a host.
```http
POST /hosts
```
--------------------------------
### Create Source
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/guides/create-a-booking-with-a-source.md
This POST request creates a new source if the desired source does not already exist.
```http
POST /sources
```
--------------------------------
### Get a single mid term rate map
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/mid_term_rate_maps.md
This snippet shows the GET request to retrieve a single mid term rate map identified by its ID.
```http
GET /mid_term_rate_maps/:mid_term_rate_map_id
```
--------------------------------
### Define Custom Schema for Rentals
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/guides/bookigsync-universe-api-early-beta.md
Example request to define a custom schema for rentals using the BookingSync Universe API.
```bash
curl --header 'Authorization: Bearer YOUR_TOKEN' --header 'Content-Type: application/vnd.api+json' --request PUT --data '{ "data": { "id": 1, "type": "websites", "attributes": { "rentals-custom-data-schema": { "pool_size": "string" } } } }' https://website.apps.bookingsync.com/api/admin/v1/websites/1
```
--------------------------------
### SemVer Cheatsheet
Source: https://github.com/bookingsync/bookingsync-api-docs/wiki/How-to-release-a-new-version
A cheatsheet explaining the SemVer versioning scheme.
```text
1. MAJOR version when you make incompatible API changes,
2. MINOR version when you add functionality in a backward-compatible manner, and
3. PATCH version when you make backward-compatible bug fixes.
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
```
--------------------------------
### Get a single review
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/reviews.md
Returns a single review identified by ID.
```http
GET /reviews/:review_id
```
--------------------------------
### Read All Published Rentals with CURL
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/guides/read-all-authorized-accounts-at-once.md
Example using CURL to fetch all published rentals using the obtained access token.
```bash
curl --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' https://www.bookingsync.com/api/v3/rentals
```
--------------------------------
### Get a single tax
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/taxes.md
Returns a single tax identified by ID.
```http
GET /taxes/:tax_id
```
--------------------------------
### Get a single payment
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/payments.md
Returns a single payment identified by ID.
```http
GET /payments/:payment_id
```
--------------------------------
### Get a single rate
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/rates.md
Returns a single rate identified by ID.
```http
GET /rates/:rate_id
```
--------------------------------
### Get a single inquiry
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/inquiries.md
Returns a single inquiry identified by ID.
```http
GET /inquiries/:inquiry_id
```
--------------------------------
### Generate changelog
Source: https://github.com/bookingsync/bookingsync-api-docs/wiki/How-to-release-a-new-version
Command to generate a changelog using github_changelog_generator.
```bash
github_changelog_generator --token GITHUB_TOKEN -u BookingSync -p bookingsync-api-docs
```
--------------------------------
### Get a single photo
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/photos.md
Returns a single photo identified by ID.
```http
GET /photos/:photo_id
```
--------------------------------
### Get a single client
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/clients.md
Returns a single client identified by ID.
```http
GET /clients/:client_id
```
--------------------------------
### Get a single period
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/periods.md
Returns a single period identified by ID.
```http
GET /periods/:period_id
```
--------------------------------
### Create Booking with Source
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/guides/create-a-booking-with-a-source.md
This POST request creates a new booking and associates it with a source using the `source_id` parameter.
```http
POST /rentals/:rental_id/bookings
```
--------------------------------
### Get a single fee
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/fees.md
Returns a single fee identified by ID.
```http
GET /fees/:fee_id
```
--------------------------------
### Get a single contact
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/contacts.md
Returns a single contact identified by ID.
```http
GET /contacts/:contact_id
```
--------------------------------
### Access Token Request with CURL
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/testing_authorization.md
Example using CURL to make a POST request to obtain an access token.
```bash
curl -X POST -d "client_id=CLIENT_ID&client_secret=CLIENT_SECRET&code=RETURNED_CODE&grant_type=authorization_code&redirect_uri=urn:ietf:wg:oauth:2.0:oob" "https://www.bookingsync.com/oauth/token"
```
--------------------------------
### Create a new photo
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/photos.md
Returns a newly created photo for given rental.
```http
POST /rentals/:rental_id/photos
```
--------------------------------
### Get a single living_room
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/living_rooms.md
Returns a single living_room identified by ID.
```http
GET /living_rooms/:living_room_id
```
--------------------------------
### Get a single Host
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/hosts.md
Returns a single host identified by ID.
```http
GET /hosts/:host_id
```
--------------------------------
### Create a new Discount Code
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/booking/discount_codes.md
Creates a Discount Code and renders it.
```http
POST /booking/discount_codes
```
--------------------------------
### Get a single destination
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/destinations.md
Returns a single destination identified by ID.
```http
GET /destinations/:destination_id
```
--------------------------------
### Get a single change_over
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/change_overs.md
Returns a single change_over identified by ID.
```http
GET /change_overs/:change_over_id
```
--------------------------------
### Get a single bedroom
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/bedrooms.md
Returns a single bedroom identified by ID.
```http
GET /bedrooms/:bedroom_id
```
--------------------------------
### Get a single bathroom
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/bathrooms.md
Returns a single bathroom identified by ID.
```http
GET /bathrooms/:bathroom_id
```
--------------------------------
### Get a single availability
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/availabilities.md
Returns a single availability identified by ID.
```http
GET /availabilities/:availability_id
```
--------------------------------
### List clients
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/clients.md
Lists all clients for a given account.
```http
GET /clients
```
--------------------------------
### Create a new Rental URL
Source: https://github.com/bookingsync/bookingsync-api-docs/blob/master/content/reference/endpoints/rental_urls.md
Returns a newly created Rental URL for given rental.
```http
POST /rentals/:rental_id/rental_urls
```