From 6fde16275a38d5203702d57c928545178450eb92 Mon Sep 17 00:00:00 2001 From: ridermansb Date: Tue, 22 Sep 2015 15:58:27 -0300 Subject: [PATCH] Add Stamplay js Sdk definitions --- stamplay-js-sdk/stamplay-js-sdk-tests.ts | 35 +++++++++++++++++++++ stamplay-js-sdk/stamplay-js-sdk.d.ts | 40 ++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 stamplay-js-sdk/stamplay-js-sdk-tests.ts create mode 100644 stamplay-js-sdk/stamplay-js-sdk.d.ts 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..f17da5c13 --- /dev/null +++ b/stamplay-js-sdk/stamplay-js-sdk-tests.ts @@ -0,0 +1,35 @@ +/// + +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 + } +) 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..50817ee2d --- /dev/null +++ b/stamplay-js-sdk/stamplay-js-sdk.d.ts @@ -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 +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Stamplay { + + export interface IStamplayModel { + signup({}) : PromisesAPlus.Thenable + new() : IStamplayModel + get(property : string) + set(property : string, value: any) + unset(property : string) + fetch(id : any) + destroy() : PromisesAPlus.Thenable + save({}?) : PromisesAPlus.Thenable + } + + export interface IStamplayAction { + new() : IStamplayModel + upVote() : PromisesAPlus.Thenable + } + + export interface IStamplayUser { + Model : IStamplayModel + } + + export interface StamplayStatic { + User() : IStamplayUser + Cobject(collection : string) : void + } +} + +declare var Stamplay: Stamplay.StamplayStatic; + +declare module "Stamplay" { + export = Stamplay; +}