Stamplay JavaScript SDK
This library gives you access to the powerful Stamplay cloud platform from your JavaScript app. For more info on Stamplay and its features, see the website or the JavaScript guide
The SDK is available for on NPM, Bower and on our CDN.
$ npm install -g stamplay-sdk
$ bower install -g stamplay-js-sdk
To get started import the library in your project and initialize it by calling init
function with your appId
<script src="https://cdn.stamplay.com/libs/stamplay-js-sdk/2.1.4/stamplay.min.js"></script>
<script> Stamplay.init("APPID"); </script>
Register a new user:
var data = {
"email":"john@stamplay.com",
"password":"john123"
}
Stamplay.User.signup(data, function(error, result){
//manage the result and the error
})
Store data using Objects:
var data = {
"description":"A description",
"title":"New title"
}
Stamplay.Object('foo').save(data, function(error, result){
//manage the result and the error
})
Skip the callback to get a promise back
var data = {
"description":"A description",
"title":"New title"
}
Stamplay.Object('foo').save(data).then(function(result){
//manage the result
},function(error){
//manage the error
})
This JavaScript SDK expose the following components:
save(data, [callback])
get(data, [callback])
getById(id, data, [callback])
remove(id, [callback])
update(id, data, [callback] )
currentUser([callback])
login(data, [callback])
socialLogin(provider)
signup(data, [callback])
logout(async)
resetPassword(data, [callback])
getRoles([callback])
getRole(id, [callback])
setRole(id, roleId, [callback])
save(data, [callback])
get(data, [callback])
getById(id, data, [callback])
remove(id, [callback])
update(id, data, [callback])
patch(id, data, [callback])
findByCurrentUser([attr], [data], [callback])
push(id, attribute, data, [callback])
post(data, queryParams, [callback])
get(queryParams, [callback])
put(data, queryParams, [callback])
patch(data, queryParams, [callback])
delete(queryParams, [callback])
post(data, [callback])
charge(userId, token, amount, currency, [callback])
createCreditCard(userId, token, [callback])
createCustomer(userId, [callback])
createSubscriptionuserId, planId, [callback])
deleteSubscription(userId, subscriptionId, options, [callback])
getCreditCard(userId, [callback])
getSubscription(userId, subscriptionId, [callback])
getSubscriptions(userId, options, [callback])
updateCreditCard(userId, token, [callback])
updateSubscription(userId, subscriptionId, options, [callback])
Also this components the sdk have some support objects to help you in common operation:
greaterThan(attr, value)
greaterThanOrEqual(attr, value)
lessThan(attr, value)
lessThanOrEqual(attr, value)
pagination(page, per_page)
between(attr, value1, value2)
equalTo(attr, value)
notEqualTo(attr, value)
exists(attr)
notExists(attr)
sortAscending(attr)
sortDescending(attr)
populate()
populateOwner()
select(attr,...)
regex(attr, regex, options)
near(type, coordinates, maxDistance, minDistance)
nearSphere(type, coordinates, maxDistance, minDistance)
geoIntersects(type, coordinates)
geoWithinGeometry(type, coordinates)
geoWithinCenterSphere(coordinates, radius)
or(query,..)
exec([callback])
To build a production ready library you need to have NPM and Bower installed and then run those two commands:
npm install && bower install
grunt build
You can also download this project and using all the precompiled files in src folder
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Go to API Reference to see a lot of examples. Enjoy!