Class: Openlive::Booking

Inherits:
Base
  • Object
show all
Defined in:
lib/openlive/booking.rb

Instance Attribute Summary

Attributes inherited from Base

#api_data, #response

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

connection, #connection, handle_response, #initialize, #method_missing, #oauth, oauth, #refresh

Constructor Details

This class inherits a constructor from Openlive::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Openlive::Base

Class Method Details

.create(attributes) ⇒ Booking

Create a new booking on Openlive

Parameters:

  • attributes (Hash)

    A hash of attributes to set

Options Hash (attributes):

  • :artistId (String)
  • :masterbuilderId (String)
  • :start (Time)
  • :finish (Time)

Returns:

  • (Booking)

    the created booking object

Raises:

  • (APIError)

    Will raise an error on unsuccessful response



34
35
36
37
38
39
40
# 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(id) ⇒ Truthy

Delete an existing booking on Openlive

Parameters:

  • id (String)

    The booking ID

Returns:

  • (Truthy)

    whether the record was successfully deleted or not

Raises:

  • (APIError)

    Will raise an error on unsuccessful response



47
48
49
50
51
52
53
# 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(id) ⇒ Booking

Find and return a booking record

Parameters:

  • id (String)

Returns:

Raises:

  • (APIError)

    Will raise an error on unsuccessful response



17
18
19
20
21
22
23
# 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

Instance Method Details

#deleteTruthy

Convenience method for deleting this booking

Returns:

  • (Truthy)

    whether the record was successfully deleted or not

Raises:

  • (APIError)

    Will raise an error on unsuccessful response



7
8
9
# File 'lib/openlive/booking.rb', line 7

def delete
  self.class.delete(id)
end