-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnews.service.ts
More file actions
33 lines (31 loc) · 939 Bytes
/
news.service.ts
File metadata and controls
33 lines (31 loc) · 939 Bytes
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
import type { NewsForAppResponse } from '../schemas/responses'
import { BaseService } from './_base.service'
export class NewsService extends BaseService {
constructor(apiKey: string) {
super(apiKey, 'api', 'ISteamNews')
}
/**
* Returns the latest news for a game
* @param config.count - The number of news items to return. If not set, will return the default number of 20.
* @param config.maxlength - The maximum length of the news item contents field to return. If not set, will return the full content. Otherwise will truncate
*/
async getNewsForApp(
appId: number,
config: {
count?: number
maxlength?: number
} = {
count: 20,
maxlength: undefined,
},
): Promise<NewsForAppResponse> {
const url = this.generateSteamUrl(`/GetNewsForApp/v1`, {
appid: appId,
...config,
})
const response = await this.sendGETRequest<{
appnews: NewsForAppResponse
}>(url)
return response.appnews
}
}