1 |
|
2 | var d = require("debug")("raptorjs:profile")
|
3 | const Base = require("./Base")
|
4 |
|
5 | class Profile extends Base {
|
6 |
|
7 | constructor (container) {
|
8 | super(container)
|
9 | }
|
10 |
|
11 | getAll(userId) {
|
12 | d("Get all values for %s", userId)
|
13 | userId = userId || this.getContainer().Auth().getUser().id
|
14 | return this.getClient().get(this.route("PROFILE_GET_ALL", userId))
|
15 | }
|
16 |
|
17 | get(key, userId) {
|
18 | d("Get %s for %s", key, userId)
|
19 | userId = userId || this.getContainer().Auth().getUser().id
|
20 | return this.getClient().get(this.route("PROFILE_GET", userId, key))
|
21 | }
|
22 |
|
23 | set(key, value, userId) {
|
24 | d("Set value of %s for %s", key, userId)
|
25 | userId = userId || this.getContainer().Auth().getUser().id
|
26 | return this.getClient().put(this.route("PROFILE_SET", userId, key), value)
|
27 | }
|
28 |
|
29 | delete(key, userId) {
|
30 | d("Delete value of %s for %s", key, userId)
|
31 | userId = userId || this.getContainer().Auth().getUser().id
|
32 | return this.getClient().delete(this.route("PREFERENCES_DELETE", userId, key))
|
33 | }
|
34 |
|
35 | }
|
36 |
|
37 |
|
38 | module.exports = Profile
|