-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathathlete.js
More file actions
52 lines (44 loc) · 1.23 KB
/
athlete.js
File metadata and controls
52 lines (44 loc) · 1.23 KB
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
var athlete = function (client) {
this.client = client
}
var _qsAllowedProps = [
// pagination
'page',
'per_page',
// listActivities
'before',
'after'
]
var _updateAllowedProps = [
'weight',
'ftp'
]
//= ==== athlete endpoint =====
athlete.prototype.get = async function (args) {
var endpoint = 'athlete'
return await this.client.getEndpoint(endpoint, args)
}
athlete.prototype.listActivities = async function (args) {
return await this._listHelper('activities', args)
}
athlete.prototype.listClubs = async function (args) {
return await this._listHelper('clubs', args)
}
athlete.prototype.listZones = async function (args) {
return await this._listHelper('zones', args)
}
athlete.prototype.update = async function (args) {
var endpoint = 'athlete'
args.body = this.client.getRequestBodyObj(_updateAllowedProps, args)
return await this.client.putEndpoint(endpoint, args)
}
//= ==== athlete.prototype endpoint =====
//= ==== helpers =====
athlete.prototype._listHelper = async function (listType, args) {
var endpoint = 'athlete/'
var qs = this.client.getQS(_qsAllowedProps, args)
endpoint += listType + '?' + qs
return await this.client.getEndpoint(endpoint, args)
}
//= ==== helpers =====
module.exports = athlete