Module: Shikimori::API::V1::Friends

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

Overview

Methods for the Friends API

Instance Method Summary collapse

Instance Method Details

#create_friend(user_id, headers: nil, **query) ⇒ Boolean

Create friend by user_id. Requires ‘friends` oauth scope

Examples:

Add to friends a user with id equal to 1

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

Parameters:

  • user_id (#to_s)

    User id that add to friends

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Returns:

  • (Boolean)

    True if added to friends

See Also:



27
28
29
30
31
# File 'lib/shikimori/api/v1/friends.rb', line 27

def create_friend(user_id, headers: nil, **query)
  rest.post base_url.join('friends', user_id.to_s).url, {}, headers: headers, query: query

  true
end

#delete_friend(user_id, headers: nil, **query) ⇒ Boolean

Delete friend by user id. Requires ‘friends` oauth scope

Examples:

Delete a user from friends by id equal to 1

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

client.v1.delete_friend(1)

Parameters:

  • user_id (#to_s)

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



51
52
53
# File 'lib/shikimori/api/v1/friends.rb', line 51

def delete_friend(user_id, headers: nil, **query)
  rest.delete base_url.join('friends', user_id.to_s).url, headers: headers, query: query
end