Created
December 10, 2014 00:59
-
-
Save marshallbrekka/01f5ee927f96ba99388e to your computer and use it in GitHub Desktop.
Mobile App Account Model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fakeIds = 555; | |
var proxyAccounts = { | |
active: true, | |
apr: 15.99, | |
balance: 2254.86, | |
lastUpdated : 1372910701811, | |
id: 1, | |
minimum: 35, | |
name: "JetBlue Card Orig", | |
number: "1000", | |
type: "credits", | |
siteId : 10 | |
}]; | |
var accounts = new PersistentSpec("accounts/1/accounts", { | |
seq : true, | |
proxy : { | |
get : function(opts, promise) { | |
promise.resolve({"_control" : {result : "ok"}, response : proxyAccounts}); | |
}, | |
add: function(opts, promise) { | |
var id = ++fakeIds; | |
opts.id = id; | |
proxyAccounts.push(opts); | |
promise.resolve({"_control": { result: "ok" }, response: id }); | |
}, | |
update: function(opts, promise) { | |
promise.resolve({"_control" : {result : "ok"}}); | |
}, | |
remove: function(opts, promise) { | |
proxyAccounts = _.filter(proxyAccounts, function(account) { | |
return account.id !== opts.id; | |
}); | |
promise.resolve({"_control" : {result : "ok"}}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment