Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added tranform for each service.

  • Loading branch information...
commit 306b57398fef130ac6d4489b9dfd1992428b40fb 1 parent 2dfe441
@AnalogJ AnalogJ authored
View
18 lib/dropbox/dropbox_transform.js
@@ -49,24 +49,6 @@ function parseDeletion(deletion_response){
exports.parseDeletion = parseDeletion;
function parseFolderItems(items_response){
-
- /*
- "total_count": 0,
- "entries": [],
- "offset": 0,
- "limit": 100,
- "order": [
- {
- "by": "type",
- "direction": "ASC"
- },
- {
- "by": "name",
- "direction": "ASC"
- }
- ]
- * */
-
var transform = {};
transform.total_items = null;
transform.content = items_response.content_stat_array.map(function(current_item){
View
26 lib/google_drive/google_drive_client.js
@@ -28,7 +28,7 @@ module.exports = function (oauth_data, provider_options) {
return deferred.promise;
}
- this.CheckQuota = function (options) {
+ this.AccountInfo = function (options) {
options = options || {}
options.includeSubscribed = options.includeSubscribed || true;
return getClient().then(function (client) {
@@ -43,16 +43,20 @@ module.exports = function (oauth_data, provider_options) {
})
}
-// this.CheckQuota = function (options) {
-// return getClient().then(function (client) {
-// var deferred = Q.defer();
-// client.getAccountInfo(options || {}, function (err, stat) {
-// if (err) return deferred.reject(err);
-// return deferred.resolve(stat);
-// });
-// return deferred.promise;
-// })
-// }
+ this.CheckQuota = function (options) {
+ options = options || {}
+ options.includeSubscribed = options.includeSubscribed || true;
+ return getClient().then(function (client) {
+ var deferred = Q.defer();
+ client.drive.about
+ .get(options)
+ .withAuthClient(_oauth2Client).execute(function (err, result) {
+ if (err) return deferred.reject(err);
+ return deferred.resolve(result);
+ });
+ return deferred.promise;
+ })
+ }
this.CreateFile = function (fileName, parentIdentifier, content_buffer, options) {
View
87 lib/google_drive/google_drive_transform.js
@@ -0,0 +1,87 @@
+function parseFileInformation(file_response){
+ var transform = {};
+ transform.is_file = (file_response.mimeType != "application/vnd.google-apps.folder");
+ transform.is_folder = (file_response.mimeType == "application/vnd.google-apps.folder");
+ transform.etag = file_response.etag;
+ transform.identifier = file_response.id;
+ transform.parent_identifier = file_response.parents[0].id;
+ transform.mimetype = file_response.mimeType
+ transform.created_date = new Date(file_response.createdDate);
+ transform.modified_date = new Date(file_response.modifiedDate);
+ transform.name = file_response.title;
+ transform.description = '';
+ //transform.extension = file_response.name.split('.')
+ transform.checksum = file_response.md5Checksum;
+ transform.file_size = file_response.fileSize;
+ transform._raw = file_response;
+ return transform;
+}
+exports.parseFileInformation = parseFileInformation;
+
+function parseFolderInformation(folder_response){
+ var transform = {};
+ transform.is_file = (folder_response.mimeType != "application/vnd.google-apps.folder");
+ transform.is_folder = (folder_response.mimeType == "application/vnd.google-apps.folder");
+ transform.etag = folder_response.etag;
+ transform.identifier = folder_response.id;
+ transform.parent_identifier = folder_response.parents[0].id;
+ transform.created_date = new Date(folder_response.createdDate);
+ transform.modified_date = new Date(folder_response.modifiedDate);
+ transform.name = folder_response.title;
+ transform.description = '';
+ transform._raw = folder_response;
+ return transform;
+}
+exports.parseFolderInformation = parseFolderInformation;
+
+function parseDeletion(deletion_response){
+ var transform = {}
+ transform.success = true;
+ transform._raw = '';
+ return transform;
+}
+exports.parseDeletion = parseDeletion;
+
+function parseFolderItems(items_response){
+ var transform = {};
+ transform.total_items = null;
+ transform.content = items_response.items.map(function(current_item){
+ if(current_item.mimeType != "application/vnd.google-apps.folder"){
+ return parseFileInformation(current_item);
+ }
+ else{
+ return parseFolderInformation(current_item);
+ }
+ });
+ return transform;
+}
+
+exports.parseFolderItems = parseFolderItems;
+
+
+function parseAccountInfo(account_response){
+
+ var transform = {};
+ transform.name = account_response.user.displayName;
+ transform.email = '';
+ transform.avatar_url = '';
+ transform.created_date = null;
+ transform.modified_date = null;
+ transform.id = account_response.permissionId;
+ transform._raw = account_response;
+ return transform;
+}
+exports.parseAccountInfo = parseAccountInfo;
+
+function parseQuota(quota_response){
+ var transform = {};
+ transform.total_bytes = quota_response.quotaBytesTotal; //total space allocated in bytes
+ transform.used_bytes = quota_response.quotaBytesUsed; //bytes used.
+ transform.limits= {
+ upload_size : '10737418240'
+ }
+ transform._raw = quota_response;
+ return transform;
+}
+exports.parseQuota = parseQuota;
+
View
21 lib/skydrive/skydrive_client.js
@@ -59,6 +59,22 @@ module.exports = function (oauth_data, provider_options) {
})
}
+ this.CheckQuota = function (options) {
+ options = options || {}
+ return getClient().then(function (client) {
+ var deferred = Q.defer();
+ client.get({
+ url: 'https://apis.live.net/v5.0/me/skydrive/quota'
+ },
+ function (err, r, body) {
+ if (err) return deferred.reject(err);
+ return deferred.resolve({ "response": r, "body": body});
+ });
+
+ return deferred.promise;
+ })
+ }
+
this.CreateFile = function (fileName, parentIdentifier, content_buffer, options) {
options = options || {}
@@ -67,7 +83,7 @@ module.exports = function (oauth_data, provider_options) {
}
parentIdentifier = parentIdentifier || 'me/skydrive'
return getClient().then(function (client) {
- console.log("successfully got client", fileName, parentIdentifier, content_buffer);
+// console.log("successfully got client", fileName, parentIdentifier, content_buffer);
var deferred = Q.defer();
client.put({
url: 'https://apis.live.net/v5.0/' + parentIdentifier + '/files/'+ fileName,
@@ -81,12 +97,10 @@ module.exports = function (oauth_data, provider_options) {
// ]
},
function (err, r, body) {
- console.log(err, r.statusCode, body);
err = errorHandler(r, body, err);
if (err) return deferred.reject(err);
return deferred.resolve({ "response": r, "body": body});
});
- console.log("GENEREATED POST")
return deferred.promise;
})
}
@@ -228,7 +242,6 @@ module.exports = function (oauth_data, provider_options) {
url: 'https://apis.live.net/v5.0/' + identifier + '/files'
},
function (err, r, body) {
- console.log(err, r.statusCode, body);
err = errorHandler(r, body, err);
if (err) return deferred.reject(err);
return deferred.resolve({ "response": r, "body": body});
View
86 lib/skydrive/skydrive_transform.js
@@ -0,0 +1,86 @@
+function parseFileInformation(file_response){
+ var transform = {};
+ transform.is_file = (file_response.type != "folder");
+ transform.is_folder = (file_response.type == "folder");
+ transform.etag = '';
+ transform.identifier = file_response.id;
+ transform.parent_identifier = file_response.parent_id;
+ transform.mimetype = ''
+ transform.created_date = new Date(file_response.created_time);
+ transform.modified_date = new Date(file_response.updated_time);
+ transform.name = file_response.name;
+ transform.description = file_response.description;
+ //transform.extension = file_response.name.split('.')
+ transform.checksum = null;
+ transform.file_size = file_response.size;
+ transform._raw = file_response;
+ return transform;
+}
+exports.parseFileInformation = parseFileInformation;
+
+function parseFolderInformation(folder_response){
+ var transform = {};
+ transform.is_file = (folder_response.type != "folder");
+ transform.is_folder = (folder_response.type == "folder");
+ transform.etag = '';
+ transform.identifier = folder_response.id;
+ transform.parent_identifier = folder_response.parent_id;
+ transform.created_date = new Date(folder_response.created_time);
+ transform.modified_date = new Date(folder_response.updated_time);
+ transform.name = folder_response.name;
+ transform.description = folder_response.description;
+ transform._raw = folder_response;
+ return transform;
+}
+exports.parseFolderInformation = parseFolderInformation;
+
+function parseDeletion(deletion_response){
+ var transform = {}
+ transform.success = true;
+ transform._raw = '';
+ return transform;
+}
+exports.parseDeletion = parseDeletion;
+
+function parseFolderItems(items_response){
+ var transform = {};
+ transform.total_items = null;
+ transform.content = items_response.data.map(function(current_item){
+ if(current_item.type != "folder"){
+ return parseFileInformation(current_item);
+ }
+ else{
+ return parseFolderInformation(current_item);
+ }
+ });
+ return transform;
+}
+
+exports.parseFolderItems = parseFolderItems;
+
+
+function parseAccountInfo(account_response){
+
+ var transform = {};
+ transform.name = account_response.name;
+ transform.email = account_response.emails.preferred;
+ transform.avatar_url = '';
+ transform.created_date = new Date(account_response.updated_time);
+ transform.modified_date = new Date(account_response.updated_time);
+ transform.id = account_response.id;
+ transform._raw = account_response;
+ return transform;
+}
+exports.parseAccountInfo = parseAccountInfo;
+
+function parseQuota(quota_response){
+ var transform = {};
+ transform.total_bytes = quota_response.quota; //total space allocated in bytes
+ transform.used_bytes = quota_response.quota - quota_response.available; //bytes used.
+ transform.limits= {
+ }
+ transform._raw = quota_response;
+ return transform;
+}
+exports.parseQuota = parseQuota;
+
View
292 test/google_drive/data/AccountInfoResponse.json
@@ -0,0 +1,292 @@
+{
+ "kind": "drive#about",
+ "etag": "\"GJcqFgACxaboeo6aKKeP6-mh0PE/FUJiyMQ1tUjZv1tqgq0K3pcofbo\"",
+ "selfLink": "https://www.googleapis.com/drive/v2/about?includeSubscribed=true",
+ "name": "Filefog Integration",
+ "user": {
+ "kind": "drive#user",
+ "displayName": "Filefog Integration",
+ "isAuthenticatedUser": true,
+ "permissionId": "12009769044836159212"
+ },
+ "quotaBytesTotal": "16106127360",
+ "quotaBytesUsed": "840",
+ "quotaBytesUsedAggregate": "840",
+ "quotaBytesUsedInTrash": "820",
+ "largestChangeId": "602",
+ "rootFolderId": "0APNh7kFAqcICUk9PVA",
+ "domainSharingPolicy": "allowed",
+ "permissionId": "12009769044836159212",
+ "importFormats": [
+ {
+ "source": "application/x-msmetafile",
+ "targets": [
+ "application/vnd.google-apps.drawing"
+ ]
+ },
+ {
+ "source": "text/tab-separated-values",
+ "targets": [
+ "application/vnd.google-apps.spreadsheet"
+ ]
+ },
+ {
+ "source": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ "targets": [
+ "application/vnd.google-apps.spreadsheet"
+ ]
+ },
+ {
+ "source": "application/vnd.ms-excel",
+ "targets": [
+ "application/vnd.google-apps.spreadsheet"
+ ]
+ },
+ {
+ "source": "application/x-vnd.oasis.opendocument.spreadsheet",
+ "targets": [
+ "application/vnd.google-apps.spreadsheet"
+ ]
+ },
+ {
+ "source": "text/csv",
+ "targets": [
+ "application/vnd.google-apps.spreadsheet"
+ ]
+ },
+ {
+ "source": "application/vnd.oasis.opendocument.text",
+ "targets": [
+ "application/vnd.google-apps.document"
+ ]
+ },
+ {
+ "source": "image/jpeg",
+ "targets": [
+ "application/vnd.google-apps.document"
+ ]
+ },
+ {
+ "source": "image/png",
+ "targets": [
+ "application/vnd.google-apps.document"
+ ]
+ },
+ {
+ "source": "application/vnd.sun.xml.writer",
+ "targets": [
+ "application/vnd.google-apps.document"
+ ]
+ },
+ {
+ "source": "text/plain",
+ "targets": [
+ "application/vnd.google-apps.document"
+ ]
+ },
+ {
+ "source": "image/bmp",
+ "targets": [
+ "application/vnd.google-apps.document"
+ ]
+ },
+ {
+ "source": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
+ "targets": [
+ "application/vnd.google-apps.document"
+ ]
+ },
+ {
+ "source": "image/gif",
+ "targets": [
+ "application/vnd.google-apps.document"
+ ]
+ },
+ {
+ "source": "application/msword",
+ "targets": [
+ "application/vnd.google-apps.document"
+ ]
+ },
+ {
+ "source": "text/html",
+ "targets": [
+ "application/vnd.google-apps.document"
+ ]
+ },
+ {
+ "source": "application/rtf",
+ "targets": [
+ "application/vnd.google-apps.document"
+ ]
+ },
+ {
+ "source": "application/pdf",
+ "targets": [
+ "application/vnd.google-apps.document"
+ ]
+ },
+ {
+ "source": "application/vnd.ms-powerpoint",
+ "targets": [
+ "application/vnd.google-apps.presentation"
+ ]
+ },
+ {
+ "source": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
+ "targets": [
+ "application/vnd.google-apps.presentation"
+ ]
+ }
+ ],
+ "exportFormats": [
+ {
+ "source": "application/vnd.google-apps.drawing",
+ "targets": [
+ "image/svg+xml",
+ "image/jpeg",
+ "image/png",
+ "application/pdf"
+ ]
+ },
+ {
+ "source": "application/vnd.google-apps.presentation",
+ "targets": [
+ "text/plain",
+ "application/pdf",
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation"
+ ]
+ },
+ {
+ "source": "application/vnd.google-apps.document",
+ "targets": [
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
+ "application/vnd.oasis.opendocument.text",
+ "text/html",
+ "application/rtf",
+ "text/plain",
+ "application/pdf",
+ "text/rtf"
+ ]
+ },
+ {
+ "source": "application/vnd.google-apps.spreadsheet",
+ "targets": [
+ "application/pdf",
+ "application/x-vnd.oasis.opendocument.spreadsheet",
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
+ ]
+ },
+ {
+ "source": "application/vnd.google-apps.form",
+ "targets": [
+ "application/pdf",
+ "application/x-vnd.oasis.opendocument.spreadsheet",
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
+ ]
+ },
+ {
+ "source": "application/vnd.google-apps.script",
+ "targets": [
+ "application/vnd.google-apps.script+json"
+ ]
+ }
+ ],
+ "additionalRoleInfo": [
+ {
+ "type": "application/vnd.google-apps.drawing",
+ "roleSets": [
+ {
+ "primaryRole": "reader",
+ "additionalRoles": [
+ "commenter"
+ ]
+ }
+ ]
+ },
+ {
+ "type": "application/vnd.google-apps.document",
+ "roleSets": [
+ {
+ "primaryRole": "reader",
+ "additionalRoles": [
+ "commenter"
+ ]
+ }
+ ]
+ },
+ {
+ "type": "application/vnd.google-apps.presentation",
+ "roleSets": [
+ {
+ "primaryRole": "reader",
+ "additionalRoles": [
+ "commenter"
+ ]
+ }
+ ]
+ },
+ {
+ "type": "*",
+ "roleSets": [
+ {
+ "primaryRole": "reader",
+ "additionalRoles": [
+ "commenter"
+ ]
+ }
+ ]
+ },
+ {
+ "type": "application/vnd.google-apps.spreadsheet",
+ "roleSets": [
+ {
+ "primaryRole": "reader",
+ "additionalRoles": [
+ "commenter"
+ ]
+ }
+ ]
+ },
+ {
+ "type": "application/vnd.google-apps.*",
+ "roleSets": []
+ }
+ ],
+ "features": [
+ {
+ "featureName": "ocr"
+ },
+ {
+ "featureName": "translation",
+ "featureRate": 0.5
+ }
+ ],
+ "maxUploadSizes": [
+ {
+ "type": "application/vnd.google-apps.document",
+ "size": "10485760"
+ },
+ {
+ "type": "application/vnd.google-apps.spreadsheet",
+ "size": "20971520"
+ },
+ {
+ "type": "application/vnd.google-apps.presentation",
+ "size": "52428800"
+ },
+ {
+ "type": "application/vnd.google-apps.drawing",
+ "size": "2097152"
+ },
+ {
+ "type": "application/pdf",
+ "size": "10737418240"
+ },
+ {
+ "type": "*",
+ "size": "10737418240"
+ }
+ ],
+ "isCurrentAppInstalled": false
+}
View
2  test/google_drive/google_drive_client_spec.js
@@ -143,7 +143,7 @@ describe('Google Client Raw Responses', function () {
it('should access account info', function () {
return Client.AccountInfo().then(function (response) {
assert(response.name);
- assert(response.email);
+ //assert(response.email);
})
})
View
81 test/google_drive/google_drive_transform_spec.js
@@ -0,0 +1,81 @@
+var assert = require('assert')
+ , q = require('q')
+ , transform = require('../../lib/google_drive/google_drive_transform.js')
+ , fs = require('fs')
+ , path = require('path')
+ , assert = require('assert')
+
+require("mocha-as-promised")();
+
+describe('Google Drive Transform', function () {
+ it('should transform account ', function () {
+ var response = JSON.parse(fs.readFileSync(
+ path.resolve(__dirname, 'data/AccountInfoResponse.json')
+ ));
+ return q.when(response)
+ .then(transform.parseAccountInfo)
+ .then(function(transform){
+ assert.equal(transform.email,'');
+ assert.equal(transform.avatar_url, '');
+ assert(transform.id);
+ })
+ })
+
+ it('should transform quota', function () {
+ var response = JSON.parse(fs.readFileSync(
+ path.resolve(__dirname, 'data/CheckQuotaResponse.json')
+ ));
+ return q.when(response)
+ .then(transform.parseQuota)
+ .then(function(transform){
+ assert(transform.total_bytes);
+ assert(transform.used_bytes);
+ assert(transform.limits);
+ })
+ })
+
+ it('should transform file information', function () {
+ var response = JSON.parse(fs.readFileSync(
+ path.resolve(__dirname, 'data/GetFileInformationResponse.json')
+ ));
+ return q.when(response)
+ .then(transform.parseFileInformation)
+ .then(function(transform){
+ assert.equal(transform.is_file, true);
+ assert.equal(transform.is_folder, false);
+ assert(transform.etag);
+ assert(transform.identifier);
+ assert(transform.parent_identifier);
+ assert(transform.name)
+ //assert.equals(transform.checksum,'')
+ assert(transform.file_size)
+ })
+ })
+
+ it('should transform folder information', function () {
+ var response = JSON.parse(fs.readFileSync(
+ path.resolve(__dirname, 'data/GetFolderInformationResponse.json')
+ ));
+ return q.when(response)
+ .then(transform.parseFolderInformation)
+ .then(function(transform){
+ assert.equal(transform.is_file, false);
+ assert.equal(transform.is_folder, true);
+ assert(transform.etag);
+ assert(transform.identifier);
+ assert(transform.parent_identifier);
+ assert(transform.name)
+ })
+ })
+
+ it('should transform folder contents', function () {
+ var response = JSON.parse(fs.readFileSync(
+ path.resolve(__dirname, 'data/RetrieveFolderItemsResponse.json')
+ ));
+ return q.when(response)
+ .then(transform.parseFolderItems)
+ .then(function(transform){
+ console.log("RESPONSE",transform);
+ })
+ })
+});
View
16 test/skydrive/data/AccountInfoResponse.json
@@ -0,0 +1,16 @@
+{
+ "id": "959da4d8356be659",
+ "name": "Filefog Last",
+ "first_name": "Filefog",
+ "last_name": "Last",
+ "link": "https://profile.live.com/",
+ "gender": null,
+ "emails": {
+ "preferred": "filefogtest@gmail.com",
+ "account": "filefogtest@gmail.com",
+ "personal": null,
+ "business": null
+ },
+ "locale": "en_US",
+ "updated_time": "2014-02-27T22:33:58+0000"
+}
View
4 test/skydrive/data/CheckQuotaResponse.json
@@ -0,0 +1,4 @@
+{
+ "quota": 26843545600,
+ "available": 26805319016
+}
View
5 test/skydrive/data/CreateFileResponse.json
@@ -0,0 +1,5 @@
+{
+ "id": "file.959da4d8356be659.959DA4D8356BE659!178",
+ "name": "71c6e32b-bf6c-1dbe-1a85-c227bb067920_test.txt",
+ "source": "https://ohbfbw.bn1303.livefilestore.com/y2m-ytQlLtnpD7G1loNEnjdxF19_wmCrQS_…cXB9zdPlz9G8/71c6e32b-bf6c-1dbe-1a85-c227bb067920_test.txt?download&psid=1"
+}
View
20 test/skydrive/data/CreateFolderResponse.json
@@ -0,0 +1,20 @@
+{
+ "id": "folder.959da4d8356be659.959DA4D8356BE659!179",
+ "from": {
+ "name": "Filefog Last",
+ "id": "959da4d8356be659"
+ },
+ "name": "e323bbf9-1fb4-712a-4fc3-5751574212a9_test",
+ "description": "A test folder",
+ "parent_id": "folder.959da4d8356be659",
+ "upload_location": "https://apis.live.net/v5.0/folder.959da4d8356be659.959DA4D8356BE659!179/files/",
+ "count": 0,
+ "link": "https://onedrive.live.com/redir.aspx?cid=959da4d8356be659&page=view&resid=959DA4D8356BE659!179&parid=959DA4D8356BE659!103",
+ "type": "folder",
+ "shared_with": {
+ "access": "Just me"
+ },
+ "created_time": "2014-03-01T21:23:51+0000",
+ "updated_time": "2014-03-01T21:23:52+0000",
+ "client_updated_time": "2014-03-01T21:23:52+0000"
+}
View
0  test/skydrive/data/DeleteFileResponse.json
No changes.
View
0  test/skydrive/data/DeleteFolderResponse.json
No changes.
View
24 test/skydrive/data/GetFileInformationResponse.json
@@ -0,0 +1,24 @@
+{
+ "id": "file.959da4d8356be659.959DA4D8356BE659!174",
+ "from": {
+ "name": "Filefog Last",
+ "id": "959da4d8356be659"
+ },
+ "name": "495f1cf9-47ac-2758-a00b-89b384a2b843_test.txt",
+ "description": "",
+ "parent_id": "folder.959da4d8356be659",
+ "size": 20,
+ "upload_location": "https://apis.live.net/v5.0/file.959da4d8356be659.959DA4D8356BE659!174/content/",
+ "comments_count": 0,
+ "comments_enabled": false,
+ "is_embeddable": true,
+ "source": "https://ohbfbw.bn1302.livefilestore.com/y2m4pzo9nmUkJRfGSwBloNUbHxFS8BFvZH0…Q6oD0klC8YPmyfvaMRwkQ/495f1cf9-47ac-2758-a00b-89b384a2b843_test.txt?psid=1",
+ "link": "https://onedrive.live.com/redir.aspx?cid=959da4d8356be659&page=view&resid=959DA4D8356BE659!174&parid=959DA4D8356BE659!103",
+ "type": "file",
+ "shared_with": {
+ "access": "Just me"
+ },
+ "created_time": "2014-03-01T21:01:55+0000",
+ "updated_time": "2014-03-01T21:01:55+0000",
+ "client_updated_time": "2014-03-01T21:01:55+0000"
+}
View
24 test/skydrive/data/GetFolderInformationResponse.json
@@ -0,0 +1,24 @@
+{
+ "id": "folder.959da4d8356be659.959DA4D8356BE659!179",
+ "from": {
+ "name": "Filefog Last",
+ "id": "959da4d8356be659"
+ },
+ "name": "e323bbf9-1fb4-712a-4fc3-5751574212a9_test",
+ "description": "A test folder",
+ "parent_id": "folder.959da4d8356be659",
+ "size": 0,
+ "upload_location": "https://apis.live.net/v5.0/folder.959da4d8356be659.959DA4D8356BE659!179/files/",
+ "comments_count": 0,
+ "comments_enabled": false,
+ "is_embeddable": true,
+ "count": 0,
+ "link": "https://onedrive.live.com/redir.aspx?cid=959da4d8356be659&page=view&resid=959DA4D8356BE659!179&parid=959DA4D8356BE659!103",
+ "type": "folder",
+ "shared_with": {
+ "access": "Just me"
+ },
+ "created_time": "2014-03-01T21:23:51+0000",
+ "updated_time": "2014-03-01T21:23:52+0000",
+ "client_updated_time": "2014-03-01T21:23:52+0000"
+}
View
3  test/skydrive/data/RetrieveFolderItemsResponse.json
@@ -0,0 +1,3 @@
+{
+ "data": []
+}
View
17 test/skydrive/skydrive_client_spec.js
@@ -52,6 +52,7 @@ describe('Skydrive Client Raw Responses', function () {
var resp_json = JSON.parse(response.body);
assert.equal(resp_json.name, testFileName);
testFileID = resp_json.id
+ console.log(resp_json)
})
})
@@ -61,6 +62,7 @@ describe('Skydrive Client Raw Responses', function () {
var resp_json = JSON.parse(response.body);
assert.equal(resp_json.type, "file");
assert.equal(resp_json.name, testFileName);
+ console.log(resp_json)
})
})
@@ -96,6 +98,7 @@ describe('Skydrive Client Raw Responses', function () {
var resp_json = JSON.parse(response.body);
assert.equal(resp_json.type, "folder");
assert.equal(resp_json.name, "SkyDrive");
+ console.log(resp_json)
})
})
@@ -104,6 +107,7 @@ describe('Skydrive Client Raw Responses', function () {
var resp_json = JSON.parse(response.body);
//assert.equal(resp_json.count, 0);
//assert.deepEqual(resp_json.data, []);
+ console.log(resp_json)
})
})
})
@@ -114,6 +118,8 @@ describe('Skydrive Client Raw Responses', function () {
assert.equal(resp_json.type, "folder");
assert.equal(resp_json.name, testFolderName);
testFolderID = resp_json.id;
+ console.log(resp_json)
+
})
})
@@ -122,6 +128,8 @@ describe('Skydrive Client Raw Responses', function () {
var resp_json = JSON.parse(response.body);
assert.equal(resp_json.type, "folder");
assert.equal(resp_json.name, testFolderName);
+ console.log(resp_json)
+
})
})
@@ -130,6 +138,7 @@ describe('Skydrive Client Raw Responses', function () {
var resp_json = JSON.parse(response.body);
//assert.equal(resp_json.count, 0);
assert.deepEqual(resp_json.data, []);
+ console.log(resp_json)
})
})
@@ -156,12 +165,16 @@ describe('Skydrive Client Raw Responses', function () {
assert(resp_json.first_name);
assert(resp_json.last_name);
assert(resp_json.emails);
+ console.log(resp_json)
})
})
it('should access quota info', function () {
- assert.throws(function () {
- Client.CheckQuota()
+ return Client.CheckQuota().then(function (response) {
+ var resp_json = JSON.parse(response.body);
+ assert(resp_json.quota);
+ assert(resp_json.available);
+ console.log(resp_json)
})
})
View
81 test/skydrive/skydrive_transform_spec.js
@@ -0,0 +1,81 @@
+var assert = require('assert')
+ , q = require('q')
+ , transform = require('../../lib/skydrive/skydrive_transform.js')
+ , fs = require('fs')
+ , path = require('path')
+ , assert = require('assert')
+
+require("mocha-as-promised")();
+
+describe('Skydrive Transform', function () {
+ it('should transform account ', function () {
+ var response = JSON.parse(fs.readFileSync(
+ path.resolve(__dirname, 'data/AccountInfoResponse.json')
+ ));
+ return q.when(response)
+ .then(transform.parseAccountInfo)
+ .then(function(transform){
+ assert.equal(transform.email,'filefogtest@gmail.com');
+ assert.equal(transform.avatar_url, '');
+ assert(transform.id);
+ })
+ })
+
+ it('should transform quota', function () {
+ var response = JSON.parse(fs.readFileSync(
+ path.resolve(__dirname, 'data/CheckQuotaResponse.json')
+ ));
+ return q.when(response)
+ .then(transform.parseQuota)
+ .then(function(transform){
+ assert(transform.total_bytes);
+ assert(transform.used_bytes);
+ assert(transform.limits);
+ })
+ })
+
+ it('should transform file information', function () {
+ var response = JSON.parse(fs.readFileSync(
+ path.resolve(__dirname, 'data/GetFileInformationResponse.json')
+ ));
+ return q.when(response)
+ .then(transform.parseFileInformation)
+ .then(function(transform){
+ assert.equal(transform.is_file, true);
+ assert.equal(transform.is_folder, false);
+ assert.equal(transform.etag,'');
+ assert(transform.identifier);
+ assert(transform.parent_identifier);
+ assert(transform.name)
+ //assert.equals(transform.checksum,'')
+ assert(transform.file_size)
+ })
+ })
+
+ it('should transform folder information', function () {
+ var response = JSON.parse(fs.readFileSync(
+ path.resolve(__dirname, 'data/GetFolderInformationResponse.json')
+ ));
+ return q.when(response)
+ .then(transform.parseFolderInformation)
+ .then(function(transform){
+ assert.equal(transform.is_file, false);
+ assert.equal(transform.is_folder, true);
+ assert.equal(transform.etag,'');
+ assert(transform.identifier);
+ assert(transform.parent_identifier);
+ assert(transform.name)
+ })
+ })
+
+ it('should transform folder contents', function () {
+ var response = JSON.parse(fs.readFileSync(
+ path.resolve(__dirname, 'data/RetrieveFolderItemsResponse.json')
+ ));
+ return q.when(response)
+ .then(transform.parseFolderItems)
+ .then(function(transform){
+ console.log("RESPONSE",transform);
+ })
+ })
+});
View
18 test/test_access_tokens.json
@@ -8,30 +8,30 @@
}
},
"box": {
- "access_token": "RhMszRL46AXfggq2PXYbMTu2kZohAE9l",
- "refresh_token": "6SazxU6wa6RMNmqG30Ga1TBLIz99AT8Pec76BcA97zvbdXSDCjN0xVBsXHVqC1Rw",
+ "access_token": "eR46ZsIaRwO6z3cf2wC9ouxJr72exgCX",
+ "refresh_token": "w53Not6rTQJlN8rVxboSPN1rgQOmMROBT1kZ4Q1DbxUxpXTQcJS0N6mFEwnVihoB",
"raw": {
- "access_token": "RhMszRL46AXfggq2PXYbMTu2kZohAE9l",
- "expires_in": 4234,
+ "access_token": "eR46ZsIaRwO6z3cf2wC9ouxJr72exgCX",
+ "expires_in": 3997,
"restricted_to": [],
"token_type": "bearer"
}
},
"google": {
- "access_token": "ya29.1.AADtN_XVyglnKuYo3MjJrA4ah3rHxQdLoBPRDjHdxadDvUjwwmkWGNVIM1SAlwpBZGBgmtnW",
+ "access_token": "ya29.1.AADtN_WdUBOtMkwXd_Duv1UaEAVosXGVqkRa3Mp3YvI-JZa5UKSgvx0QSLQ7K9XVobMsUR67",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "1/IMcWJR9KJPVguuKLUrHzMjRl-XECLf6mK2YoUYnbQaU"
},
"skydrive": {
- "access_token": "EwA4Aq1DBAAUGCCXc8wU/zFu9QnLdZXy+YnElFkAAWnZ2da+6JqJ/7/pC2EKsgrD//e+M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OuApNWoQpYeRYkBAOtQZg6km8j0Vx8!4IkEXYJPZjFC7ddqpHbh*jvj7YNGLCVhcAeUC8dRpnmiRYxD64Qdi!W!oc3Wf5Pn*dfrJ91O6!m8tjBZiAVLzGYxEU8drH7eVP7jrRWp*0M$",
"raw": {
"token_type": "bearer",
"expires_in": 3600,
"scope": "wl.basic wl.emails wl.offline_access wl.skydrive_update",
- "access_token": "EwA4Aq1DBAAUGCCXc8wU/zFu9QnLdZXy+YnElFkAAWnZ2da+6JqJ/7/pC2EKsgrD//e+MfuNQypWC3y0jduW+2yzhyfOf1h+WMWsxj9xkwrKxswSFjiiRUPMNshdZbYX3TDwkm3uSqmgdD9lJRduHSSPFiVpJLbhEBGN44J6u/thVmt8ulquY+ot5EZ5CFteRyOck5g7/+M/ijBkgDDImc8E0P/JuLIrWr1DusCldtCD+Wwa7X0+5KTyGZdLWPJ9XPw5HXviWf9gLmtms5z/ZjN+d2QgceTsBOeTd71ur2Gx8YPHvGr/+4XItCkfmXg9mnPNAdc0AcEtZ4UK7Nh1cyGej/JDDNgbSmkBK/icmL7UCaY3IWH1lS7WGYs/jQ8DZgAACDGxUoU8dhfnCAG/K7CXkkcJQ+6O78DA7soc4LJeqT7wJX2C6yjYmzyUAz6lpLmjEG6GlshnUGA0QmDzGI9VQUcWGe6untVIvmrvfmu5knGyw69hAaCK0/7XN23DnjWpTlTay9ek8282ys0fR/aHhcWE1XIpj003veYmdvKrx3ZsA3KGkbpGWGCebv27rfpGrPlYqKej9MWwA406F7VE8x6FdJkLY4/pu8cOj538HBFe7/xMMqQFkfa7y3IcXOMjvOm6zkWQe2fW4TwLgdoesf8Q0SnvMvjKfWJjvR9+iHou6zfBbcedCjxIN58CrInM6cNOz43Ko7+30XPlvyuHZ3EEiN8tfwyvZqsKv1NuU8i0s4wAAA==",
- "authentication_token": "eyJhbGciOiJIUzI1NiIsImtpZCI6IjEiLCJ0eXAiOiJKV1QifQ.eyJ2ZXIiOjEsImlzcyI6InVybjp3aW5k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ication_token": "eyJhbGciOiJIUzI1NiIsImtpZCI6IjEiLCJ0eXAiOiJKV1QifQ.eyJ2ZXIiOjEsImlzcyI6InVybjp3aW5kb3dzOmxpdmVpZCIsImV4cCI6MTM5Mzc5NzU0MywidWlkIjoiYmIyNTA5ZjlhNzc1MTkzMWQxMTQ4NmU1OGE1MmQwMjUiLCJhdWQiOiJ3d3cuZXhhbXBsZS5lZHUiLCJ1cm46bWljcm9zb2Z0OmFwcHVyaSI6ImFwcGlkOi8vMDAwMDAwMDA0QzEwRUEwMyIsInVybjptaWNyb3NvZnQ6YXBwaWQiOiIwMDAwMDAwMDRDMTBFQTAzIn0.cPUa83NJDHEJiZZsdyidVHCZMzgL-gNbAx0RGXQ5IWg"
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.