diff --git a/stamplay-js-sdk/stamplay-js-sdk-tests.ts b/stamplay-js-sdk/stamplay-js-sdk-tests.ts new file mode 100644 index 000000000..bfc229d49 --- /dev/null +++ b/stamplay-js-sdk/stamplay-js-sdk-tests.ts @@ -0,0 +1,36 @@ +/// + +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 + } +) diff --git a/stamplay-js-sdk/stamplay-js-sdk.d.ts b/stamplay-js-sdk/stamplay-js-sdk.d.ts new file mode 100644 index 000000000..154dc414e --- /dev/null +++ b/stamplay-js-sdk/stamplay-js-sdk.d.ts @@ -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 +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Stamplay { + + export interface IStamplayModel { + signup({}) : PromisesAPlus.Thenable + new() : IStamplayModel + get(property : string) : any + set(property : string, value: any) : void + unset(property : string) : void + fetch(id : any) : PromisesAPlus.Thenable + destroy() : PromisesAPlus.Thenable + save({}?) : PromisesAPlus.Thenable + upVote() : PromisesAPlus.Thenable + } + + 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; +}