Ox.API: fix docs, return request id from API call
This commit is contained in:
parent
2d4ab2b32d
commit
daec992536
1 changed files with 21 additions and 13 deletions
|
@ -1,11 +1,23 @@
|
|||
'use strict';
|
||||
|
||||
/*@
|
||||
Ox.API <f> bind remote api to object
|
||||
Ox.API <f> Remote API controller
|
||||
options <o> Options object
|
||||
timeout <n|60000> request timeout
|
||||
url <s> request url
|
||||
callback <f> called once api discover is done
|
||||
([options, ] callback) -> <o> API controller
|
||||
api <f> Remote API discovery (calls the API's `api` method)
|
||||
(callback) -> <n> Request id
|
||||
callback <f> Callback functions
|
||||
.* <f> Remote API method call
|
||||
([data, [age, ]]callback) -> <n> Request id
|
||||
data <o> Request data
|
||||
age <n|-1> Max-age in ms (0: not from cache, -1: from cache)
|
||||
callback <f> Callback function
|
||||
cancel <f> Cancels a request
|
||||
(id) -> <u> undefined
|
||||
id <n> Request id
|
||||
@*/
|
||||
|
||||
Ox.API = function(options, callback) {
|
||||
|
@ -20,7 +32,7 @@ Ox.API = function(options, callback) {
|
|||
},
|
||||
that = {
|
||||
api: function(callback) {
|
||||
Ox.Request.send({
|
||||
return Ox.Request.send({
|
||||
url: self.options.url,
|
||||
data: {action: 'api'},
|
||||
callback: callback
|
||||
|
@ -37,12 +49,6 @@ Ox.API = function(options, callback) {
|
|||
url: self.options.url
|
||||
});
|
||||
|
||||
/*@
|
||||
api <o> bakcend API
|
||||
[action] <f> all api requests available on backend
|
||||
cancel <f> cancel a request
|
||||
options <f> get or set options
|
||||
@*/
|
||||
that.api(function(result) {
|
||||
Ox.forEach(result.data.actions, function(val, key) {
|
||||
that[key] = function(/*data, age, callback*/) {
|
||||
|
@ -70,5 +76,7 @@ Ox.API = function(options, callback) {
|
|||
});
|
||||
callback && callback();
|
||||
});
|
||||
|
||||
return that;
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue