Skip to content

Instantly share code, notes, and snippets.

@aaronksaunders
Created April 24, 2012 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronksaunders/2475485 to your computer and use it in GitHub Desktop.
Save aaronksaunders/2475485 to your computer and use it in GitHub Desktop.
Changes to ti.cloud.js to support Events in Appcelerator Cloud Services - app.js
var Cloud = require('ci.cloud');
var moment = require('moment');
var data = {
start_time : '2011-03-22T20:59:50+0000',
duration : '3600',
name : 'Appcelerator Meetup Group',
};
/*
*/
var index = 0, actions = [];
function next() {
actions[index++]();
}
actions.push(function() {
Cloud.Users.login({
login : 'testuser',
password : 'password'
}, function(e) {
if(e.success) {
var user = e.users[0];
Ti.API.info('id: ' + user.id + ' name: ' +user.first_name + ' ' + user.last_name);
} else {
alert('Error:\\n' + ((e.error && e.message) || JSON.stringify(e)));
}
next();
});
});
/* actions.push(function() {
Cloud.Events.create(data, function(e) {
if(e.success) {
for(var i = 0; i < e.events.length; i++) {
var event = e.events[i];
Ti.API.info('id: ' + event.id + ' event: ' + event.name + ' event details: ' + event.details + ' event duration: ' + event.duration + ' updated_at: ' + event.updated_at + ' user: ' + event.user.first_name + ' ' + event.user.last_name);
}
} else {
alert('Error:\n' + ((e.error && e.message) || JSON.stringify(e)));
}
next();
});
});
*/
actions.push(function() {
Cloud.Events.query({
page : 1,
per_page : 20,
}, function(e) {
if(e.success) {
for(var i = 0; i < e.events.length; i++) {
var event = e.events[i];
Ti.API.info('id: ' + event.id + ' event: ' + event.name + ' event details: ' + event.details + ' event duration: ' + event.duration + ' updated_at: ' + moment(event.updated_at +"").format() + ' user: ' + event.user.first_name + ' ' + event.user.last_name);
}
} else {
alert('Error:\\n' + ((e.error && e.message) || JSON.stringify(e)));
}
});
})
next();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment