Module: Shikimori::API::V1::Reviews

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

Overview

Methods for the Reviews API

Instance Method Summary collapse

Instance Method Details

#create_review(review, frontend: nil, headers: nil, **query) ⇒ Hash

Create a anime’s review

Examples:

Create a comment for topic with id equal to 1

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.create_review({ body: 'Good!', anime_id: 1, opinion: 'positive' })

Parameters:

  • review (Hash)

    Review data for creating

  • frontend ('false', 'true', 1, 0) (defaults to: nil)

    Used by shikimori frontend code. Ignore it.

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Options Hash (review):

  • :body (String)

    Review text

  • :anime_id (Integer)

    Anime’s ID

  • :opinion ('positive', 'neutral', 'negative')

    Review’s opinion

Returns:

  • (Hash)

    Hash representing created comment

See Also:



30
31
32
33
34
35
36
# File 'lib/shikimori/api/v1/reviews.rb', line 30

def create_review(review, frontend: nil, headers: nil, **query)
  rest.post(
    base_url.join('reviews').url,
    { review: review, frontend: frontend }.compact,
    headers: headers, query: query
  )
end

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

Delete anime’s review

Examples:

Delete review with id equal to 1

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

Parameters:

  • id (String, Integer)

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



83
84
85
# File 'lib/shikimori/api/v1/reviews.rb', line 83

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

#update_review(id, review, frontend: nil, headers: nil, **query) ⇒ Hash

Update anime’s review by id

Examples:

Change review opinion

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

client.v1.update_review(1, { opinion: 'negative' })

Parameters:

  • id (Hash)

    Review’s id

  • review (Hash)

    Review data for updating

  • frontend ('false', 'true', 1, 0) (defaults to: nil)

    Used by shikimori frontend code. Ignore it.

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Options Hash (review):

  • :body (String)

    Review text

  • :opinion ('positive', 'neutral', 'negative')

    Review’s opinion

Returns:

  • (Hash)

    Hash representing updated review

See Also:



59
60
61
62
63
64
65
# File 'lib/shikimori/api/v1/reviews.rb', line 59

def update_review(id, review, frontend: nil, headers: nil, **query)
  rest.put(
    base_url.join('reviews', id.to_s).url,
    { review: review, frontend: frontend }.compact,
    headers: headers, query: query
  )
end