class Openlive::Booking
Public Class Methods
Create a new booking on Openlive
@param [Hash] attributes A hash of attributes to set @option attributes [String] :artistId @option attributes [String] :masterbuilderId @option attributes [Time] :start @option attributes [Time] :finish @return [Booking] the created booking object @raise [APIError] Will raise an error on unsuccessful response
# File lib/openlive/booking.rb, line 34 def create(attributes) response = Request.post("bookings", format_attributes(attributes)) handle_response(response, error_class: APIError) do |response| new(response.body, response: response) end end
Delete an existing booking on Openlive
@param [String] id The booking ID @return [Truthy] whether the record was successfully deleted or not @raise [APIError] Will raise an error on unsuccessful response
# File lib/openlive/booking.rb, line 47 def delete(id) response = Request.delete("bookings/#{id}") handle_response(response, error_class: APIError) do |response| response.response.success? end end
Find and return a booking record
@param id [String] @return [Booking] @raise [APIError] Will raise an error on unsuccessful response
# File lib/openlive/booking.rb, line 17 def find(id) response = Request.get("bookings/#{id}") handle_response(response, error_class: APIError) do |response| new(response.body, response: response) end end
Private Class Methods
# File lib/openlive/booking.rb, line 57 def format_attributes(attributes) attributes.update(attributes) do |key, val| if val.is_a?(Time) || val.is_a?(DateTime) val.strftime("%Y-%m-%dT%H:%M:%S.%LZ") else val end end end
Public Instance Methods
Convenience method for deleting this booking
@return [Truthy] whether the record was successfully deleted or not @raise [APIError] Will raise an error on unsuccessful response
# File lib/openlive/booking.rb, line 7 def delete self.class.delete(id) end