Module: WikidataAdaptor::RestApi::Properties

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

Overview

Instance Method Summary collapse

Instance Method Details

#get_property(property_id) ⇒ Hash

Retrieve a single Wikibase Property by ID.

Parameters:

  • property_id (String)

    The ID of the required Property.

Returns:

  • (Hash)

    A single Wikibase Property.



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

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

#patch_property(property_id, payload) ⇒ Hash

Apply JSON Patch operations to a Property.

Parameters:

  • property_id (String)

    The ID of the Property.

  • payload (Hash)

    JSON Patch operations and edit metadata.

Returns:

  • (Hash)

    The updated Property.



31
32
33
# File 'lib/wikidata_adaptor/rest_api/properties.rb', line 31

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

#post_property(payload) ⇒ Hash

Create a Wikibase Property.

Parameters:

  • payload (Hash)

    Property containing a Wikibase Property and edit metadata.

Returns:

  • (Hash)

    A single Wikibase Property.



21
22
23
# File 'lib/wikidata_adaptor/rest_api/properties.rb', line 21

def post_property(payload)
  post_json("#{endpoint}/v1/entities/properties", payload)
end