delta-store
Version:
An API for a store with change records
62 lines • 2.13 kB
JavaScript
;
var FeedType = (function () {
function FeedType() {
}
return FeedType;
}());
FeedType.WORKSHEETS = 'worksheets';
FeedType.LIST = 'list';
var Scope = (function () {
function Scope() {
}
return Scope;
}());
Scope.PRIVATE = 'private';
Scope.PUBLIC = 'public';
var ReturnType = (function () {
function ReturnType() {
}
return ReturnType;
}());
ReturnType.FULL = 'full';
var GoogleSheets = (function () {
function GoogleSheets(googleApi, promiseHttp) {
this.googleApi = googleApi;
this.promiseHttp = promiseHttp;
this.urlPrefix = 'https://spreadsheets.google.com/feeds';
}
GoogleSheets.prototype.getSheet = function (fileId) {
return this.promiseHttp.get(this.getListFeedUrl(fileId));
};
GoogleSheets.prototype.getWorksheets = function (fileId) {
return this.googleApi.request(this.getWorksheetsUrl(fileId));
};
GoogleSheets.prototype.getRequestOptionsArgs = function () {
var headers = {}; //new Headers();
// headers.append('Authorization', 'GoogleLogin auth=' + 1);
// headers.append('GData-Version', '3.0');
var requestOptionsArgs = {
headers: headers
};
return requestOptionsArgs;
};
GoogleSheets.prototype.getListFeedUrl = function (fileId) {
var url = this.urlPrefix + "/" + FeedType.LIST + "/key/" + fileId + "/" + this.getUrlSuffix();
return url;
};
GoogleSheets.prototype.getWorksheetsUrl = function (fileId) {
var url = this.urlPrefix + "/" + FeedType.WORKSHEETS + "/" + fileId + "/" + this.getUrlSuffix();
return url;
};
GoogleSheets.prototype.getUrlSuffix = function () {
var accessToken = gapi.auth.getToken().access_token;
var suffix = "/private/full/?access_token=" + accessToken;
return suffix;
};
GoogleSheets.prototype.addRow = function (fileId, rowXml) {
return this.promiseHttp.post(this.getListFeedUrl(fileId), rowXml);
};
return GoogleSheets;
}());
exports.GoogleSheets = GoogleSheets;
//# sourceMappingURL=GoogleSheets.js.map