-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathindex.js
77 lines (51 loc) · 1.58 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* Module dependencies
*/
var _ = require('lodash'),
mapObj = require('./util/mapObj'),
Request = require('./request'),
OAuth = require('./oauth'),
affordances = require('./affordances');
/**
* Core DZ object which wraps calls to the Deezer API
*
*
* Deezer REST API docs: (for reference)
* http://developers.deezer.com/api
*
* API Explorer:
* http://developers.deezer.com/api/explorer
*/
function DZ (options) {
// TODO: *Enhancement*
// allow `options` argument to override core defaults (e.g. apiEndpointUrl)
// (use case: e.g. future API versions)
// Pulled from http://developers.deezer.com/api and http://developers.deezer.com/api/oauth
this.endpoints = {
// Base URL for accessing core Deezer resources as a particular user
resources: 'https://api.deezer.com',
// URL where user should be redirected to allow this app's access to the Deezer API
userAuth: 'https://connect.deezer.com/oauth/auth.php',
// URL where the access token for a user can be retrieved
accessToken: 'https://connect.deezer.com/oauth/access_token.php/'
};
// Mixin OAuth methods
_.extend(this, OAuth);
// Mixin API request methods
_.extend(this, Request);
/**
* More initialization/configuration logic
*/
// Ensure that both URLs have no trailing slash
this.endpoints = mapObj(this.endpoints, function (url) {
return url.replace(/\/$/, '');
});
/**
* Apply usage affordances
*
* (friendly error messages in case a developer is trying to use methods
* from the client-side JavaScript SDK)
*/
affordances.apply(this);
}
module.exports = DZ;