Class: Openlive::User
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.create(attributes) ⇒ User
Create a new user on Openlive.
-
.find(id) ⇒ User
Find and return a user record.
-
.find_by_email(email) ⇒ User
Find and return a user by email address.
Instance Method Summary collapse
-
#artists ⇒ Array<Openlive::Artist>
Convenience method for returning artists associated with user.
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) ⇒ User
Create a new user on Openlive
53 54 55 56 57 58 59 |
# File 'lib/openlive/user.rb', line 53 def create(attributes) response = Request.post("users", attributes) handle_response(response, error_class: APIError) do |response| new(response.body, response: response) end end |
.find(id) ⇒ User
Find and return a user record
24 25 26 27 28 29 30 |
# File 'lib/openlive/user.rb', line 24 def find(id) response = Request.get("users/#{id}") handle_response(response, error_class: APIError) do |response| new(response.body, response: response) end end |
.find_by_email(email) ⇒ User
Find and return a user by email address
37 38 39 40 41 42 43 |
# File 'lib/openlive/user.rb', line 37 def find_by_email(email) response = Request.get("users", email: email) handle_response(response, error_class: APIError) do |response| new(response.body, response: response) end end |
Instance Method Details
#artists ⇒ Array<Openlive::Artist>
Convenience method for returning artists associated with user
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/openlive/user.rb', line 6 def artists unless api_data['artists'].nil? if api_data['artists'].empty? [] else @artists ||= api_data['artists'].map do |attributes| Artist.new(attributes) end end end end |