Class: Openlive::Artist

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

Instance Attribute Summary

Attributes inherited from Base

#api_data, #response

Class 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

.allArray<Artist>

Fetch and return a list of all artists

Returns:

Raises:

  • (APIError)

    Will raise an error on unsuccessful response



36
37
38
39
40
41
42
43
44
# File 'lib/openlive/artist.rb', line 36

def all
  response = Request.get("artists")

  handle_response(response, error_class: APIError) do |response|
    response.body['data'].map do |a|
      new(a, response: response)
    end
  end
end

.create(attributes) ⇒ Artist

Create a new artist on Openlive

Parameters:

  • attributes (Hash)

    A hash of attributes to set

Options Hash (attributes):

  • :name (String)
  • :userId (String)

Returns:

  • (Artist)

    the created artist object

Raises:

  • (APIError)

    Will raise an error on unsuccessful response



24
25
26
27
28
29
30
# File 'lib/openlive/artist.rb', line 24

def create(attributes)
  response = Request.post("artists", attributes)

  handle_response(response, error_class: APIError) do |response|
    new(response.body, response: response)
  end
end

.find(id) ⇒ Artist

Find and return an artist record

Parameters:

  • id (String)

Returns:

Raises:

  • (APIError)

    Will raise an error on unsuccessful response



9
10
11
12
13
14
15
# File 'lib/openlive/artist.rb', line 9

def find(id)
  response = Request.get("artists/#{id}")

  handle_response(response, error_class: APIError) do |response|
    new(response.body, response: response)
  end
end