Module: Shikimori::API::V2::UserRates

Included in:
Shikimori::API::V2
Defined in:
lib/shikimori/api/v2/user_rates.rb

Overview

Methods for the User rates API

Instance Method Summary collapse

Instance Method Details

#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.v2.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:



90
91
92
# File 'lib/shikimori/api/v2/user_rates.rb', line 90

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. Requires ‘user_rates` oauth scope

Examples:

Delete user rate

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v2.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:



144
145
146
# File 'lib/shikimori/api/v2/user_rates.rb', line 144

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.v2.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:



165
166
167
# File 'lib/shikimori/api/v2/user_rates.rb', line 165

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

#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.v2.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:



123
124
125
# File 'lib/shikimori/api/v2/user_rates.rb', line 123

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.v2.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:



52
53
54
# File 'lib/shikimori/api/v2/user_rates.rb', line 52

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

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

Get list of user rates

Examples:

List of user rates

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

Parameters:

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Options Hash (**query):

  • :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

  • :user_id (Integer)

    User ID

  • :target_id (Integer)

    Target ID

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

    Target ID

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

    Watching/Reading status

Returns:

  • (Array<Hash>)

    Array of hashes representing user rates

See Also:



32
33
34
# File 'lib/shikimori/api/v2/user_rates.rb', line 32

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