// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>

namespace BookFast.Booking.Client
{
    using Models;
    using System.Collections;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;

    /// <summary>
    /// Extension methods for BookFastBookingAPI.
    /// </summary>
    public static partial class BookFastBookingAPIExtensions
    {
            /// <summary>
            /// List bookings by customer
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            public static IList<BookingRepresentation> ListBookings(this IBookFastBookingAPI operations)
            {
                return operations.ListBookingsAsync().GetAwaiter().GetResult();
            }

            /// <summary>
            /// List bookings by customer
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task<IList<BookingRepresentation>> ListBookingsAsync(this IBookFastBookingAPI operations, CancellationToken cancellationToken = default(CancellationToken))
            {
                using (var _result = await operations.ListBookingsWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false))
                {
                    return _result.Body;
                }
            }

            /// <summary>
            /// Find booking by ID
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='id'>
            /// Booking ID
            /// </param>
            public static BookingRepresentation FindBooking(this IBookFastBookingAPI operations, System.Guid id)
            {
                return operations.FindBookingAsync(id).GetAwaiter().GetResult();
            }

            /// <summary>
            /// Find booking by ID
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='id'>
            /// Booking ID
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task<BookingRepresentation> FindBookingAsync(this IBookFastBookingAPI operations, System.Guid id, CancellationToken cancellationToken = default(CancellationToken))
            {
                using (var _result = await operations.FindBookingWithHttpMessagesAsync(id, null, cancellationToken).ConfigureAwait(false))
                {
                    return _result.Body;
                }
            }

            /// <summary>
            /// Cancel booking
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='id'>
            /// Booking ID
            /// </param>
            public static void DeleteBooking(this IBookFastBookingAPI operations, System.Guid id)
            {
                operations.DeleteBookingAsync(id).GetAwaiter().GetResult();
            }

            /// <summary>
            /// Cancel booking
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='id'>
            /// Booking ID
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task DeleteBookingAsync(this IBookFastBookingAPI operations, System.Guid id, CancellationToken cancellationToken = default(CancellationToken))
            {
                (await operations.DeleteBookingWithHttpMessagesAsync(id, null, cancellationToken).ConfigureAwait(false)).Dispose();
            }

            /// <summary>
            /// Book an accommodation
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='accommodationId'>
            /// Accommodation ID
            /// </param>
            /// <param name='bookingData'>
            /// Booking details
            /// </param>
            public static void CreateBooking(this IBookFastBookingAPI operations, int accommodationId, BookAccommodationCommand bookingData = default(BookAccommodationCommand))
            {
                operations.CreateBookingAsync(accommodationId, bookingData).GetAwaiter().GetResult();
            }

            /// <summary>
            /// Book an accommodation
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='accommodationId'>
            /// Accommodation ID
            /// </param>
            /// <param name='bookingData'>
            /// Booking details
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task CreateBookingAsync(this IBookFastBookingAPI operations, int accommodationId, BookAccommodationCommand bookingData = default(BookAccommodationCommand), CancellationToken cancellationToken = default(CancellationToken))
            {
                (await operations.CreateBookingWithHttpMessagesAsync(accommodationId, bookingData, null, cancellationToken).ConfigureAwait(false)).Dispose();
            }

    }
}
