Sha256: 7c8b0107c001a1e166a8fe4c71b65feb3ead5d8230c80c5377d592c4f3d46441

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

module Genius
  class Account < Resource
    resource_name "user"

    attr_reader :unread_messages_count, :artist, :role_for_display, :iq,
                :unread_main_activity_inbox_count, :avatar, :about_me,
                :tracking_paths, :id, :current_user_metadata, :login, :name

    def parse_resource!
      @unread_messages_count = resource["unread_messages_count"]
      @artist = resource["artist"]
      @role_for_display = resource["role_for_display"]
      @unread_main_activity_inbox_count = resource["unread_main_activity_inbox_count"]
      @avatar = resource["avatar"]
      @about_me = formatted_attribute("about_me")
      @identities = resource["identities"]
      @name = resource["name"]
      @tracking_paths = resource["tracking_paths"]
      @id = resource["id"]
      @current_user_metadata = resource["current_user_metadata"]
      @iq = resource["iq"]
      @login = resource["login"]
    end

    def reload
      raise NotReloadableError, "An Account cannot be reloaded"
    end

    def self.find(id, params: {}, headers: {})
      raise NotImplementedError, "An Account cannot be loaded by its ID in the public API"
    end

    def self.me(params = {})
      headers = default_headers.merge(params.delete(:headers) || {})
      params = default_params.merge(params)

      new(http_get("/account", query: params, headers: headers),
                               text_format: params[:text_format])
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
genius-0.1.0 lib/genius/account.rb