Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Api.gs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@
// ======
//
// This local object provides internal access to the Trello API.
/* Not sure what the above means. */
//

var Api_ = {

/**
* The API object manages the API version value
*/

setVersion: function (version) {

// version checked in setProperty_()

setProperty_(
PROPERTY_API_VERSION,
version,
Expand Down
20 changes: 10 additions & 10 deletions App.gs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
// 34567890123456789012345678901234567890123456789012345678901234567890123456789

// JSHint (this file) - TODO

// App.gs
// ======
//
// This object provides the external interface to the TrelloApp library

/* blinks notes:
Just like API.gs I am unsure what the above line "MEANS".
My goal with this project is to see an object I can instantiate
regardless of anything else in a Google Doc/Sheet/Presentation/Drawing/etc.
and have the object manage Trello behind the scenes FOR the user.
*/
function App(version) {

Api_.setVersion(setDefault_(version, '1'))
Expand All @@ -16,7 +20,6 @@ function App(version) {
* URI to the user to trigger Trello authorization pop-up, then get
* them to try again.
*/

// TODO - Probably a nicer way of doing that

App.prototype.getAuthorizationUri = function() {
Expand All @@ -27,9 +30,8 @@ function App(version) {


/**
*
* A method of App to get all boards of current user.
*/

App.prototype.getMyBoards = function() {

var config = {
Expand All @@ -50,9 +52,8 @@ function App(version) {
} // App.prototype.getMyBoards()

/**
*
* A method of App to get all lists from specific board
*/

App.prototype.getBoardLists = function(boardId) {

var config = {
Expand All @@ -77,9 +78,8 @@ function App(version) {
} // App.getBoardLists()

/**
*
* A method of App to get all Organizations that current user is a member of.
*/

App.prototype.getMyOrganizations = function() {

var config = {
Expand All @@ -103,7 +103,7 @@ function App(version) {
}

/**
*
* A method of App that creates a card based on the config payload variable.
*/

/*
Expand Down
166 changes: 80 additions & 86 deletions Authorizer.gs
Original file line number Diff line number Diff line change
Expand Up @@ -7,103 +7,97 @@
// =============
//
// This object provides the autorization methods

var Authorizer_ = {

/**
*
*/

getTrelloService: function() {

var service = OAuth1.createService(OAUTH_SERVICE_NAME);
service.setAccessTokenUrl("https://trello.com/1/OAuthGetAccessToken");
service.setRequestTokenUrl("https://trello.com/1/OAuthGetRequestToken");
service.setAuthorizationUrl("https://trello.com/1/OAuthAuthorizeToken?scope=read,write");
service.setConsumerKey(getProperty_(PROPERTY_API_KEY, OnNull.ERROR));
service.setConsumerSecret(getProperty_(PROPERTY_SECRET, OnNull.ERROR));
service.setProjectKey(getProperty_(PROPERTY_PROJECT_KEY, OnNull.ERROR));
service.setCallbackFunction('authCallback');
service.setPropertyStore(PropertiesService.getUserProperties());
return service;

}, // Authorizer_.getTrelloService

/**
*
*/

resetTrello:function() {

OAuth1.createService('trello')
.setPropertyStore(PropertiesService.getUserProperties())
.reset();

}, // Authorizer_.resetTrello()

/**
*
*/

getToken: function() {

var service = Authorizer_.getTrelloService()
var token = ''

if (service.hasAccess) {

var accessData = JSON.parse(PropertiesService.getUserProperties().getProperty('oauth1.trello' ))

if (accessData){

token = accessData.public

} else {

throw new Error("Trello API unauthorized! Please authorize at " + AUTHORIZATION_URI)
}

} else {

throw new Error("Trello API unauthorized! Please authorize at " + AUTHORIZATION_URI)
}

return token

}, // Authorizer_.getToken()

/**
* @returns {object} Returns an OAuth1 Service for Trello
*/
getTrelloService : function () {
var service = OAuth1.createService(OAUTH_SERVICE_NAME);
service.setAccessTokenUrl("https://trello.com/1/OAuthGetAccessToken");
service.setRequestTokenUrl("https://trello.com/1/OAuthGetRequestToken");
service.setAuthorizationUrl("https://trello.com/1/OAuthAuthorizeToken?scope=read,write");
service.setConsumerKey(getProperty_(PROPERTY_API_KEY, OnNull.ERROR));
service.setConsumerSecret(getProperty_(PROPERTY_SECRET, OnNull.ERROR));
service.setProjectKey(getProperty_(PROPERTY_PROJECT_KEY, OnNull.ERROR));
service.setCallbackFunction('authCallback');
service.setPropertyStore(PropertiesService.getUserProperties());
return service;

}, // Authorizer_.getTrelloService

/**
* Resets all OAuth1 settings in Authorizer object.
*/
resetTrello : function () {
OAuth1.createService('trello')
.setPropertyStore(PropertiesService.getUserProperties())
.reset();

}, // Authorizer_.resetTrello()

/**
*
*/
getToken : function () {

var service = Authorizer_.getTrelloService()
var token = ''

if (service.hasAccess) {

var accessData = JSON.parse(PropertiesService.getUserProperties().getProperty('oauth1.trello'))

if (accessData) {

token = accessData.public

} else {

throw new Error("Trello API unauthorized! Please authorize at " + AUTHORIZATION_URI)
}

} else {

throw new Error("Trello API unauthorized! Please authorize at " + AUTHORIZATION_URI)
}

return token

}, // Authorizer_.getToken()

} // Authorizer_

/**
*
*
*/

function authCallback(request) {

var service = Authorizer_.getTrelloService();
var isAuthorized = service.handleCallback(request);
if (isAuthorized) {
var template = HtmlService.createTemplateFromFile('Authorized');
var page = template.evaluate();
return HtmlService.createHtmlOutput(page)
} else {
return HtmlService.createHtmlOutput('Denied. You can close this page');
}
function authCallback(request) {

var service = Authorizer_.getTrelloService();
var isAuthorized = service.handleCallback(request);

if (isAuthorized) {

var template = HtmlService.createTemplateFromFile('Authorized');
var page = template.evaluate();
return HtmlService.createHtmlOutput(page)

} else {

return HtmlService.createHtmlOutput('Denied. You can close this page');
}

} // authCallback()

function resetTrello(){
Authorizer_.resetTrello();
function resetTrello() {
Authorizer_.resetTrello();
}

function deleteUserProperties(){
PropertiesService.getUserProperties().deleteAllProperties()
function deleteUserProperties() {
PropertiesService.getUserProperties().deleteAllProperties()
}

function getUserData() {
Logger.log(PropertiesService.getUserProperties().getProperty('oauth1.trello' ))
}
Logger.log(PropertiesService.getUserProperties().getProperty('oauth1.trello'))
}
91 changes: 79 additions & 12 deletions Board.gs
Original file line number Diff line number Diff line change
@@ -1,20 +1,87 @@
/**
* @classdesc
* This class defines an Trello Organization.
* This class defines an Trello Board.
* @constructor
*/

function Board() {

/**
* @returns {string} The id of this Segment
*/
Board.prototype.getName = function() {
return this.wrapped.name;
}

Board.prototype.getId = function() {
return this.wrapped.id;
}

/**
* @returns {string} The id of this Segment
*/
Board.prototype.getId = function () {
return this.wrapped.id;
}

/**
* @returns {string} The name of this board
*/
Board.prototype.getName = function () {
return this.wrapped.name;
}

/**
* @returns {string} The brief description of this board
*/
Board.prototype.getDescription = function () {
return this.wrapped.desc;
}

/**
* @returns {string} The description data for this board
*/
Board.prototype.getDescriptionData = function () {
return this.wrapped.descData;
}

/**
* @returns {boolean} Is this board closed or not?
*/
Board.prototype.isClosed = function () {
return this.wrapped.closed;
}

/**
* @returns {string} The ID of the organization this board is in
*/
Board.prototype.getOrganizationID = function () {
return this.wrapped.idOrganization;
}

/**
* @returns {boolean} Has this board been 'starred'?
*/
Board.prototype.isFavorited = function () {
return this.wrapped.pinned;
}

/**
* @returns {string} The url of this board
*/
Board.prototype.getURL = function () {
return this.wrapped.url;
}

/**
* @returns {string} The short url of this board
*/
Board.prototype.getShortURL = function () {
return this.wrapped.shortUrl;
}

/**
* @returns {array} The preferences for this board
*/
Board.prototype.getPrefs = function () {
return this.wrapped.prefs;
}

/**
* @returns {array} The labels for this board
*/
Board.prototype.getLabels = function () {
return this.wrapped.labelNames;
}


} // Board
14 changes: 14 additions & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#Notes
This is my first GIT-based project. It's also the first REAL javascript development I've done in years.

I am going to try to cover the basics of what I want to see happen with this project in case the original repository that I forked from isn't interested in including my commits as well as in case anyone interested in the direction I envision wants to work on this as well. What I am wanting is actually fairly simple in terms of describing. I'm QUITE pleased that someone else had started this as I was still in the early stages of finishing touches on an OAuth process that I still wasn't pleased with.

## Aim
A javascript project that can be easily added to an existing Google product (Doc, Sheets, Slide, Drawing, etc.). It needs to provide the user with a simple interface for authenticating and authorizing so that non-developers can use it. It needs to have a simplistic interface to allow non-developers to quickly integrate it into their Google Prod without being required to dig into Trello developer documentation.

##Expected Workflow
This is my (initial) expectation for the finished product (the end result might end up being a plugin).

1. User Creates New Google Product (Doc for example)
1. User Adds GAS-Trello Library
1.
Loading