Add Stamplay js Sdk definitions

This commit is contained in:
ridermansb
2015-09-22 15:58:27 -03:00
parent 09e37435ff
commit 6fde16275a
2 changed files with 75 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
/// <reference path="stamplay-js-sdk.d.ts" />
var userFn = Stamplay.User();
var user = new userFn.Model;
var tags = new Stamplay.Cobject('tag').Collection;
// Signing up
var registrationData = {
email : 'user@provider.com',
password: 'mySecret'
};
user.signup(registrationData).then(function(){
user.set('phoneNumber', '020 123 4567' );
return user.save();
}).then(function(){
var number = user.get('phoneNumber');
console.log(number); // number value is 020 123 4567
});
// Action
var fooMod = new Stamplay.Cobject('foo').Model;
fooMod.fetch(5).then(
function(){
return fooMod.upVote()
}
).then(
function(){
//success callback
}, function( err ){
//error callback
}
)
+40
View File
@@ -0,0 +1,40 @@
// Type definitions for stamplay-js-sdk 1.2.9
// Project: https://github.com/Stamplay/stamplay-js-sdk and https://stamplay.com/docs/jssdk#api-ref-model
// Definitions by: Riderman de Sousa Barbosa <https://github.com/ridermansb/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="..\promises-a-plus\promises-a-plus.d.ts"/>
declare module Stamplay {
export interface IStamplayModel {
signup({}) : PromisesAPlus.Thenable<any>
new() : IStamplayModel
get(property : string)
set(property : string, value: any)
unset(property : string)
fetch(id : any)
destroy() : PromisesAPlus.Thenable<any>
save({}?) : PromisesAPlus.Thenable<any>
}
export interface IStamplayAction {
new() : IStamplayModel
upVote() : PromisesAPlus.Thenable<any>
}
export interface IStamplayUser {
Model : IStamplayModel
}
export interface StamplayStatic {
User() : IStamplayUser
Cobject(collection : string) : void
}
}
declare var Stamplay: Stamplay.StamplayStatic;
declare module "Stamplay" {
export = Stamplay;
}