Module: Zotero::Syncing

Included in:
Client, Library
Defined in:
lib/zotero/syncing.rb

Overview

Syncing and API key verification methods.

This module can be included in both Client and Library classes. Classes including this module must implement #api_client which returns the object that responds to #make_get_request.

Instance Method Summary collapse

Instance Method Details

#api_clientObject (private)

Returns the object that handles API requests. Override in including classes if needed.

Returns:

  • (Object)

    The API client object



41
42
43
# File 'lib/zotero/syncing.rb', line 41

def api_client
  @client || self
end

#deleted_items(since: nil) ⇒ Hash

Get items that have been deleted from this library. Only available when included in Library.

Parameters:

  • since (Integer) (defaults to: nil)

    Optional version to get deletions since

Returns:

  • (Hash)

    Object with deleted collections and items arrays



31
32
33
# File 'lib/zotero/syncing.rb', line 31

def deleted_items(since: nil)
  api_client.make_get_request("#{@base_path}/deleted", params: { since: since }.compact)
end

#user_groups(user_id, format: "versions") ⇒ Hash, Array

Get groups for a specific user.

Parameters:

  • user_id (Integer, String)

    The user ID to get groups for

  • format (String) (defaults to: "versions")

    Response format ('versions' or 'json')

Returns:

  • (Hash, Array)

    Groups data in the requested format



22
23
24
# File 'lib/zotero/syncing.rb', line 22

def user_groups(user_id, format: "versions")
  api_client.make_get_request("/users/#{user_id}/groups", params: { format: format })
end

#verify_api_keyHash

Verify that the current API key is valid.

Returns:

  • (Hash)

    API key information including userID and username



13
14
15
# File 'lib/zotero/syncing.rb', line 13

def verify_api_key
  api_client.make_get_request("/keys/current")
end