Skip to content

Instantly share code, notes, and snippets.

@dbaba
dbaba / ModelMapper.remove.singleton.example.js
Last active December 9, 2015 22:08
ModelMapper.remove() for Singleton Models from MOAT js API Document
// Prepares an update operation.
var mySingletonTypeMapper =
session.newModelMapperStub('MySingletonType');
// Enqueues the remove operation
mySingletonTypeMapper.remove({
error : function(type, code) { // ---- (2)
if (type == 'NOT_FOUND') {
...
}
@dbaba
dbaba / ModelMapper.add.singleton.example.js
Last active December 9, 2015 22:08
ModelMapper.add() for Singleton Models from MOAT js API Document
// Prepares an add operation.
var mySingletonTypeMapper =
session.newModelMapperStub('MySingletonType');
// Creates or retrieves a model object
var obj = mySingletonTypeMapper.newModelStub();
obj.myProperty = 'myValue';
obj.myIntProperty = 12345;
obj.myBooleanProperty = true;
@dbaba
dbaba / NetworkDevice-FindByPushAddresses.example.js
Created July 20, 2012 04:57
/NetworkDevice/FindByPushAddresses from MOAT REST API Document
curl -X POST -H "Accept:application/json" \
-d "region=**&type=B&addresses=my.gateway&token=9999999999999999999999999999999999999999999" \
http://moat-iot-runtime:[port]/dms/restgw/NetworkDevice/FindByPushAddresses
@dbaba
dbaba / Admin-Login.response.example.json
Created July 20, 2012 04:46
/Admin/Login response from MOAT REST API Document
{
"groupRoleUid":"-9223372036854775808",
"lastLoggedIn":"Wed, 25 Apr 2012 07:28:25 GMT",
"roleUid":"8aa01502329e284a01329f37e3ef0154",
"sessionKey":"11876d44-b285-4f9b-a9cb-a6b7a6b91a0c",
"userId":"user@domain",
"accessToken":"9999999999999999999999999999999999999999999"
}
@dbaba
dbaba / Admin-Login.example.sh
Created July 20, 2012 03:00
/Admin/Login from MOAT REST API Document
curl -X POST -H "Accept:application/json" \
-d "w=your-app-id&x=user@domain&y=passwordhash%3d&z=" \
http://moat-iot-runtime:[port]/dms/restgw/Admin/Login
@dbaba
dbaba / ModelMapper.updateFields.example.js
Last active October 7, 2015 09:27
ModelMapper.updateField() from MOAT js API Document
// Get the UID
var uid = ....;
// Prepares an update operation.
var myArrayTypeMapper =
session.newModelMapperStub('MyArrayType');
// Creates or retrieves a model object
var obj = ...;
obj.myProperty = 'myValue';
@dbaba
dbaba / ModelMapper.update.example.js
Last active October 7, 2015 09:27
ModelMapper.update() from MOAT js API Document
// Prepares an update operation.
var myArrayTypeMapper =
session.newModelMapperStub('MyArrayType');
// Creates or retrieves a model object
var obj = ...;
obj.myProperty = 'myValue';
obj.myIntProperty = 12345;
obj.myBooleanProperty = true;
@dbaba
dbaba / ModelMapper.updateFields.singleton.example.js
Last active October 7, 2015 09:27
ModelMapper.updateFields() for Singleton Models from MOAT js API Document
// Prepares an update operation.
var mySingletonTypeMapper =
session.newModelMapperStub('MySingletonType');
// Creates or retrieves a model object
var obj = ...;
obj.myProperty = 'myValue';
obj.myIntProperty = 12345;
obj.myBooleanProperty = true;
@dbaba
dbaba / ModelMapper.update.singleton.example.js
Last active October 7, 2015 09:27
ModelMapper.update() for Singleton Models from MOAT js API Document
// Prepares an update operation.
var mySingletonTypeMapper =
session.newModelMapperStub('MySingletonType');
// Creates or retrieves a model object
var obj = ...;
obj.myProperty = 'myValue';
obj.myIntProperty = 12345;
obj.myBooleanProperty = true;
@dbaba
dbaba / Model.Command.example.js
Last active October 7, 2015 09:27
Model's command from MOAT js API Document
// Gets a UID of an object to be fetched.
var uid = 'an-identifier-for-object';
var myArrayTypeMapper =
session.newModelMapperStub('MyArrayType');
var obj = myArrayTypeMapper.newModelStub(uid);
obj.doIt(session, 'param_data', {
success : function(reuslt) {
if (result.async) {