Module: Shikimori::API::V1::UserRates

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

Overview

Methods for the User rates API

Instance Method Summary collapse

Instance Method Details

#cleanup_user_rates(type, headers: nil, **query) ⇒ Boolean

Delete entire user rates and history

Examples:

Delete entire user rates and history

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

Parameters:

  • type ('anime', 'manga')

    Type of cleanup

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Returns:

  • (Boolean)

    True if deletion successful, false otherwise.

See Also:



168
169
170
# File 'lib/shikimori/api/v1/user_rates.rb', line 168

def cleanup_user_rates(type, headers: nil, **query)
  rest.delete base_url.join('user_rates', type.to_s, 'cleanup').url, headers: headers, query: query
end

#create_user_rate(user_rate, headers: nil, **query) ⇒ Hash

Create a user rate. Requires ‘user_rates` oauth scope

Examples:

Create a user rate

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
user_rate = {
  text: "text",
  user_id: 1,
  target_id: "41",
  target_type: "Anime"
}
client.v1.create_user_rate(user_rate)

Parameters:

  • user_rate (Hash)

    User rate data for creating

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Options Hash (user_rate):

  • :user_id (Integer)

    User id

  • :target_id (Integer)

    Target id

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

    Target type

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

    Watching status

  • :score (Numeric)

    Score

  • :chapters (Numeric)

    Current chapter number

  • :episodes (Numeric)

    Current episode number

  • :volumes (Numeric)

    Current volume number

  • :rewatches (Numeric)

    Count of rewatching

  • :text (String)

    Rate text

Returns:

  • (Hash)

    Hash representing created user rate

See Also:



68
69
70
# File 'lib/shikimori/api/v1/user_rates.rb', line 68

def create_user_rate(user_rate, headers: nil, **query)
  rest.post base_url.join('user_rates').url, { user_rate: user_rate }, headers: headers, query: query
end

#delete_user_rate(id, headers: nil, **query) ⇒ Boolean

Delete user rate

Examples:

Delete user rate

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

Parameters:

  • id (#to_s)

    User rate id

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Returns:

  • (Boolean)

    True if deletion successful, false otherwise.

See Also:



125
126
127
# File 'lib/shikimori/api/v1/user_rates.rb', line 125

def delete_user_rate(id, headers: nil, **query)
  rest.delete base_url.join('user_rates', id.to_s).url, headers: headers, query: query
end

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

Increment episodes/chapters by 1 Requires ‘user_rates` oauth scope

Examples:

Increment episodes/chapters by 1

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

Parameters:

  • id (#to_s)

    User rate ID

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Returns:

  • (Hash)

    Hash representing created user rate

See Also:



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

def increment_user_rate(id, headers: nil, **query)
  rest.post base_url.join('user_rates', id.to_s, 'increment').url, {}, headers: headers, query: query
end

#reset_user_rates(type, headers: nil, **query) ⇒ Boolean

Reset all user scores to 0

Examples:

Reset all user scores to 0

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

Parameters:

  • type ('anime', 'manga')

    Type of reset

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Returns:

  • (Boolean)

    True if deletion successful, false otherwise.

See Also:



188
189
190
# File 'lib/shikimori/api/v1/user_rates.rb', line 188

def reset_user_rates(type, headers: nil, **query)
  rest.delete base_url.join('user_rates', type.to_s, 'reset').url, headers: headers, query: query
end

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

Update a user rate. Requires ‘user_rates` oauth scope

Examples:

Update a user rate text

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
user_rate = {
  text: "text"
}
client.v1.update_user_rate(1, user_rate)

Parameters:

  • id (#to_s)

    User rate id

  • user_rate (Hash)

    User rate data for creating

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Options Hash (user_rate):

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

    Watching status

  • :score (Numeric)

    Score

  • :chapters (Numeric)

    Current chapter number

  • :episodes (Numeric)

    Current episode number

  • :volumes (Numeric)

    Current volume number

  • :rewatches (Numeric)

    Count of rewatching

  • :text (String)

    Rate text

Returns:

  • (Hash)

    Hash representing updated user rate

See Also:



103
104
105
# File 'lib/shikimori/api/v1/user_rates.rb', line 103

def update_user_rate(id, user_rate, headers: nil, **query)
  rest.put base_url.join('user_rates', id.to_s).url, { user_rate: user_rate }, headers: headers, query: query
end

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

Get an user rate by id

Examples:

Get user rate with id equal to 1

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.user_rate(1) #=> { id: 1, ... }

Parameters:

  • id (#to_s)

    user rate id

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Returns:

  • (Hash)

    Hash representing user rate

See Also:



28
29
30
# File 'lib/shikimori/api/v1/user_rates.rb', line 28

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