Module: Shikimori::API::V1::Users

Included in:
Shikimori::API::V1
Defined in:
lib/shikimori/api/v1/users.rb

Overview

Methods for the Users API

Instance Method Summary collapse

Instance Method Details

#sign_out(headers: nil, **query) ⇒ Hash

Sign out the user

Examples:

Sign out current user

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.sign_out

Parameters:

  • headers (Hash) (defaults to: nil)

    a customizable set of options

  • query (Hash)

    a customizable set of options

Options Hash (headers:):

  • Request (Hash)

    headers

Options Hash (**query):

  • Query (Hash)

    string parameters for request

Returns:

  • (Hash)

    Hash representing user

See Also:



108
109
110
# File 'lib/shikimori/api/v1/users.rb', line 108

def sign_out(headers: nil, **query)
  rest.get base_url.join('users', 'sign_out').url, headers: headers, query: query
end

#user(id, headers: nil, **query) ⇒ Hash

Get an user

Examples:

Get a user with id equal to 1

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)

client.v1.user(1)

Parameters:

  • id (Hash)

    a customizable set of options

  • headers (Hash) (defaults to: nil)

    a customizable set of options

  • query (Hash)

    a customizable set of options

Options Hash (id):

  • User (#to_s)

    id

Options Hash (headers:):

  • Request (Hash)

    headers

Options Hash (**query):

  • Query (Hash)

    string parameters for request

Returns:

  • (Hash)

    Hash representing user

See Also:



50
51
52
# File 'lib/shikimori/api/v1/users.rb', line 50

def user(id, headers: nil, **query)
  rest.get base_url.join('users', id.to_s).url, headers: headers, query: query
end

#user_anime_rates(id, headers: nil, **query) ⇒ Array<Hash>

Get an user’s anime rates

Examples:

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.user_anime_rates(1)

Parameters:

  • id (Hash)

    a customizable set of options

  • headers (Hash) (defaults to: nil)

    a customizable set of options

  • query (Hash)

    a customizable set of options

Options Hash (id):

  • User (#to_s)

    id

Options Hash (headers:):

  • Request (Hash)

    headers

Options Hash (**query):

  • Query (Hash)

    string parameters for request

  • :page (Integer)

    Number of page. Must be between 1 and 100000

  • :limit (Integer)

    Number of titles per page. Must be a lower or equal that 5000

  • :censored (TrueClass, FalseClass)

    Set to true to discard hentai, yaoi and yuri

  • :status ('planned', 'watching', 'rewatching', 'completed', 'on_hold', 'dropped')

    Watching status

Returns:

  • (Array<Hash>)

    Array of hashes representing user’s anime rates

See Also:



172
173
174
# File 'lib/shikimori/api/v1/users.rb', line 172

def user_anime_rates(id, headers: nil, **query)
  rest.get base_url.join('users', id.to_s, 'anime_rates').url, headers: headers, query: query
end

#user_bans(id, headers: nil, **query) ⇒ Array<Hash>

Get an user’s bans

Examples:

Get user’s manga bans

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.user_bans

Parameters:

  • id (Hash)

    a customizable set of options

  • headers (Hash) (defaults to: nil)

    a customizable set of options

  • query (Hash)

    a customizable set of options

Options Hash (id):

  • User (#to_s)

    id

Options Hash (headers:):

  • Request (Hash)

    headers

Options Hash (**query):

  • Query (Hash)

    string parameters for request

Returns:

  • (Array<Hash>)

    Array of hashes representing user’s bans

See Also:



304
305
306
# File 'lib/shikimori/api/v1/users.rb', line 304

def user_bans(id, headers: nil, **query)
  rest.get base_url.join('users', id.to_s, 'bans').url, headers: headers, query: query
end

#user_clubs(id, headers: nil, **query) ⇒ Array<Hash>

Get an user’s clubs

Examples:

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.user_clubs(1)

Parameters:

  • id (Hash)

    a customizable set of options

  • headers (Hash) (defaults to: nil)

    a customizable set of options

  • query (Hash)

    a customizable set of options

Options Hash (id):

  • User (#to_s)

    id

Options Hash (headers:):

  • Request (Hash)

    headers

Options Hash (**query):

  • Query (Hash)

    string parameters for request

Returns:

  • (Array<Hash>)

    Array of hashes representing user’s clubs

See Also:



148
149
150
# File 'lib/shikimori/api/v1/users.rb', line 148

def user_clubs(id, headers: nil, **query)
  rest.get base_url.join('users', id.to_s, 'clubs').url, headers: headers, query: query
end

#user_favorites(id, headers: nil, **query) ⇒ Hash

Get an user’s favorites

Examples:

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.user_favorites(1)

Parameters:

  • id (Hash)

    a customizable set of options

  • headers (Hash) (defaults to: nil)

    a customizable set of options

  • query (Hash)

    a customizable set of options

Options Hash (id):

  • User (#to_s)

    id

Options Hash (headers:):

  • Request (Hash)

    headers

Options Hash (**query):

  • Query (Hash)

    string parameters for request

Returns:

  • (Hash)

    Hash representing user’s favorites

See Also:



215
216
217
# File 'lib/shikimori/api/v1/users.rb', line 215

def user_favorites(id, headers: nil, **query)
  rest.get base_url.join('users', id.to_s, 'favourites').url, headers: headers, query: query
end

#user_friends(id, headers: nil, **query) ⇒ Array<Hash>

Get an user’s friends

Examples:

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.user_friends(1)

Parameters:

  • id (Hash)

    a customizable set of options

  • headers (Hash) (defaults to: nil)

    a customizable set of options

  • query (Hash)

    a customizable set of options

Options Hash (id):

  • User (#to_s)

    id

Options Hash (headers:):

  • Request (Hash)

    headers

Options Hash (**query):

  • Query (Hash)

    string parameters for request

Returns:

  • (Array<Hash>)

    Array of hashes representing user’s friends

See Also:



128
129
130
# File 'lib/shikimori/api/v1/users.rb', line 128

def user_friends(id, headers: nil, **query)
  rest.get base_url.join('users', id.to_s, 'friends').url, headers: headers, query: query
end

#user_history(id, headers: nil, **query) ⇒ Array<Hash>

Get an user’s history

Examples:

Get user’s manga history

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.user_history(1, type: 'manga', limit: 10)

Parameters:

  • id (Hash)

    a customizable set of options

  • headers (Hash) (defaults to: nil)

    a customizable set of options

  • query (Hash)

    a customizable set of options

Options Hash (id):

  • User (#to_s)

    id

Options Hash (headers:):

  • Request (Hash)

    headers

Options Hash (**query):

  • Query (Hash)

    string parameters for request

  • :page (Integer)

    Number of page. Must be between 1 and 100000

  • :limit (Integer)

    Number of titles per page. Must be a lower or equal that 100

  • :target_id (Integer)

    Target ID

  • :target_type ('Anime', 'Manga')

    Target type

Returns:

  • (Array<Hash>)

    Array of hashes representing user’s history

See Also:



284
285
286
# File 'lib/shikimori/api/v1/users.rb', line 284

def user_history(id, headers: nil, **query)
  rest.get base_url.join('users', id.to_s, 'history').url, headers: headers, query: query
end

#user_info(id, headers: nil, **query) ⇒ Hash

Get an user’s brief info

Examples:

Get a user info with id equal to 1

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.(1)

Parameters:

  • id (Hash)

    a customizable set of options

  • headers (Hash) (defaults to: nil)

    a customizable set of options

  • query (Hash)

    a customizable set of options

Options Hash (id):

  • User (#to_s)

    id

Options Hash (headers:):

  • Request (Hash)

    headers

Options Hash (**query):

  • Query (Hash)

    string parameters for request

Returns:

  • (Hash)

    Hash representing user

See Also:



70
71
72
# File 'lib/shikimori/api/v1/users.rb', line 70

def (id, headers: nil, **query)
  rest.get base_url.join('users', id.to_s, 'info').url, headers: headers, query: query
end

#user_manga_rates(id, headers: nil, **query) ⇒ Array<Hash>

Get an user’s manga rates

Examples:

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.user_manga_rates(1)

Parameters:

  • id (Hash)

    a customizable set of options

  • headers (Hash) (defaults to: nil)

    a customizable set of options

  • query (Hash)

    a customizable set of options

Options Hash (id):

  • User (#to_s)

    id

Options Hash (headers:):

  • Request (Hash)

    headers

Options Hash (**query):

  • Query (Hash)

    string parameters for request

  • :page (Integer)

    Number of page. Must be between 1 and 100000

  • :limit (Integer)

    Number of titles per page. Must be a lower or equal that 5000

  • :censored (TrueClass, FalseClass)

    Set to true to discard hentai, yaoi and yuri

Returns:

  • (Array<Hash>)

    Array of hashes representing user’s manga rates

See Also:



195
196
197
# File 'lib/shikimori/api/v1/users.rb', line 195

def user_manga_rates(id, headers: nil, **query)
  rest.get base_url.join('users', id.to_s, 'manga_rates').url, headers: headers, query: query
end

#user_messages(id, headers: nil, **query) ⇒ Array<Hash>

Get an user’s messages Requires ‘messages` oauth scope

Examples:

Get user’s messages from inbox

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.user_messages(1, type: 'inbox', limit: 10)

Parameters:

  • id (Hash)

    a customizable set of options

  • headers (Hash) (defaults to: nil)

    a customizable set of options

  • query (Hash)

    a customizable set of options

Options Hash (id):

  • User (#to_s)

    id

Options Hash (headers:):

  • Request (Hash)

    headers

Options Hash (**query):

  • Query (Hash)

    string parameters for request

  • :page (Integer)

    Number of page. Must be between 1 and 100000

  • :limit (Integer)

    Number of titles per page. Must be a lower or equal that 100

  • :type ('inbox', 'private', 'sent', 'news', 'notifications')

    Type of messages

Returns:

  • (Array<Hash>)

    Array of hashes representing user’s messages

See Also:



239
240
241
# File 'lib/shikimori/api/v1/users.rb', line 239

def user_messages(id, headers: nil, **query)
  rest.get base_url.join('users', id.to_s, 'messages').url, headers: headers, query: query
end

#user_unread_messages(id, headers: nil, **query) ⇒ Hash

Get an user’s unread messages Requires ‘messages` oauth scope

Examples:

Get user’s unread messages

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.user_unread_messages(1, type: 'inbox', limit: 10)

Parameters:

  • id (Hash)

    a customizable set of options

  • headers (Hash) (defaults to: nil)

    a customizable set of options

  • query (Hash)

    a customizable set of options

Options Hash (id):

  • User (#to_s)

    id

Options Hash (headers:):

  • Request (Hash)

    headers

Options Hash (**query):

  • Query (Hash)

    string parameters for request

Returns:

  • (Hash)

    Hash representing user’s messages

See Also:



260
261
262
# File 'lib/shikimori/api/v1/users.rb', line 260

def user_unread_messages(id, headers: nil, **query)
  rest.get base_url.join('users', id.to_s, 'unread_messages').url, headers: headers, query: query
end

#users(headers: nil, **query) ⇒ Array<Hash>

Get list of users

Examples:

Search users with by name “ivan”

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)

client.v1.users(search: 'ivan')

Parameters:

  • headers (Hash) (defaults to: nil)

    a customizable set of options

  • query (Hash)

    a customizable set of options

Options Hash (headers:):

  • Request (Hash)

    headers

Options Hash (**query):

  • Query (Hash)

    string parameters for request

  • :page (Integer)

    Number of page. Must be between 1 and 100000

  • :limit (Integer)

    Number of titles per page. Must be a lower or equal that 50

  • :search (String)

    Find user by name

Returns:

  • (Array<Hash>)

    Array of hashes representing users

See Also:



29
30
31
# File 'lib/shikimori/api/v1/users.rb', line 29

def users(headers: nil, **query)
  rest.get base_url.join('users').url, headers: headers, query: query
end

#whoami(headers: nil, **query) ⇒ Hash

Get an current user’s brief info

Examples:

Get a current user info

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.whoami

Parameters:

  • headers (Hash) (defaults to: nil)

    a customizable set of options

  • query (Hash)

    a customizable set of options

Options Hash (headers:):

  • Request (Hash)

    headers

Options Hash (**query):

  • Query (Hash)

    string parameters for request

Returns:

  • (Hash)

    Hash representing user

See Also:



89
90
91
# File 'lib/shikimori/api/v1/users.rb', line 89

def whoami(headers: nil, **query)
  rest.get base_url.join('users', 'whoami').url, headers: headers, query: query
end