-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathpvp.js
153 lines (131 loc) · 3.14 KB
/
pvp.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
const AbstractEndpoint = require('../endpoint')
module.exports = class PvpEndpoint extends AbstractEndpoint {
constructor (client, fromAccount) {
super(client)
this.fromAccount = fromAccount
}
amulets () {
return new AmuletsEndpoint(this)
}
games () {
return new GamesEndpoint(this)
}
heroes () {
if (this.fromAccount) {
return new AccountHeroesEndpoint(this)
}
return new HeroesEndpoint(this)
}
ranks () {
return new RanksEndpoint(this)
}
seasons (id) {
return new SeasonsEndpoint(this, id)
}
standings () {
return new StandingsEndpoint(this)
}
stats () {
return new StatsEndpoint(this)
}
}
class AccountHeroesEndpoint extends AbstractEndpoint {
constructor (client) {
super(client)
this.url = '/v2/account/pvp/heroes'
this.isAuthenticated = true
this.cacheTime = 5 * 60
}
}
class AmuletsEndpoint extends AbstractEndpoint {
constructor (client) {
super(client)
this.url = '/v2/pvp/amulets'
this.isPaginated = true
this.isBulk = true
this.isLocalized = true
this.cacheTime = 24 * 60 * 60
}
}
class GamesEndpoint extends AbstractEndpoint {
constructor (client) {
super(client)
this.url = '/v2/pvp/games'
this.isPaginated = true
this.isBulk = true
this.isAuthenticated = true
this.cacheTime = 5 * 60
}
}
class HeroesEndpoint extends AbstractEndpoint {
constructor (client) {
super(client)
this.url = '/v2/pvp/heroes'
this.isPaginated = true
this.isBulk = true
this.isLocalized = true
this.cacheTime = 24 * 60 * 60
}
}
class RanksEndpoint extends AbstractEndpoint {
constructor (client) {
super(client)
this.url = '/v2/pvp/ranks'
this.isPaginated = true
this.isBulk = true
this.isLocalized = true
this.cacheTime = 24 * 60 * 60
}
}
class SeasonsEndpoint extends AbstractEndpoint {
constructor (client, id) {
super(client)
this.id = id
this.url = '/v2/pvp/seasons'
this.isPaginated = true
this.isBulk = true
this.isLocalized = true
this.cacheTime = 24 * 60 * 60
}
leaderboards () {
return new SeasonLeaderboardEndpoint(this, this.id)
}
}
class SeasonLeaderboardEndpoint extends AbstractEndpoint {
constructor (client, id) {
super(client)
this.id = id
this.url = `/v2/pvp/seasons/${id}/leaderboards`
this.cacheTime = 24 * 60 * 60
}
ids () {
return super.get('', true)
}
board (board, region) {
return new SeasonLeaderboardBoardEndpoint(this, this.id, board, region)
}
}
class SeasonLeaderboardBoardEndpoint extends AbstractEndpoint {
constructor (client, id, board, region) {
super(client)
this.url = `/v2/pvp/seasons/${id}/leaderboards/${board}/${region}`
this.isPaginated = true
this.cacheTime = 5 * 60
}
}
class StandingsEndpoint extends AbstractEndpoint {
constructor (client) {
super(client)
this.url = '/v2/pvp/standings'
this.isAuthenticated = true
this.cacheTime = 5 * 60
}
}
class StatsEndpoint extends AbstractEndpoint {
constructor (client) {
super(client)
this.url = '/v2/pvp/stats'
this.isAuthenticated = true
this.cacheTime = 5 * 60
}
}