juice-shop

Форк
0
/
challenge.service.ts 
52 строки · 2.3 Кб
1
/*
2
 * Copyright (c) 2014-2024 Bjoern Kimminich & the OWASP Juice Shop contributors.
3
 * SPDX-License-Identifier: MIT
4
 */
5

6
import { environment } from '../../environments/environment'
7
import { HttpClient } from '@angular/common/http'
8
import { Injectable } from '@angular/core'
9
import { type Observable } from 'rxjs'
10
import { catchError, map } from 'rxjs/operators'
11
import { type Challenge } from '../Models/challenge.model'
12

13
@Injectable({
14
  providedIn: 'root'
15
})
16
export class ChallengeService {
17
  private readonly hostServer = environment.hostServer
18
  private readonly host = this.hostServer + '/api/Challenges'
19
  constructor (private readonly http: HttpClient) { }
20

21
  find (params?: any): Observable<Challenge[]> {
22
    return this.http.get(this.host + '/', { params }).pipe(map((response: any) => response.data), catchError((err) => { throw err }))
23
  }
24

25
  repeatNotification (challengeName: string) {
26
    return this.http.get(this.hostServer + '/rest/repeat-notification', { params: { challenge: challengeName }, responseType: 'text' as const }).pipe(catchError((err) => { throw err }))
27
  }
28

29
  continueCode () {
30
    return this.http.get(this.hostServer + '/rest/continue-code').pipe(map((response: any) => response.continueCode), catchError((err) => { throw err }))
31
  }
32

33
  continueCodeFindIt () {
34
    return this.http.get(this.hostServer + '/rest/continue-code-findIt').pipe(map((response: any) => response.continueCode), catchError((err) => { throw err }))
35
  }
36

37
  continueCodeFixIt () {
38
    return this.http.get(this.hostServer + '/rest/continue-code-fixIt').pipe(map((response: any) => response.continueCode), catchError((err) => { throw err }))
39
  }
40

41
  restoreProgress (continueCode: string) {
42
    return this.http.put(this.hostServer + '/rest/continue-code/apply/' + continueCode, {}).pipe(map((response: any) => response.data), catchError((err) => { throw err }))
43
  }
44

45
  restoreProgressFindIt (continueCode: string) {
46
    return this.http.put(this.hostServer + '/rest/continue-code-findIt/apply/' + continueCode, {}).pipe(map((response: any) => response.data), catchError((err) => { throw err }))
47
  }
48

49
  restoreProgressFixIt (continueCode: string) {
50
    return this.http.put(this.hostServer + '/rest/continue-code-fixIt/apply/' + continueCode, {}).pipe(map((response: any) => response.data), catchError((err) => { throw err }))
51
  }
52
}
53

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.