Module: WikidataAdaptor::RestApi::Descriptions

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

Overview

Instance Method Summary collapse

Instance Method Details

#delete_item_description(item_id, lang_code, payload) ⇒ String

Delete an Item's description in a specific language.

Parameters:

  • item_id (String)

    The ID of the Item.

  • lang_code (String)

    The language code.

  • payload (Hash)

    Edit metadata (comment).

Returns:

  • (String)

    Confirmation message.



122
123
124
# File 'lib/wikidata_adaptor/rest_api/descriptions.rb', line 122

def delete_item_description(item_id, lang_code, payload)
  delete_json("#{endpoint}/v1/entities/items/#{CGI.escape(item_id)}/descriptions/#{lang_code}", payload)
end

#delete_property_description(property_id, lang_code, payload) ⇒ String

Delete a Property's description in a specific language.

Parameters:

  • property_id (String)

    The ID of the Property.

  • lang_code (String)

    The language code.

  • payload (Hash)

    Edit metadata (comment).

Returns:

  • (String)

    Confirmation message.



133
134
135
# File 'lib/wikidata_adaptor/rest_api/descriptions.rb', line 133

def delete_property_description(property_id, lang_code, payload)
  delete_json("#{endpoint}/v1/entities/properties/#{CGI.escape(property_id)}/descriptions/#{lang_code}", payload)
end

#get_item_description(item_id, lang_code) ⇒ String

Retrieve an Item's description in a specific language.

Parameters:

  • item_id (String)

    The ID of the required Item.

  • lang_code (String)

    The requested resource language.

Returns:

  • (String)

    Item's description in a specific language.



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

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

#get_item_description_with_language_fallback(item_id, lang_code) ⇒ String

Retrieve an Item's description in a specific language, using Wikibase language fallback.

NOTE: The OpenAPI spec documents that this endpoint may respond with a redirect (e.g. 307/308) and a Location header. api_adaptor v0.1.0+ follows these redirects.

Parameters:

  • item_id (String)

    The ID of the required Item.

  • lang_code (String)

    The requested resource language.

Returns:

  • (String)

    Item's description in a specific language.



36
37
38
# File 'lib/wikidata_adaptor/rest_api/descriptions.rb', line 36

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

#get_item_descriptions(item_id) ⇒ Hash

Retrieve an Item's descriptions.

Parameters:

  • item_id (String)

    The ID of the required Item.

Returns:

  • (Hash)

    Item's descriptions by language.



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

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

#get_property_description(property_id, lang_code) ⇒ String

Retrieve a Property's description in a specific language.

Parameters:

  • property_id (String)

    The ID of the required Property.

  • lang_code (String)

    The requested resource language.

Returns:

  • (String)

    Property's description in a specific language.



55
56
57
# File 'lib/wikidata_adaptor/rest_api/descriptions.rb', line 55

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

#get_property_description_with_language_fallback(property_id, lang_code) ⇒ String

Retrieve a Property's description in a specific language, using Wikibase language fallback.

NOTE: The OpenAPI spec documents that this endpoint may respond with a redirect (e.g. 307/308) and a Location header. api_adaptor v0.1.0+ follows these redirects.

Parameters:

  • property_id (String)

    The ID of the required Property.

  • lang_code (String)

    The requested resource language.

Returns:

  • (String)

    Property's description in a specific language.



69
70
71
# File 'lib/wikidata_adaptor/rest_api/descriptions.rb', line 69

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

#get_property_descriptions(property_id) ⇒ Hash

Retrieve a Property's descriptions.

Parameters:

  • property_id (String)

    The ID of the required Property.

Returns:

  • (Hash)

    Property's descriptions by language.



45
46
47
# File 'lib/wikidata_adaptor/rest_api/descriptions.rb', line 45

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

#patch_item_descriptions(item_id, payload) ⇒ Hash

Apply JSON Patch operations to an Item's descriptions.

Parameters:

  • item_id (String)

    The ID of the Item.

  • payload (Hash)

    JSON Patch operations and edit metadata.

Returns:

  • (Hash)

    The updated descriptions.



101
102
103
# File 'lib/wikidata_adaptor/rest_api/descriptions.rb', line 101

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

#patch_property_descriptions(property_id, payload) ⇒ Hash

Apply JSON Patch operations to a Property's descriptions.

Parameters:

  • property_id (String)

    The ID of the Property.

  • payload (Hash)

    JSON Patch operations and edit metadata.

Returns:

  • (Hash)

    The updated descriptions.



111
112
113
# File 'lib/wikidata_adaptor/rest_api/descriptions.rb', line 111

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

#put_item_description(item_id, lang_code, payload) ⇒ String

Replace an Item's description in a specific language.

Parameters:

  • item_id (String)

    The ID of the Item.

  • lang_code (String)

    The language code.

  • payload (Hash)

    Description value and edit metadata.

Returns:

  • (String)

    The new description value.



80
81
82
# File 'lib/wikidata_adaptor/rest_api/descriptions.rb', line 80

def put_item_description(item_id, lang_code, payload)
  put_json("#{endpoint}/v1/entities/items/#{CGI.escape(item_id)}/descriptions/#{lang_code}", payload)
end

#put_property_description(property_id, lang_code, payload) ⇒ String

Replace a Property's description in a specific language.

Parameters:

  • property_id (String)

    The ID of the Property.

  • lang_code (String)

    The language code.

  • payload (Hash)

    Description value and edit metadata.

Returns:

  • (String)

    The new description value.



91
92
93
# File 'lib/wikidata_adaptor/rest_api/descriptions.rb', line 91

def put_property_description(property_id, lang_code, payload)
  put_json("#{endpoint}/v1/entities/properties/#{CGI.escape(property_id)}/descriptions/#{lang_code}", payload)
end