Module: WikidataAdaptor::RestApi::Aliases

Included in:
WikidataAdaptor::RestApi
Defined in:
lib/wikidata_adaptor/rest_api/aliases.rb

Overview

Instance Method Summary collapse

Instance Method Details

#get_item_alias(item_id, lang_code) ⇒ Array<String>

Retrieve an Item's alias in a specific language.

Parameters:

  • item_id (String)

    The ID of the required Item.

  • lang_code (String)

    The requested resource language.

Returns:

  • (Array<String>)

    Item's alias in a specific language.



22
23
24
# File 'lib/wikidata_adaptor/rest_api/aliases.rb', line 22

def get_item_alias(item_id, lang_code)
  get_json("#{endpoint}/v1/entities/items/#{CGI.escape(item_id)}/aliases/#{lang_code}")
end

#get_item_aliases(item_id) ⇒ Hash

Retrieve an Item's aliases.

Parameters:

  • item_id (String)

    The ID of the required Item.

Returns:

  • (Hash)

    Item's aliases by language.



12
13
14
# File 'lib/wikidata_adaptor/rest_api/aliases.rb', line 12

def get_item_aliases(item_id)
  get_json("#{endpoint}/v1/entities/items/#{CGI.escape(item_id)}/aliases")
end

#get_property_alias(property_id, lang_code) ⇒ Array<String>

Retrieve a Property's aliases in a specific language.

Parameters:

  • property_id (String)

    The ID of the required Property.

  • lang_code (String)

    The requested resource language.

Returns:

  • (Array<String>)

    Property's aliases in a specific language.



52
53
54
# File 'lib/wikidata_adaptor/rest_api/aliases.rb', line 52

def get_property_alias(property_id, lang_code)
  get_json("#{endpoint}/v1/entities/properties/#{CGI.escape(property_id)}/aliases/#{lang_code}")
end

#get_property_aliases(property_id) ⇒ Hash

Retrieve a Property's aliases.

Parameters:

  • property_id (String)

    The ID of the required Property.

Returns:

  • (Hash)

    Property's aliases by language.



42
43
44
# File 'lib/wikidata_adaptor/rest_api/aliases.rb', line 42

def get_property_aliases(property_id)
  get_json("#{endpoint}/v1/entities/properties/#{CGI.escape(property_id)}/aliases")
end

#patch_item_aliases(item_id, payload) ⇒ Hash

Apply JSON Patch operations to an Item's aliases.

Parameters:

  • item_id (String)

    The ID of the Item.

  • payload (Hash)

    JSON Patch operations and edit metadata.

Returns:

  • (Hash)

    The updated aliases.



73
74
75
# File 'lib/wikidata_adaptor/rest_api/aliases.rb', line 73

def patch_item_aliases(item_id, payload)
  patch_json("#{endpoint}/v1/entities/items/#{CGI.escape(item_id)}/aliases", payload)
end

#patch_property_aliases(property_id, payload) ⇒ Hash

Apply JSON Patch operations to a Property's aliases.

Parameters:

  • property_id (String)

    The ID of the Property.

  • payload (Hash)

    JSON Patch operations and edit metadata.

Returns:

  • (Hash)

    The updated aliases.



83
84
85
# File 'lib/wikidata_adaptor/rest_api/aliases.rb', line 83

def patch_property_aliases(property_id, payload)
  patch_json("#{endpoint}/v1/entities/properties/#{CGI.escape(property_id)}/aliases", payload)
end

#post_item_aliases(item_id, lang_code, payload) ⇒ Array<String>

Add aliases to an Item in a specific language.

Parameters:

  • item_id (String)

    The ID of the Item.

  • lang_code (String)

    The language code.

  • payload (Hash)

    Aliases and edit metadata.

Returns:

  • (Array<String>)

    The updated list of aliases.



33
34
35
# File 'lib/wikidata_adaptor/rest_api/aliases.rb', line 33

def post_item_aliases(item_id, lang_code, payload)
  post_json("#{endpoint}/v1/entities/items/#{CGI.escape(item_id)}/aliases/#{lang_code}", payload)
end

#post_property_aliases(property_id, lang_code, payload) ⇒ Array<String>

Add aliases to a Property in a specific language.

Parameters:

  • property_id (String)

    The ID of the Property.

  • lang_code (String)

    The language code.

  • payload (Hash)

    Aliases and edit metadata.

Returns:

  • (Array<String>)

    The updated list of aliases.



63
64
65
# File 'lib/wikidata_adaptor/rest_api/aliases.rb', line 63

def post_property_aliases(property_id, lang_code, payload)
  post_json("#{endpoint}/v1/entities/properties/#{CGI.escape(property_id)}/aliases/#{lang_code}", payload)
end