diff --git a/Api.gs b/Api.gs index 39b6eae..7ea612e 100644 --- a/Api.gs +++ b/Api.gs @@ -7,6 +7,7 @@ // ====== // // This local object provides internal access to the Trello API. +/* Not sure what the above means. */ // var Api_ = { @@ -14,11 +15,9 @@ var Api_ = { /** * The API object manages the API version value */ - setVersion: function (version) { // version checked in setProperty_() - setProperty_( PROPERTY_API_VERSION, version, diff --git a/App.gs b/App.gs index a3ff9ff..62fe74e 100644 --- a/App.gs +++ b/App.gs @@ -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')) @@ -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() { @@ -27,9 +30,8 @@ function App(version) { /** - * + * A method of App to get all boards of current user. */ - App.prototype.getMyBoards = function() { var config = { @@ -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 = { @@ -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 = { @@ -103,7 +103,7 @@ function App(version) { } /** - * + * A method of App that creates a card based on the config payload variable. */ /* diff --git a/Authorizer.gs b/Authorizer.gs index 68d34fc..4fb4fcd 100644 --- a/Authorizer.gs +++ b/Authorizer.gs @@ -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')) +} \ No newline at end of file diff --git a/Board.gs b/Board.gs index 4748f92..8917344 100644 --- a/Board.gs +++ b/Board.gs @@ -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 diff --git a/NOTES.md b/NOTES.md new file mode 100644 index 0000000..9ae64fa --- /dev/null +++ b/NOTES.md @@ -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. diff --git a/README.md b/README.md index 7e3cbe4..32d9ca4 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,27 @@ # GAS-TrelloApp Google Apps Script library for using the [Trello RESTful API] (https://developers.trello.com/advanced-reference). -At the moment it provides: +It currently has on-going development in these areas: * authorization/authentication -* listing of organisations and boards +* object-oriented approach to Trello 'objects' +<<<<<<< HEAD + +It currently can be used to: +* Authorize and Authenticate Users +* Get all Boards and Orgnizations for Users +* Get a List ID +* Create a new Card in an Existing Board + +======= + +It currently can be used to: +* authorize / authenticate users * getting a list id * creation of new cards in an existing board -You can use the TrelloApp library in you code by using the ID: **MOXamiHNCH44xpQh9H7FTudnfWGfgtIUb**. +>>>>>>> be3806edf0a63fd0216c05cfd2e04366d0c7a8f5 +You can use the TrelloApp library in your code by using the ID: **MOXamiHNCH44xpQh9H7FTudnfWGfgtIUb**. Here's an example of using it to create a new card: diff --git a/Wrapper.gs b/Wrapper.gs index 6fc70eb..0574db4 100644 --- a/Wrapper.gs +++ b/Wrapper.gs @@ -29,4 +29,3 @@ var Wrapper = { }, } // Wrapper - diff --git a/boardPrefs.gs b/boardPrefs.gs new file mode 100644 index 0000000..b502383 --- /dev/null +++ b/boardPrefs.gs @@ -0,0 +1,44 @@ +/** + * @classdesc + * This class defines the Preferences that can be set on a Board. + * @constructor + */ + +function boardPrefs() { + + /** + * @return {string} The premission level of this board + */ + boardPrefs.prototype.getPermissionLevel = function () { + return this.wrapped.permissionLevel; + } + + /** + * @return {string} The voting level of this board + */ + boardPrefs.prototype.getVotingLevel = function () { + return this.wrapped.voting; + } + + /** + * @return {string} The comments level of this board + */ + boardPrefs.prototype.getCommentsLevel = function () { + return this.wrapped.comments; + } + + /** + * @return {string} The invitations level of this board + */ + boardPrefs.prototype.getInvitationLevel = function () { + return this.wrapped.invitations; + } + + /** + * @return {boolean} Can this board be joined without an invitation? + */ + boardPrefs.prototype.isMembershipOpen = function () { + return this.wrapped.selfJoin; + } + +} // Board Preferences