A NodeJS client for the FreeboxOS API.
Documentation : http://dev.freebox.fr/sdk/os/
This module is installed via npm:
$ npm install freebox-os-client
All the methods have the same parameters :
- routeParam : The parameters in the route of the endpoint
- bodyParam : The data to send to the endpoint
- sessiontoken : The session token needed if the endpoint require authentication
- callback : The callback function
var routeParam = {
track_id: 42
};
var bodyParam = {
app_id: "fr.freebox.testapp",
password: "d4da8517c2c25b1b145f2e5ba91bd0589fc0053d"
};
var sessionToken = "35JYdQSvkcBYK84IFMU7H86clfhS75OzwlQrKlQN1gBch\/Dd62RGzDpgC7YB9jB2";
function callback(response) {
// ...
}
client.endpointMethod(routeParam,bodyParam,sessiontoken,callback);
The default callback function is :
function defaultCallback(response) {
console.log(JSON.stringify(response));
}
The callback function has only one parameter : response
The response convention is :
- On communication success : The same as the freebox, see the documentation
- On communication error : The response returned looks :
response = {
success: false, // Always set to false
msg: Forbidden // The error
error_code: 403// The status code of the response
}
var freebox = {
url: 'mafreebox.freebox.fr',
port: 80
};
var tokenRequest = {
app_id: 'fr.freebox.clientapp',
app_name: 'Client App',
app_version: '0.0.7',
device_name: 'Pc de Xavier'
};
var client = require('freebox-os-client')(freebox);
client.requestAuthorization(null,tokenRequest,null,function(response) {
console.log(JSON.stringify(response));
});
In this case, the callback function is the default so there is the same result with :
var freebox = {
url: 'mafreebox.freebox.fr',
port: 80
};
var tokenRequest = {
app_id: 'fr.freebox.clientapp',
app_name: 'Client App',
app_version: '0.0.7',
device_name: 'Pc de Xavier'
};
var client = require('freebox-os-client')(freebox);
client.requestAuthorization(null,tokenRequest);
var freebox = {
url: 'mafreebox.freebox.fr',
port: 80
};
var app = {
app_id: 'fr.freebox.clientapp',
app_token: '35JYdQSvkcBYK84IFMU7H86clfhS75OzwlQrKlQN1gBch\/Dd62RGzDpgC7YB9jB2'
};
var routeParam = {
track_id: app.track_id
};
var client = require('freebox-os-client')(freebox);
client.trackAuthorizationProgress(routeParam);
var crypto = require('crypto');
var freebox = {
url: 'mafreebox.freebox.fr',
port: 80
};
var app = {
app_id: 'fr.freebox.clientapp',
app_token: '35JYdQSvkcBYK84IFMU7H86clfhS75OzwlQrKlQN1gBch\/Dd62RGzDpgC7YB9jB2'
};
var client = require('freebox-os-client')(freebox);
client.getChallenge(null, null, null, function(response) {
if (response.success) {
var sessionStart = {
app_id: app.app_id,
app_version: app.app_version,
password: crypto.createHmac('sha1', app.app_token).update(response.result.challenge).digest('hex')
};
client.openSession(null, sessionStart);
}
});
Name | Method |
---|---|
Request authorization | requestAuthorization |
Track authorization progress | trackAuthorizationProgress |
Getting the challenge value | getChallenge |
Opening a session | openSession |
Closing the current session | closeSession |
Name | Method |
---|---|
Retrieve all Download tasks | getAllDownloads |
Retrieve a Download task | getDownload |
Delete a Download task | deleteDownload |
Erase a Download task | eraseDownload |
Update a Download task | updateDownload |
Get download log | getDownloadLog |
Adding a new Download task by url | addDownloadByUrl |
Get the Download Stats | getDownloadStats |
Get the list of files for a given Download | getFilesOfDownload |
Change the priority of a Download File | changePriorityOfDownloadFile |
####Download
- Adding a new Download task by file upload
- UNSTABLES
The MIT License (MIT)
Copyright (c) 2014 trusta
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.