Merge pull request #5958 from Ridermansb/master

Add Stamplay js Sdk definitions
This commit is contained in:
Horiuchi_H
2015-10-02 11:46:12 +09:00
2 changed files with 74 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
/// <reference path="stamplay-js-sdk.d.ts" />
var userFn = Stamplay.User();
var user = new userFn.Model;
var colTags = Stamplay.Cobject('tag');
var tags = new colTags.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 colFoo = Stamplay.Cobject('foo');
var fooMod = new colFoo.Model();
fooMod.fetch(5).then(
function(){
return fooMod.upVote()
}
).then(
function(){
//success callback
}, function( err : any ){
//error callback
}
)
+38
View File
@@ -0,0 +1,38 @@
// Type definitions for stamplay-js-sdk 1.2.9
// Project: https://github.com/Stamplay/stamplay-js-sdk
// 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) : any
set(property : string, value: any) : void
unset(property : string) : void
fetch(id : any) : PromisesAPlus.Thenable<any>
destroy() : PromisesAPlus.Thenable<any>
save({}?) : PromisesAPlus.Thenable<any>
upVote() : PromisesAPlus.Thenable<any>
}
export interface IStamplayObject {
Model : IStamplayModel
Collection : any
}
export interface StamplayStatic {
User() : IStamplayObject
Cobject(object : string) : IStamplayObject
}
}
declare var Stamplay: Stamplay.StamplayStatic;
declare module "Stamplay" {
export = Stamplay;
}