Behaviour-driven objects served on an API
In real life, everything is an object. Every object has characteristics, behaviours and actions.
In SPOO, we have adopted the way real life objects work, making them available through our APIs.
Code Examples
Object Anatomy
Object operations
Interval-driven automations
React to changes
Intitalisation + User auth.
See more in the API docs
// Objects are represented as JSON
{
"_id": "5a8e80d0e1e1282f7d3121e9",
"role": "object",
"name": "my name",
"type": "my type",
"applications": [],
"inherits": [],
"properties":
{
"my prop": {
"type" : "shortText",
"value" : "hello world",
},
"permissions": {},
"onCreate": null,
"onDelete": null,
}
// Initialize your client.
spoo = new Client("myworkspace").AppId("myapp");
// User login
spoo.io().auth("username", "password", function(data, err)
{
if(err) console.log("login failed")
else console.log("login success")
}, true)
// User logout
spoo.io().logout(function(data, err){
if(err) console.log("logout failed")
else console.log("logout success")
})
// Add an object
spoo.io().Object({
name : "car",
properties: {
color:
{
type: "shortText",
value: "blue"
}
}
}).add(function(data, err){
console.log("ok")
})
// Update an object
spoo.io().Object("28rh8qhwf")
.addProperty({
"doors" : {
type: "number",
value: 4
}
}).
.setPropertyValue("color", "black")
.save(function(data, err){
console.log("ok")
})
// Add "inspection" automation
spoo.io().Object("28rh8qhwf")
.addProperty({
"inspection" : {
type: "event",
interval: "P2Y",
action: "dsl.email('peter@griffin.com', 'Car Inspection', 'There is an upcoming inspection...')"
}
}).
.save(function(data, err){
console.log("ok")
})
/*
The property of type "event" will be observed by SPOO. On due date, the action, here an email, will be triggered automatically.
*/
// Create a backup, when an object is changed
spoo.io().Object("28rh8qhwf")
.setOnChange("self.object.type = 'backup'; dsl.Object(self.object).add()").
.save(function(data, err){
console.log("ok")
})
/*
When changed, the action will create a new object, based on the current object, thus create a momentum backup.
*/
How it'll work
Application access SPOO Cloud via a REST API (or an SDK) in the context of a user's workspace and the app identifier:
This works the same way for every workspace/user and every app, meaning that an application can be consumed from any workspace.
// REST
'spoo.io/api/client/WORSPACE/app/YOURAPP/...'
// JS
spoo = new SPOO_Client("workspace").AppId("yourapp")
This works the same way for every workspace/user and every app, meaning that an application can be consumed from any workspace.