-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsale.service.ts
More file actions
56 lines (53 loc) · 1.52 KB
/
sale.service.ts
File metadata and controls
56 lines (53 loc) · 1.52 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
53
54
55
56
import type {
UserYearAchievementsResponse,
UserYearInReviewResponse,
} from '../schemas/responses'
import { BaseService } from './_base.service'
export class SaleService extends BaseService {
constructor(apiKey: string) {
super(apiKey, 'api', 'ISaleFeatureService')
}
/**
* Attempts to retrieve the achivements for a given app, achieved in that year
* This only will return data for the user if the api key used matches the user's steam account
*/
async getUserYearAchivements(
steamUserId: string,
appid: number,
config: {
year: number
},
): Promise<UserYearAchievementsResponse> {
const url = this.generateSteamUrl(`/GetUserYearAchievements/v1`, {
steamid: steamUserId,
'appids[0]': appid,
year: config.year,
})
const response = await this.sendGETRequest<{
response: UserYearAchievementsResponse
}>(url)
return response.response
}
/**
* Gets the year in review for a user (for past years only) Attempting to get the current year will return an empty response
* This only will return data for the user if the api key used matches the user's steam account
* @param appId
* @returns
*/
async getUserYearInReview(
steamUserId: string,
config: {
year: number
},
): Promise<UserYearInReviewResponse> {
const url = this.generateSteamUrl(`/GetUserYearInReview/v1`, {
steamid: steamUserId,
year: config.year,
fetch_previous_year_summary: true,
})
const response = await this.sendGETRequest<{
response: UserYearInReviewResponse
}>(url)
return response.response
}
}