Commit fc616d77 authored by Mihkel Putrinš's avatar Mihkel Putrinš

js: getChilds and getReferrals

parent 1d65b110
......@@ -3,7 +3,7 @@ entulib
Library for authenticated access to Entu database API
## 5 methods to please your application
## 7 javascript (5 python) methods to please your application
### python 3
#### class EntuLib():
......@@ -31,6 +31,12 @@ Library for authenticated access to Entu database API
> - getEntity: function (callback, entity_id)
> - on success callback ({result: entity, time: 0.009})
> - else callback ({time: 0.009, error: "Entity with given ID is not found!"})
> - getChilds: function (callback, entity_id)
> - on success callback ({count: count, result: {}, time: 0.097})
> - else callback ({count: 0, result: {definition: {entities:[entities]}}, time: 0.094})
> - getReferrals: function (callback, entity_id)
> - on success callback ({result: entity, time: 0.009})
> - else callback ({count: 0, result: {definition: {entities:[entities]}}, time: 0.095})
> - findEntity: function (callback, definition, query, limit)
> - on success callback ({ count: count, result: [entitylist], time: 0.011})
> - else callback ({ count: 0, result: [], time: 0.086 })
......
......@@ -82,11 +82,17 @@ var EntuLib = function EntuLib(entu_user_id, entu_user_key, entu_url) {
__submit_it(callback, path, 'GET')
},
// Return childs of entity
listChilds: function (callback, entity_id) {
getChilds: function (callback, entity_id) {
var data = __create_policy()
var path = API_VERSION + 'entity-' + entity_id + '/childs?' + data
__submit_it(callback, path, 'GET')
},
// Return entity's referrals
getReferrals: function (callback, entity_id) {
var data = __create_policy()
var path = API_VERSION + 'entity-' + entity_id + '/referrals?' + data
__submit_it(callback, path, 'GET')
},
// definition = property's dataproperty name
createEntity: function (callback, parent_id, definition, properties) {
var entu_query = {}
......@@ -156,6 +162,8 @@ var entu_user_key = 'Write your Entu key here'
var entu_url = 'yourdomain.entu.ee'
var EntuLib = new EntuLib(entu_user_id, entu_user_key, entu_url)
// EntuLib.getEntity(print_result, 684)
// EntuLib.getChilds(print_result, 684)
// EntuLib.getReferrals(print_result, 684)
// EntuLib.findEntity(print_result, 'person', 'test', 10)
// EntuLib.createEntity(print_result, 610, 'person', {'forename':'test3','surname':'test3'})
// EntuLib.addProperties(print_result, 684, 'person', {'email':'foo@bar','user':'zaza@google'})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment