Skip to content

Javascript wrapper documentation

J. Biolaz edited this page Apr 1, 2014 · 10 revisions

First include urturn-api into your project. There is no others dependencies.

urturn.get let you retrieve post from urturn This method can be called in 3 different ways :

###1 : Using an option object :

urturn.get(options, successCallback, errorCallback)

@param  {Object} options A set of options
{
  queryType {String} : The type of query to perform (ex:  'post'),
  querySelector {String} : The selector to apply to query (ex : username),
  query {String} : The query to get,
  perPage (optional, default 50 or last set value on this query) {Number}: The page to return,
  page (optional, default 0 or last page called + 1) {Number}: the page number
}

@param {Function} successCallback The success callback @param {Function} (optional) errorCallback The errorcallback

###2 : Using a query to return posts directly : urturn.get(query, successCallback, errorCallback)

  @param  {String} query All post matching this query will be returned (ex : 'test')
  @param  {Function} successCallback The success callback
  @param  {Function} (optional) errorCallback The errorcallback

###3 : Using more arguments (type, by, query); urturn.get(type, by, query, successCallback, errorCallback)

  @param  {String} type The type of query to perform (ex:  'post')
  @param  {String} by The selector of query to perform (ex:  'username')
  @param  {String} query The query to perform (ex:  'q')
  @param  {Function} successCallback The success callback
  @param  {Function} (optional) errorCallback The errorcallback

@return {bool} Return true when fails, false when no issues detected

Notes :

  • All result returned are paginated. If no page specific page is asked, the query will return first page first time it is called, second page second time it is called, ....

  • the 'post' type is supported with the following selector :

  • 'id' : Select a post by id. Return only one post

  • 'username' : Select post by username. Return all posts of an user

  • 'expression' : Select post by expression. Return all posts of from a given expression

  • 'query' : Select post by a query. Return all posts matching the query

  • the 'expression' type is supported with the following selector :

  • 'id' : Select a expression by id. Return only one expression

  • 'username' : Select expression by username. Return all expression of an user

  • 'expression' : Select expression by expression name. Return this expression

  • 'query' : Select expression by a query. Return all expressions matching the query