Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

meocloud

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

meocloud - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

151

lib/meocloud.js

@@ -26,2 +26,3 @@ /*

var CONTENT_ENDPOINT = PROTOCOL + '://api-content.meocloud.pt';
var NOTIFICATIONS_ENDPOINT = PROTOCOL + '://notifications.meocloud.pt';

@@ -43,3 +44,7 @@ /**

options.oauth = config.oauth;
if (!options.noAuth) {
options.oauth = config.oauth;
} else {
delete options.noAuth;
}

@@ -192,2 +197,57 @@ if (Object.keys(query).length > 0) {

var changeShareOwner = function(query, cb) {
var options = {};
options.method = 'POST';
options.uri = [ ENDPOINT, '/1/ChangeShareOwner' ].join('');
return createRequest(options, query, function(err, body, status) {
return cb(err, body, status);
});
};
var participantLeavesSharedFolder = function(path, cb) {
var options = {};
options.method = 'POST';
options.uri = [
ENDPOINT,
'/1/ParticipantLeavesSharedFolder/',
config.root,
path
].join('');
return createRequest(options, {}, function(err, body, status) {
return cb(err, body, status);
});
};
var removeParticipantFromSharedFolder = function(path, query, cb) {
var options = {};
options.method = 'POST';
options.uri = [
ENDPOINT,
'/1/RemoveParticipantFromSharedFolder/',
config.root,
path
].join('');
return createRequest(options, query, function(err, body, status) {
return cb(err, body, status);
});
};
var ownerUnsharesFolder = function(path, cb) {
var options = {};
options.method = 'POST';
options.uri = [
ENDPOINT,
'/1/OwnerUnsharesFolder/',
config.root,
path
].join('');
return createRequest(options, {}, function(err, body, status) {
return cb(err, body, status);
});
};
var thumbnails = function(path, query, cb) {

@@ -345,2 +405,36 @@ var options = {};

var longpollDelta = function(query, cb) {
var options = {};
options.noAuth = true;
options.method = 'GET';
options.uri = [
NOTIFICATIONS_ENDPOINT,
'/notifications/longpoll_delta'
].join('');
return createRequest(options, query, function(err, data, status) {
return cb(err, data, status);
});
};
var latestCursor = function(cb) {
var options = {};
options.method = 'GET';
options.uri = [ ENDPOINT, '/1/LatestCursor' ].join('');
return createRequest(options, {}, function(err, data, status) {
return cb(err, data, status);
});
};
var zipdir = function(path, cb) {
var options = {};
options.method = 'GET';
options.uri = [ ENDPOINT, '/1/Zipdir/' + config.root, path ].join('');
return createRequest(options, {}, function(err, data, status) {
return cb(err, data, status);
});
};
var copy = function(query, cb) {

@@ -414,2 +508,14 @@ var options = {};

var forgetFile = function(query, cb) {
var options = {};
options.method = 'POST';
options.uri = [ ENDPOINT, '/1/Fileops/ForgetFile' ].join('');
query.root = query.root || config.root;
return createRequest(options, query, function(err, data, status) {
return cb(err, data, status);
});
};
var accountInfo = function(cb) {

@@ -425,2 +531,32 @@ var options = {};

var listEvents = function(cb) {
var options = {};
options.method = 'GET';
options.uri = [ ENDPOINT, '/1/ListEvents' ].join('');
return createRequest(options, null, function(err, data, status) {
return cb(err, data, status);
});
};
var disableAccessToken = function(cb) {
var options = {};
options.method = 'POST';
options.uri = [ ENDPOINT, '/1/DisableAccessToken' ].join('');
return createRequest(options, {}, function(err, data, status) {
return cb(err, data, status);
});
};
var changeUserLanguage = function(query, cb) {
var options = {};
options.method = 'POST';
options.uri = [ ENDPOINT, '/1/ChangeUserLanguage' ].join('');
return createRequest(options, query, function(err, data, status) {
return cb(err, data, status);
});
};
return {

@@ -439,2 +575,6 @@ metadata: metadata,

listSharedFolders: listSharedFolders,
changeShareOwner: changeShareOwner,
participantLeavesSharedFolder: participantLeavesSharedFolder,
removeParticipantFromSharedFolder: removeParticipantFromSharedFolder,
ownerUnsharesFolder: ownerUnsharesFolder,
thumbnails: thumbnails,

@@ -450,2 +590,5 @@ search: search,

delta: delta,
longpollDelta: longpollDelta,
latestCursor: latestCursor,
zipdir: zipdir,
copy: copy,

@@ -457,4 +600,8 @@ copyRef: copyRef,

undeleteTree: undeleteTree,
accountInfo: accountInfo
forgetFile: forgetFile,
accountInfo: accountInfo,
listEvents: listEvents,
disableAccessToken: disableAccessToken,
changeUserLanguage: changeUserLanguage
};
};

21

package.json
{
"name": "meocloud",
"version": "1.0.0",
"version": "2.0.0",
"main": "lib/meocloud.js",
"description": "MEOCloud api wrapper (http://meocloud.pt)",
"keywords": ["cloudpt", "meocloud", "cloud", "sapo"],
"keywords": [
"cloudpt",
"meocloud",
"cloud",
"sapo"
],
"homepage": "http://github.com/rogeriopvl/node-meocloud",

@@ -24,7 +29,7 @@ "bugs": "https://github.com/rogeriopvl/meocloud/issues",

"devDependencies": {
"grunt-contrib-jshint": "~0.6.0",
"grunt-contrib-watch": "~0.5.0",
"mocha": "~1.14.0",
"chai": "~1.8.1",
"nock": "~0.22.1",
"grunt-contrib-jshint": "~1.1.0",
"grunt-contrib-watch": "~1.0.0",
"mocha": "^3.4.1",
"chai": "^3.5.0",
"nock": "~9.0.21",
"grunt-simple-mocha": "~0.4.0"

@@ -36,4 +41,4 @@ },

"dependencies": {
"request": "~2.42.0"
"request": "^2.53.0"
}
}
# meocloud [![Build Status](https://secure.travis-ci.org/rogeriopvl/node-meocloud.png?branch=master)](http://travis-ci.org/rogeriopvl/node-meocloud)
[![Greenkeeper badge](https://badges.greenkeeper.io/rogeriopvl/node-meocloud.svg)](https://greenkeeper.io/)
[MEOCloud](http://www.meocloud.pt) api wrapper.

@@ -13,26 +15,30 @@

var config = {
auth: {
consumer_key: 'xxxxxxxxxxxxxx',
consumer_secret: 'xxxxxxxxxxxx',
token: 'xxxxxxxxxxxxxx',
token_secret: 'xxxxxxxxxxxxxx';
},
root: 'meocloud', // or sandbox
noSSL: true // default: false
}
```js
var config = {
auth: {
consumer_key: 'xxxxxxxxxxxxxx',
consumer_secret: 'xxxxxxxxxxxx',
token: 'xxxxxxxxxxxxxx',
token_secret: 'xxxxxxxxxxxxxx';
},
root: 'meocloud', // or sandbox
noSSL: true // default: false
}
var meocloud = require('meocloud')(config);
var meocloud = require('meocloud')(config);
```
### Search for file
var meocloud = require('meocloud')(config);
```js
var meocloud = require('meocloud')(config);
var params = {
query: 'my_search_term'
};
var params = {
query: 'my_search_term'
};
meocloud.search('/', params, function(err, data, status) {
console.log(err, data, status);
});
meocloud.search('/', params, function(err, data, status) {
console.log(err, data, status);
});
```

@@ -45,28 +51,32 @@ ### File Upload

var meocloud = require(meocloud)(config);
```js
var meocloud = require(meocloud)(config);
var params = {}; // add here only the MEOCloud API params
var params = {}; // add here only the MEOCloud API params
meocloud.upload('/file/to/upload.txt', '/new/file/path.txt', params, function(err, data, status) {
console.log(err, data, status);
});
meocloud.upload('/file/to/upload.txt', '/new/file/path.txt', params, function(err, data, status) {
console.log(err, data, status);
});
```
The second one, gives you enough flexibility to adapt to your project, but requires you to provide all the code to deal with files, and returns the request object so you can add event listeners to control the progress or whatever. Here's an example:
var meocloud = require('meocloud')(config);
var fs = require('fs');
```js
var meocloud = require('meocloud')(config);
var fs = require('fs');
fs.stat('/file/to/upload.txt', console.log(err, stat) {
if (err) { throw err; }
fs.stat('/file/to/upload.txt', console.log(err, stat) {
if (err) { throw err; }
var fstream = fs.createReadStream('/file/to/upload.txt');
var params = { overwrite: true };
var fstream = fs.createReadStream('/file/to/upload.txt');
var params = { overwrite: true };
meocloud.putFile('/new/file/path.txt', fstream, stat.size, params, function(err, data, status) {
console.log(err, data, status);
});
meocloud.putFile('/new/file/path.txt', fstream, stat.size, params, function(err, data, status) {
console.log(err, data, status);
});
});
```
##### More samples coming soon ...

@@ -73,0 +83,0 @@

@@ -394,2 +394,122 @@ 'use strict';

describe('ChangeShareOwner', function() {
beforeEach(function(done) {
meocloud = new MEOCloud(config);
done();
});
it('should exist as a public method on MEOCloud', function(done) {
expect(typeof meocloud.changeShareOwner).to.equal('function');
done();
});
it('should make correct changeShareOwner request', function(done) {
nock('https://api.meocloud.pt')
.post('/1/ChangeShareOwner', {
shareid: '9a3c9576-37a9-40fd-8f7b-181f4da2f124',
to_userid: 'foobar'
})
.reply(200, { req_id: '509fc400-2f65-11e2-9501-3c0754179fed' });
meocloud.changeShareOwner({
shareid: '9a3c9576-37a9-40fd-8f7b-181f4da2f124',
to_userid: 'foobar'
}, function(err, data, status) {
expect(err).to.not.be.ok;
expect(data).to.be.an('object');
expect(data).to.have.ownProperty('req_id');
expect(status).to.equal(200);
done();
});
});
});
describe('ParticipantLeavesSharedFolder', function() {
beforeEach(function(done) {
meocloud = new MEOCloud(config);
done();
});
it('should exist as a public method on MEOCloud', function(done) {
expect(typeof meocloud.participantLeavesSharedFolder).to.equal('function');
done();
});
it('should make correct participantLeavesSharedFolder request', function(done) {
nock('https://api.meocloud.pt')
.post('/1/ParticipantLeavesSharedFolder/' + config.root + '/testFolder')
.reply(200, {});
meocloud.participantLeavesSharedFolder(
'/testFolder',
function(err, data, status) {
expect(err).to.not.be.ok;
expect(data).to.be.an('object');
expect(status).to.equal(200);
done();
});
});
});
describe('RemoveParticipantFromSharedFolder', function() {
beforeEach(function(done) {
meocloud = new MEOCloud(config);
done();
});
it('should exist as a public method on MEOCloud', function(done) {
expect(typeof meocloud.removeParticipantFromSharedFolder).to.equal('function');
done();
});
it('should make correct removeParticipantFromSharedFolder request', function(done) {
nock('https://api.meocloud.pt')
.post(
'/1/RemoveParticipantFromSharedFolder/' + config.root + '/testFolder',
{ participantid: 'foobar' }
).reply(200, {});
meocloud.removeParticipantFromSharedFolder('/testFolder',{
participantid: 'foobar'
},
function(err, data, status) {
expect(err).to.not.be.ok;
expect(data).to.be.an('object');
expect(status).to.equal(200);
done();
});
});
});
describe('OwnerUnsharesFolder', function() {
beforeEach(function(done) {
meocloud = new MEOCloud(config);
done();
});
it('should exist as a public method on MEOCloud', function(done) {
expect(typeof meocloud.ownerUnsharesFolder).to.equal('function');
done();
});
it('should make correct ownerUnsharesFolder request', function(done) {
nock('https://api.meocloud.pt')
.post('/1/OwnerUnsharesFolder/' + config.root + '/testFolder')
.reply(200, {});
meocloud.ownerUnsharesFolder(
'/testFolder',
function(err, data, status) {
expect(err).to.not.be.ok;
expect(data).to.be.an('object');
expect(status).to.equal(200);
done();
});
});
});
describe('ShareFolder', function() {

@@ -796,2 +916,91 @@

describe('LongpollDelta', function() {
beforeEach(function(done) {
meocloud = new MEOCloud(config);
done();
});
it('should exist as a public method on MEOCloud', function(done) {
expect(typeof meocloud.longpollDelta).to.equal('function');
done();
});
it('should make correct longpollDelta request', function(done) {
nock('https://notifications.meocloud.pt')
.get('/notifications/longpoll_delta?cursor=1353289183.061f533&timeout=60')
.reply(200, {
changes: true,
backoff: 60
});
meocloud.longpollDelta({
cursor: '1353289183.061f533',
timeout: 60
}, function(err, data, status) {
expect(err).to.not.be.ok;
expect(data).to.be.an('object');
expect(data).to.have.ownProperty('changes');
expect(data).to.have.ownProperty('backoff');
expect(status).to.equal(200);
done();
});
});
});
describe('LatestCursor', function() {
beforeEach(function(done) {
meocloud = new MEOCloud(config);
done();
});
it('should exist as a public method on MEOCloud', function(done) {
expect(typeof meocloud.latestCursor).to.equal('function');
done();
});
it('should make correct latestCursor request', function(done) {
nock('https://api.meocloud.pt')
.get('/1/LatestCursor')
.reply(200, {
cursor: 'foobar123456778-1234456-1234456'
});
meocloud.latestCursor(function(err, data, status) {
expect(err).to.not.be.ok;
expect(data).to.be.an('object');
expect(data).to.have.ownProperty('cursor');
expect(data.cursor).to.equal('foobar123456778-1234456-1234456');
expect(status).to.equal(200);
done();
});
});
});
describe('Zipdir', function() {
beforeEach(function(done) {
meocloud = new MEOCloud(config);
done();
});
it('should exist as a public method on MEOCloud', function(done) {
expect(typeof meocloud.zipdir).to.equal('function');
done();
});
it('should make correct zipdir request', function(done) {
nock('https://api.meocloud.pt')
.get('/1/Zipdir/' + config.root + '/helio')
.reply(200);
meocloud.zipdir('/helio', function(err, data, status) {
expect(err).to.not.be.ok;
expect(status).to.equal(200);
done();
});
});
});
describe('Copy', function() {

@@ -1026,2 +1235,35 @@

describe('ForgetFile', function() {
beforeEach(function(done) {
meocloud = new MEOCloud(config);
done();
});
it('should exist as a public method on MEOCloud', function(done) {
expect(typeof meocloud.forgetFile).to.equal('function');
done();
});
it('should make correct forgetFile request', function(done) {
nock('https://api.meocloud.pt')
.post('/1/Fileops/ForgetFile', {
root: config.root,
path: '/meocloud_TEST.md'
})
.reply(200, { res: 'ok' });
meocloud.forgetFile({
root: config.root,
path: '/meocloud_TEST.md'
}, function(err, data, status) {
expect(err).to.not.be.ok;
expect(data).to.be.an('object');
expect(data).to.have.ownProperty('res');
expect(status).to.equal(200);
done();
});
});
});
describe('AccountInfo', function() {

@@ -1063,2 +1305,87 @@

describe('ListEvents', function() {
beforeEach(function(done) {
meocloud = new MEOCloud(config);
done();
});
it('should exist as a public method on MEOCloud', function(done) {
expect(typeof meocloud.listEvents).to.equal('function');
done();
});
it('should make correct listEvents request', function(done) {
nock('https://api.meocloud.pt')
.get('/1/ListEvents')
.reply(200, [
{
event_id: 'abcdefg123',
count: 1,
}
]);
meocloud.listEvents(function(err, data, status) {
expect(err).to.not.be.ok;
expect(data).to.be.an('array');
expect(data[0]).to.have.ownProperty('event_id');
expect(data[0]).to.have.ownProperty('count');
expect(status).to.equal(200);
done();
});
});
});
describe('DisableAccessToken', function() {
beforeEach(function(done) {
meocloud = new MEOCloud(config);
done();
});
it('should exist as a public method on MEOCloud', function(done) {
expect(typeof meocloud.disableAccessToken).to.equal('function');
done();
});
it('should make correct disableAccessToken request', function(done) {
nock('https://api.meocloud.pt')
.post('/1/DisableAccessToken')
.reply(200, {});
meocloud.disableAccessToken(function(err, data, status) {
expect(err).to.not.be.ok;
expect(data).to.be.an('object');
expect(status).to.equal(200);
done();
});
});
});
describe('ChangeUserLanguage', function() {
beforeEach(function(done) {
meocloud = new MEOCloud(config);
done();
});
it('should exist as a public method on MEOCloud', function(done) {
expect(typeof meocloud.changeUserLanguage).to.equal('function');
done();
});
it('should make correct changeUserLanguage request', function(done) {
nock('https://api.meocloud.pt')
.post('/1/ChangeUserLanguage')
.reply(200, {});
meocloud.changeUserLanguage({ lang_code: 'end' }, function(err, data, status) {
expect(err).to.not.be.ok;
expect(data).to.be.an('object');
expect(status).to.equal(200);
done();
});
});
});
describe('Protocol', function() {

@@ -1065,0 +1392,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc