class LolesportsApi::BaseApiObject

Constants

SCHEDULE_URL

Public Class Methods

fail_by_status(response) click to toggle source
# File lib/lolesports-api/base.rb, line 26
def self.fail_by_status(response)
  klass =
    LolesportsApi::Error::ERRORS[response.status] || LolesportsApi::Error
  fail klass
end
find(base_id) click to toggle source
# File lib/lolesports-api/base.rb, line 9
def self.find(base_id)
  response = Faraday.get("#{self::API_URL}/#{base_id}.json")
  fail_by_status(response) unless response.success?
  @attributes = JSON.parse(response.body)
  @attributes['id'] = base_id
  @base_object = new(@attributes)
end

Public Instance Methods

reload() click to toggle source
# File lib/lolesports-api/base.rb, line 17
def reload
  response = Faraday.get("#{self.class::API_URL}/#{@id}.json")
  self.class.fail_by_status(response) unless response.success?
  @attributes = JSON.parse(response.body)
  @attributes['id'] = @id
  initialize(@attributes)
  self
end

Private Instance Methods

parse_datetime(attribute) click to toggle source
# File lib/lolesports-api/base.rb, line 34
def parse_datetime(attribute)
  DateTime.parse(attribute) if attribute
end