Module: WikidataAdaptor::RestApi::Labels
- Included in:
- WikidataAdaptor::RestApi
- Defined in:
- lib/wikidata_adaptor/rest_api/labels.rb
Overview
Instance Method Summary collapse
-
#delete_item_label(item_id, lang_code, payload) ⇒ String
Delete an Item's label in a specific language.
-
#delete_property_label(property_id, lang_code, payload) ⇒ String
Delete a Property's label in a specific language.
-
#get_item_label(item_id, lang_code) ⇒ String
Retrieve an Item's label in a specific language.
-
#get_item_label_with_language_fallback(item_id, lang_code) ⇒ String
Retrieve an Item's label in a specific language, using Wikibase language fallback.
-
#get_item_labels(item_id) ⇒ Hash
Retrieve an Item's labels.
-
#get_property_label(property_id, lang_code) ⇒ String
Retrieve a Property's label in a specific language.
-
#get_property_label_with_language_fallback(property_id, lang_code) ⇒ String
Retrieve a Property's label in a specific language, using Wikibase language fallback.
-
#get_property_labels(property_id) ⇒ Hash
Retrieve a Property's labels.
-
#patch_item_labels(item_id, payload) ⇒ Hash
Apply JSON Patch operations to an Item's labels.
-
#patch_property_labels(property_id, payload) ⇒ Hash
Apply JSON Patch operations to a Property's labels.
-
#put_item_label(item_id, lang_code, payload) ⇒ String
Replace an Item's label in a specific language.
-
#put_property_label(property_id, lang_code, payload) ⇒ String
Replace a Property's label in a specific language.
Instance Method Details
#delete_item_label(item_id, lang_code, payload) ⇒ String
Delete an Item's label in a specific language.
122 123 124 |
# File 'lib/wikidata_adaptor/rest_api/labels.rb', line 122 def delete_item_label(item_id, lang_code, payload) delete_json("#{endpoint}/v1/entities/items/#{CGI.escape(item_id)}/labels/#{lang_code}", payload) end |
#delete_property_label(property_id, lang_code, payload) ⇒ String
Delete a Property's label in a specific language.
133 134 135 |
# File 'lib/wikidata_adaptor/rest_api/labels.rb', line 133 def delete_property_label(property_id, lang_code, payload) delete_json("#{endpoint}/v1/entities/properties/#{CGI.escape(property_id)}/labels/#{lang_code}", payload) end |
#get_item_label(item_id, lang_code) ⇒ String
Retrieve an Item's label in a specific language.
22 23 24 |
# File 'lib/wikidata_adaptor/rest_api/labels.rb', line 22 def get_item_label(item_id, lang_code) get_json("#{endpoint}/v1/entities/items/#{CGI.escape(item_id)}/labels/#{lang_code}") end |
#get_item_label_with_language_fallback(item_id, lang_code) ⇒ String
Retrieve an Item's label 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.
36 37 38 |
# File 'lib/wikidata_adaptor/rest_api/labels.rb', line 36 def get_item_label_with_language_fallback(item_id, lang_code) get_json("#{endpoint}/v1/entities/items/#{CGI.escape(item_id)}/labels_with_language_fallback/#{lang_code}") end |
#get_item_labels(item_id) ⇒ Hash
Retrieve an Item's labels.
12 13 14 |
# File 'lib/wikidata_adaptor/rest_api/labels.rb', line 12 def get_item_labels(item_id) get_json("#{endpoint}/v1/entities/items/#{CGI.escape(item_id)}/labels") end |
#get_property_label(property_id, lang_code) ⇒ String
Retrieve a Property's label in a specific language.
55 56 57 |
# File 'lib/wikidata_adaptor/rest_api/labels.rb', line 55 def get_property_label(property_id, lang_code) get_json("#{endpoint}/v1/entities/properties/#{CGI.escape(property_id)}/labels/#{lang_code}") end |
#get_property_label_with_language_fallback(property_id, lang_code) ⇒ String
Retrieve a Property's label 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.
69 70 71 |
# File 'lib/wikidata_adaptor/rest_api/labels.rb', line 69 def get_property_label_with_language_fallback(property_id, lang_code) get_json("#{endpoint}/v1/entities/properties/#{CGI.escape(property_id)}/labels_with_language_fallback/#{lang_code}") end |
#get_property_labels(property_id) ⇒ Hash
Retrieve a Property's labels.
45 46 47 |
# File 'lib/wikidata_adaptor/rest_api/labels.rb', line 45 def get_property_labels(property_id) get_json("#{endpoint}/v1/entities/properties/#{CGI.escape(property_id)}/labels") end |
#patch_item_labels(item_id, payload) ⇒ Hash
Apply JSON Patch operations to an Item's labels.
101 102 103 |
# File 'lib/wikidata_adaptor/rest_api/labels.rb', line 101 def patch_item_labels(item_id, payload) patch_json("#{endpoint}/v1/entities/items/#{CGI.escape(item_id)}/labels", payload) end |
#patch_property_labels(property_id, payload) ⇒ Hash
Apply JSON Patch operations to a Property's labels.
111 112 113 |
# File 'lib/wikidata_adaptor/rest_api/labels.rb', line 111 def patch_property_labels(property_id, payload) patch_json("#{endpoint}/v1/entities/properties/#{CGI.escape(property_id)}/labels", payload) end |
#put_item_label(item_id, lang_code, payload) ⇒ String
Replace an Item's label in a specific language.
80 81 82 |
# File 'lib/wikidata_adaptor/rest_api/labels.rb', line 80 def put_item_label(item_id, lang_code, payload) put_json("#{endpoint}/v1/entities/items/#{CGI.escape(item_id)}/labels/#{lang_code}", payload) end |
#put_property_label(property_id, lang_code, payload) ⇒ String
Replace a Property's label in a specific language.
91 92 93 |
# File 'lib/wikidata_adaptor/rest_api/labels.rb', line 91 def put_property_label(property_id, lang_code, payload) put_json("#{endpoint}/v1/entities/properties/#{CGI.escape(property_id)}/labels/#{lang_code}", payload) end |