Module: WikidataAdaptor::RestApi::Statements
- Included in:
- WikidataAdaptor::RestApi
- Defined in:
- lib/wikidata_adaptor/rest_api/statements.rb
Overview
Instance Method Summary collapse
-
#delete_item_statement(item_id, statement_id, payload) ⇒ String
Delete a Statement from an Item.
-
#delete_property_statement(property_id, statement_id, payload) ⇒ String
Delete a Statement from a Property.
-
#delete_statement(statement_id, payload) ⇒ String
Delete a Statement (global).
-
#get_item_statement(item_id, statement_id) ⇒ Object
Retrieve a single Statement from an Item.
-
#get_item_statements(item_id, params = { property: nil }) ⇒ Object
Retrieve Statements from an Item.
-
#get_property_statement(property_id, statement_id) ⇒ Object
Retrieve a single Statement from a Property.
-
#get_property_statements(property_id) ⇒ Object
Retrieve Statements from a Property.
-
#get_statement(statement_id) ⇒ Object
Retrieve a single Statement (global).
-
#patch_item_statement(item_id, statement_id, payload) ⇒ Hash
Apply JSON Patch operations to a Statement on an Item.
-
#patch_property_statement(property_id, statement_id, payload) ⇒ Hash
Apply JSON Patch operations to a Statement on a Property.
-
#patch_statement(statement_id, payload) ⇒ Hash
Apply JSON Patch operations to a Statement (global).
-
#post_item_statement(item_id, payload) ⇒ Hash
Add a Statement to an Item.
-
#post_property_statement(property_id, payload) ⇒ Hash
Add a Statement to a Property.
-
#put_item_statement(item_id, statement_id, payload) ⇒ Hash
Replace a Statement on an Item.
-
#put_property_statement(property_id, statement_id, payload) ⇒ Hash
Replace a Statement on a Property.
-
#put_statement(statement_id, payload) ⇒ Hash
Replace a Statement (global).
Instance Method Details
#delete_item_statement(item_id, statement_id, payload) ⇒ String
Delete a Statement from an Item.
127 128 129 |
# File 'lib/wikidata_adaptor/rest_api/statements.rb', line 127 def delete_item_statement(item_id, statement_id, payload) delete_json("#{endpoint}/v1/entities/items/#{CGI.escape(item_id)}/statements/#{statement_id}", payload) end |
#delete_property_statement(property_id, statement_id, payload) ⇒ String
Delete a Statement from a Property.
138 139 140 |
# File 'lib/wikidata_adaptor/rest_api/statements.rb', line 138 def delete_property_statement(property_id, statement_id, payload) delete_json("#{endpoint}/v1/entities/properties/#{CGI.escape(property_id)}/statements/#{statement_id}", payload) end |
#delete_statement(statement_id, payload) ⇒ String
Delete a Statement (global).
148 149 150 |
# File 'lib/wikidata_adaptor/rest_api/statements.rb', line 148 def delete_statement(statement_id, payload) delete_json("#{endpoint}/v1/statements/#{statement_id}", payload) end |
#get_item_statement(item_id, statement_id) ⇒ Object
Retrieve a single Statement from an Item.
17 18 19 |
# File 'lib/wikidata_adaptor/rest_api/statements.rb', line 17 def get_item_statement(item_id, statement_id) get_json("#{endpoint}/v1/entities/items/#{CGI.escape(item_id)}/statements/#{statement_id}") end |
#get_item_statements(item_id, params = { property: nil }) ⇒ Object
Retrieve Statements from an Item.
Optional filter: params[:property] => property ID (e.g., "P31")
11 12 13 14 |
# File 'lib/wikidata_adaptor/rest_api/statements.rb', line 11 def get_item_statements(item_id, params = { property: nil }) query = params[:property] ? "?property=#{CGI.escape(params[:property])}" : "" get_json("#{endpoint}/v1/entities/items/#{CGI.escape(item_id)}/statements#{query}") end |
#get_property_statement(property_id, statement_id) ⇒ Object
Retrieve a single Statement from a Property.
42 43 44 |
# File 'lib/wikidata_adaptor/rest_api/statements.rb', line 42 def get_property_statement(property_id, statement_id) get_json("#{endpoint}/v1/entities/properties/#{CGI.escape(property_id)}/statements/#{statement_id}") end |
#get_property_statements(property_id) ⇒ Object
Retrieve Statements from a Property.
37 38 39 |
# File 'lib/wikidata_adaptor/rest_api/statements.rb', line 37 def get_property_statements(property_id) get_json("#{endpoint}/v1/entities/properties/#{CGI.escape(property_id)}/statements") end |
#get_statement(statement_id) ⇒ Object
Retrieve a single Statement (global).
32 33 34 |
# File 'lib/wikidata_adaptor/rest_api/statements.rb', line 32 def get_statement(statement_id) get_json("#{endpoint}/v1/statements/#{statement_id}") end |
#patch_item_statement(item_id, statement_id, payload) ⇒ Hash
Apply JSON Patch operations to a Statement on an Item.
95 96 97 |
# File 'lib/wikidata_adaptor/rest_api/statements.rb', line 95 def patch_item_statement(item_id, statement_id, payload) patch_json("#{endpoint}/v1/entities/items/#{CGI.escape(item_id)}/statements/#{statement_id}", payload) end |
#patch_property_statement(property_id, statement_id, payload) ⇒ Hash
Apply JSON Patch operations to a Statement on a Property.
106 107 108 |
# File 'lib/wikidata_adaptor/rest_api/statements.rb', line 106 def patch_property_statement(property_id, statement_id, payload) patch_json("#{endpoint}/v1/entities/properties/#{CGI.escape(property_id)}/statements/#{statement_id}", payload) end |
#patch_statement(statement_id, payload) ⇒ Hash
Apply JSON Patch operations to a Statement (global).
116 117 118 |
# File 'lib/wikidata_adaptor/rest_api/statements.rb', line 116 def patch_statement(statement_id, payload) patch_json("#{endpoint}/v1/statements/#{statement_id}", payload) end |
#post_item_statement(item_id, payload) ⇒ Hash
Add a Statement to an Item.
27 28 29 |
# File 'lib/wikidata_adaptor/rest_api/statements.rb', line 27 def post_item_statement(item_id, payload) post_json("#{endpoint}/v1/entities/items/#{CGI.escape(item_id)}/statements", payload) end |
#post_property_statement(property_id, payload) ⇒ Hash
Add a Statement to a Property.
52 53 54 |
# File 'lib/wikidata_adaptor/rest_api/statements.rb', line 52 def post_property_statement(property_id, payload) post_json("#{endpoint}/v1/entities/properties/#{CGI.escape(property_id)}/statements", payload) end |
#put_item_statement(item_id, statement_id, payload) ⇒ Hash
Replace a Statement on an Item.
63 64 65 |
# File 'lib/wikidata_adaptor/rest_api/statements.rb', line 63 def put_item_statement(item_id, statement_id, payload) put_json("#{endpoint}/v1/entities/items/#{CGI.escape(item_id)}/statements/#{statement_id}", payload) end |
#put_property_statement(property_id, statement_id, payload) ⇒ Hash
Replace a Statement on a Property.
74 75 76 |
# File 'lib/wikidata_adaptor/rest_api/statements.rb', line 74 def put_property_statement(property_id, statement_id, payload) put_json("#{endpoint}/v1/entities/properties/#{CGI.escape(property_id)}/statements/#{statement_id}", payload) end |
#put_statement(statement_id, payload) ⇒ Hash
Replace a Statement (global).
84 85 86 |
# File 'lib/wikidata_adaptor/rest_api/statements.rb', line 84 def put_statement(statement_id, payload) put_json("#{endpoint}/v1/statements/#{statement_id}", payload) end |