mojio-js-sdk
Version:
Mojio javascript REST client.
365 lines (362 loc) • 10.3 kB
HTML
<html>
<head>
<meta charset='UTF-8'>
<title>CoffeeScript API Documentation</title>
<script src='../javascript/application.js'></script>
<script src='../javascript/search.js'></script>
<link rel='stylesheet' href='../stylesheets/application.css' type='text/css'>
</head>
<body>
<div id='base' data-path='../'></div>
<div id='header'>
<div id='menu'>
<a href='../alphabetical_index.html' title='Index'>
Index
</a>
»
<span class='title'>MojioSDK</span>
</div>
</div>
<div id='content'>
<h1>
Class:
MojioSDK
</h1>
<table class='box'>
<tr>
<td>Defined in:</td>
<td>MojioSDK.coffee</td>
</tr>
<tr>
<td>Inherits:</td>
<td>
Module
</td>
</tr>
</table>
<h2>Overview</h2>
<div class='docstring'>
<p>The Mojio SDK. The Mojio SDK provides a means to easily use Mojio's Authentication Server, REST API, and Push API.</p><p>The SDK works with four code segments: MojioModel, MojioAuth, MojioRest, and MojioPush that work together to provide
methods for constructing fluent method calls.</p><p>MojioModel provides mechanisms for specifying resources and data for resources.</p><p>MojioAuth provides a security layer through OAuth2.</p><p>MojioRest provides ways to make rest calls to the API and preform CRUD operations as well as update associates with
secondary resources like permissions, images or tags.</p><p>MojioPush methods provide a way to subscribe to changes that occur on primary resources. The Push SDK allows data to
be sent to the application without it requesting it through transports like SignalR, Http Post, MQTT or others.</p><p>Four programming styles are supported, synchronous, asynchronous with callbacks (node js style), asynchronous with promises,
and asynchronous with reactive streams. Choose one style and or multiple, but each fluent call must operate in one of
these modes at the end of the fluent chain.</p>
<div class='examples'>
<h3>Examples:</h3>
<h4>
initate a fluent chain to retrieve a the vehicle given using a synchronous call. (don't do this very often).
</h4>
<pre><code class='coffeescript'>sdk = new MojioSDK()
result = sdk.get().vehicle(vehicleId).sync()
...</code></pre>
<h4>
initate a fluent chain to retrieve a the vehicle given using an asynchronous initiation with a callback.
</h4>
<pre><code class='coffeescript'>sdk = new MojioSDK()
sdk.get().vehicle(vehicleId).callback((error, result) ->
...
)</code></pre>
<h4>
initate a fluent chain to retrieve a the vehicle given using an asynchronous initiation with a promise.
</h4>
<pre><code class='coffeescript'>sdk = new MojioSDK()
promise = sdk.get().vehicle(vehicleId).callback()
...</code></pre>
<h4>
initate a fluent chain to retrieve a the vehicle given using an asynchronous initiation with a reative stream.
</h4>
<pre><code class='coffeescript'>sdk = new MojioSDK()
stream = sdk.get().vehicle(vehicleId).callback()
...</code></pre>
</div>
</div>
<div class='tags'>
</div>
<h2>Instance Method Summary</h2>
<ul class='summary'>
<li>
<span class='signature'>
<a href='#sync-dynamic'>
#
(void)
<b>sync</b><span>()</span>
</a>
</span>
<span class='desc'>
Sync initiates the fluent chain in a synchronous call, blocking until results are returned.
</span>
</li>
<li>
<span class='signature'>
<a href='#callback-dynamic'>
#
(void)
<b>callback</b><span>(callback)</span>
</a>
</span>
<span class='desc'>
The 'callback' method initiates the fluent chain asynchronously by providing a callback(error, result) that will be called once the request has returned.
</span>
</li>
<li>
<span class='signature'>
<a href='#redirect-dynamic'>
#
(void)
<b>redirect</b><span>(redirectClass = null)</span>
</a>
</span>
<span class='desc'>
The 'redirect' method initiates the fluent chain by performing a redirect given the passed in redirecting technology.
</span>
</li>
<li>
<span class='signature'>
<a href='#url-dynamic'>
#
(string)
<b>url</b><span>()</span>
</a>
</span>
<span class='desc'>
return the url formed by the fluent chain instead of actually making the rest call.
</span>
</li>
<li>
<span class='signature'>
<a href='#show-dynamic'>
#
(object)
<b>show</b><span>()</span>
</a>
</span>
<span class='desc'>
return the internal state object.
</span>
</li>
<li>
<span class='signature'>
<a href='#me-dynamic'>
#
(void)
<b>me</b><span>()</span>
</a>
</span>
<span class='desc'>
</span>
</li>
</ul>
<h2>Instance Method Details</h2>
<div class='methods'>
<div class='method_details'>
<p class='signature' id='sync-dynamic'>
#
(void)
<b>sync</b><span>()</span>
<br>
</p>
<div class='docstring'>
<p>Sync initiates the fluent chain in a synchronous call, blocking until results are returned. Sync is one of four
ways to initiate fluent requests, one of which must be called for requests to be made. This is the least desireable
way to initiate a call because it will block until an answer is returned or a timeout occurs.
@public</p>
</div>
<div class='tags'>
</div>
</div>
<div class='method_details'>
<p class='signature' id='callback-dynamic'>
#
(void)
<b>callback</b><span>(callback)</span>
<br>
</p>
<div class='docstring'>
<p>The 'callback' method initiates the fluent chain asynchronously by providing a callback(error, result) that will be called once
the request has returned. It is one of four ways to initiate fluent requests, one of which must be called for requests to be made.
In the case of a redirect (in the auth sdk) control will be returned to a url given and you must call authorize again with the results
until 'true' is given in the callback results.
@public</p>
</div>
<div class='tags'>
<h3>Parameters:</h3>
<ul class='param'>
<li>
<span class='name'>callback</span>
<span class='type'>
(
<tt>function</tt>
)
</span>
—
<span class='desc'>A function to call when the fluent chain is complete. </span>
</li>
</ul>
</div>
</div>
<div class='method_details'>
<p class='signature' id='redirect-dynamic'>
#
(void)
<b>redirect</b><span>(redirectClass = null)</span>
<br>
</p>
<div class='docstring'>
<p>The 'redirect' method initiates the fluent chain by performing a redirect given the passed in redirecting
technology. The class or object passed in must follow the iRedirect interface and must have a function
called "redirect". For browser environments, pass in "{ redirect: (url) -> window.location = url }". For
NodeJS express, pass in ServerResponse ('res' passed into the route expression in the examples). For other
technologies, this class will depend on the framework used to reply to server requests. Note that even
in server environments, the redirect call may need to be wrapped as it is in the browser.
@public
@ return {object} this</p>
</div>
<div class='tags'>
<h3>Parameters:</h3>
<ul class='param'>
<li>
<span class='name'>redirectClass</span>
<span class='type'>
(
<tt>object</tt>
)
</span>
—
<span class='desc'>An object with a 'redirect' function implement. </span>
</li>
</ul>
</div>
</div>
<div class='method_details'>
<p class='signature' id='url-dynamic'>
#
(string)
<b>url</b><span>()</span>
<br>
</p>
<div class='docstring'>
<p>return the url formed by the fluent chain instead of actually making the rest call.</p>
</div>
<div class='tags'>
<h3>Returns:</h3>
<ul class='return'>
<li>
<span class='type'></span>
(
<tt>string</tt>
)
—
<span class='desc'>Fully formed REST url </span>
</li>
</ul>
</div>
</div>
<div class='method_details'>
<p class='signature' id='show-dynamic'>
#
(object)
<b>show</b><span>()</span>
<br>
</p>
<div class='docstring'>
<p>return the internal state object. Used for debugging this sdk.</p>
</div>
<div class='tags'>
<h3>Returns:</h3>
<ul class='return'>
<li>
<span class='type'></span>
(
<tt>object</tt>
)
—
<span class='desc'>Internal state object built up by the fluent chain. </span>
</li>
</ul>
</div>
</div>
<div class='method_details'>
<p class='signature' id='me-dynamic'>
#
(void)
<b>me</b><span>()</span>
<br>
</p>
</div>
</div>
</div>
<div id='footer'>
November 17, 15 17:54:44 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>
2.0.11
✲
Press H to see the keyboard shortcuts
✲
<a href='http://twitter.com/netzpirat' target='_parent'>@netzpirat</a>
✲
<a href='http://twitter.com/_inossidabile' target='_parent'>@_inossidabile</a>
</div>
<iframe id='search_frame'></iframe>
<div id='fuzzySearch'>
<input type='text'>
<ol></ol>
</div>
<div id='help'>
<p>
Quickly fuzzy find classes, mixins, methods, file:
</p>
<ul>
<li>
<span>T</span>
Open fuzzy finder dialog
</li>
</ul>
<p>
Control the navigation frame:
</p>
<ul>
<li>
<span>L</span>
Toggle list view
</li>
<li>
<span>C</span>
Show class list
</li>
<li>
<span>I</span>
Show mixin list
</li>
<li>
<span>F</span>
Show file list
</li>
<li>
<span>M</span>
Show method list
</li>
<li>
<span>E</span>
Show extras list
</li>
</ul>
<p>
You can focus and blur the search input:
</p>
<ul>
<li>
<span>S</span>
Focus search input
</li>
<li>
<span>Esc</span>
Blur search input
</li>
</ul>
</div>
</body>
</html>