class Openlive::User

Public Class Methods

create(attributes) click to toggle source

Create a new user on Openlive

@param [Hash] attributes A hash of attributes to set @option attributes [String] :username @option attributes [String] :email @option attributes [String] :password Optional, will be automatically generated @return [User] the created user object @raise [APIError] Will raise an error on unsuccessful response

# 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) click to toggle source

Find and return a user record

@param id [String] @return [User] @raise [APIError] Will raise an error on unsuccessful response

# 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) click to toggle source

Find and return a user by email address

@param email [String] @return [User] @raise [APIError] Will raise an error on unsuccessful response

# 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

Public Instance Methods

artists() click to toggle source

Convenience method for returning artists associated with user

@return [Array<Openlive::Artist>]

# 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