Module: Shikimori::API::V1::Characters

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

Overview

Methods for the Characters API

Instance Method Summary collapse

Instance Method Details

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

Get a character by id

Examples:

Get character with id equal to 1

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

Parameters:

  • id (#to_s)

    Character id

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Returns:

  • (Hash)

    Hash representing character

See Also:



46
47
48
# File 'lib/shikimori/api/v1/characters.rb', line 46

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

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

Get list of Characters

Examples:

Search characters

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

Parameters:

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Options Hash (**query):

  • :search (String)

    A character name for searching

Returns:

  • (Array<Hash>)

    Array of hashes representing characters

See Also:



26
27
28
# File 'lib/shikimori/api/v1/characters.rb', line 26

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