Class: MojioRestSDK

Defined in: MojioRestSDK.coffee
Inherits: MojioAuthSDK

Overview

The REST segment of the Mojio SDK. The REST methods provide a mechanism to retrieve, create, save, or destroy objects in the Mojio API. Availablity of REST calls is subject to the access rights of the user authenticated.

There are two types of resources within the Mojio Domain Model, primary objects and secondary associated objects. Primary objects are: Vehicles, Users, Mojios, Trips, Apps, and Groups. Secondary Objects are Images and Tags.

This segement of the SDK provides a set of verbs that represent actions within the fluent chain.

Verbs on primary resources are GET, PUT, POST, DELETE. QUERY is an alias for GET, both provide a subset of ODATA style criteria for retrieval of lists of objects. ODATA verbs include: TAKE, TOP, SKIP, FILTER, SELECT, and ORDERBY. Direct inspection of the code will reveal aliases for all of these verbs.

Verbs available for actions on secondary resources provide mechanisms to associate secondary resources with primary. These are ADD, SET, REMOVE, and GET.

Examples:

mojioRestSdk = new MojioSDK({sdk: MojioRestSDK}) # instantiate the mojioSDK to do only REST and authentication methods.

Direct Known Subclasses

MojioPushSDK

Instance Method Summary

Inherited Method Summary

Methods inherited from MojioAuthSDK

#authorize #unauthorize #token #parse #refresh #login #consent #loginAndConsent #prompt #scope #username #email #password #credentials #with #getToken #setup #setCriteria #users #vehicles #mojios #trips #apps #groups #permissions #images #tags #details #histories #states #locations #mock

Instance Method Details

# (object) put(object_or_json_string)

Put sets up the fluent chain in order to save an already persisted object in the Mojio system. Use with one of the ModelSDK calls to specify the data for a vehicle, mojio, user, trip, group, or permission. (alias: save and update)

Examples:

sdk.put().vehicle([resourceObject])

Returns:

  • ( object ) — this

# (object) post(object_or_json_string)

Post sets up the fluent chain in order to create a new persisted object in the Mojio system. Use with one of the ModelSDK calls to specify the data for a vehicle, mojio, user, trip, group, or permission. (alias: create)

Examples:

sdk.post().vehicle([resourceObject])

Returns:

  • ( object ) — this

# (object) delete(id_or_array_of_ids)

Delete sets up the fluent chain to delete an existing persisted object in the Mojio system. Use with one of the ModelSDK calls to specify the Id for a vehicle, mojio, user, trip, group, or permission. (alias: destroy)

Examples:

sdk.delete().vehicle([resourceId])

Returns:

  • ( object ) — this

# (object) get(id_example_or_query)

Get sets up the fluent chain for retrieving an existing persisted object in the Mojio system. Use with one of the ModelSDK calls to specify the Id for a vehicle, mojio, user, trip, group, or permission. (alias: query)

Examples:

sdk.get().mojio([resourceId]).submit()

sdk.get().tag(key).vehicle(vehicleId).submit()

Returns:

  • ( object ) — this

# (object) query(id_example_or_query)

Query sets up the fluent chain for retrieving an existing persisted object in the Mojio system. Use with one of the ModelSDK calls to specify the type of object for a vehicle, mojio, user, trip, group, or permission. The query is specified with follow on query specificaiton calls: select, top, skip, orderby, fields and desc. (alias: get)

Examples:

sdk.get/query().vehicles().fields([FieldsList]).select([selectString]).top(#).skip(#).orderby(field).desc(bool)

Returns:

  • ( object ) — this

# (object) select(id_example_or_query)

Select specifies a criteria for the objects that will be returned. (alias: where)

Examples:

sdk.get/query().vehicles().select("query string").submit()

Returns:

  • ( object ) — this

# (object) filter(filter)

Filter specifies which fields are returned in the objects returned. (alias: fields)

Examples:

sdk.get/query().vehicles().top(#).filter(["Location", "Speed", "RPM"].submit()

Returns:

  • ( object ) — this

# (object) top(top)

Top specifies that the query should only return the given number of results. (alias: limit)

Examples:

sdk.get/query().vehicles().top(#).submit()

Returns:

  • ( object ) — this

# (object) skip(offset)

Skip specifies that the query should skip the specified number of records when it return the results. (alias: offset)

Examples:

sdk.get/query().vehicles().top(#).skip(#).submit()

Returns:

  • ( object ) — this

# (object) orderby(field, desc = null)

Orderby specifies that the query results should be ordered by the given field and if it's descending (true) or ascending (false). The default is by id ascending. (partial alias: desc)

Examples:

sdk.get/query().vehicles().top(#).skip(#).orderby(TimeStamp, true).submit()

Returns:

  • ( object ) — this

# (object) field(field, desc = null)

Field specifies that the query results should be ordered by the given field (partial alias: desc)

Examples:

sdk.get/query().vehicles().top(#).skip(#).field(TimeStamp).desc().submit()

Returns:

  • ( object ) — this

# (object) add(field, desc = null)

Add allows the code to associate add a tag to a vehicle, mojio, group, user, or app. When used with the Sharing SDK, it allows the code to add users to groups or to add permission 'access rules' to groups for resources.

Examples:

sdk.add().tag(key, value).vehicle(vehicleId).submit()

Returns:

  • ( object ) — this

# (object) set(field, desc = null)

Set allows the code to associate an image with a vehicle or user, a tag with a vehicle, mojio, group, user, or app. When used with the Sharing SDK, it allows the code to set users for groups or to set permission 'access rules' to resources from groups.

Examples:

sdk.add().tag(key, value).vehicle(vehicleId).submit()

Returns:

  • ( object ) — this

# (object) remove(field, desc = null)

Remove allows the code to remove an associated image with a vehicle or user, or remove a tag from a vehicle, mojio, group, user, or app. (alias: revoke)

Examples:

sdk.remove().tag(key).vehicle(vehicleId).submit()

Returns:

  • ( object ) — this

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: