<commit_before>import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs';

import { Challenge } from './../models/Challenge';

@Injectable()
export class ChallengeService {

    constructor(private httpSrv:Http) {}

    /**
     * Get all the current challenges
     * @retuns {Observable<Array<Challenge>} challenges.
     */
    getCurrentChallenges(): Observable<Array<Object>> {
        return this.httpSrv.get('/api/challenges')
            .map((res:Response) => res.json().challenges)
            .catch((res:Response) => res.json().error);
    }

    /**
     * Create new challenge, assign a identifier and returns it.
     * @param playerId {string} the socketId.
     * @returns {string} UUID (v4).
     */
    createChallengeId(playerId: string): Observable<string> {
        return this.httpSrv.post('/api/challenges/create', { playerId: playerId })
            .map((res:Response) => res.json().uuid)
            .catch((res:Response) => res.json().error);
    }

    /**
     * Return all the information related to the specified challenge.
     * @param challengeId {string} the challenge identifier.
     * @returns {Challenge} challenge.
     */
    getChallengeInfo(challengeId: string): Observable<Challenge> {
        return this.httpSrv.get('/api/challenges/challenge/' + challengeId)
            .map((res:Response) => res.json().challenge)
            .catch((res:Response) => res.json().error);
    }

    /**
     * Check if exists a specified challenge.
     * @param challengeId {string} the challenge identifier.
     * @returns {boolean} exists.
     */
    checkIfChallengeIdExists(challengeId: string): Observable<boolean> {
        return this.httpSrv.get('/api/challenges/check-challenge-id/' + challengeId)
            .map((res:Response) => res.json().exists)
            .catch((res:Response) => res.json().error);
    }

    /**
     * Add the user into a challenge room.
     * @param challengeId {string} the challenge identifier.
     * @param socketId {SocketIO.client} the client-side socket.
     */
    joinToChallengeRoom(challengeId: string, socketId: string) {
        return this.httpSrv.post('/api/challenges/join', {
                challengeId: challengeId,
                playerId: socketId
            })
            .map((res:Response) => res.json())
            .catch((res:Response) => res.json().error);
    }

}<commit_msg>Added challenge parameters like direction, duration and mode<commit_after>import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs';

import { Challenge } from './../models/Challenge';

@Injectable()
export class ChallengeService {

    constructor(private httpSrv:Http) {}

    /**
     * Get all the current challenges
     * @retuns {Observable<Array<Challenge>} challenges.
     */
    getCurrentChallenges(): Observable<Array<Object>> {
        return this.httpSrv.get('/api/challenges')
            .map((res:Response) => res.json().challenges)
            .catch((res:Response) => res.json().error);
    }

    /**
     * Create new challenge, assign a identifier and returns it.
     * @param playerId {string} the socketId.
     * @returns {string} UUID (v4).
     */
    createChallengeId(playerId: string, direction: string, duration: number, mode: string): Observable<string> {
        return this.httpSrv.post('/api/challenges/create', { 
                playerId: playerId,
                direction: direction,
                duration: duration,
                mode: mode
            })
            .map((res:Response) => res.json().uuid)
            .catch((res:Response) => res.json().error);
    }

    /**
     * Return all the information related to the specified challenge.
     * @param challengeId {string} the challenge identifier.
     * @returns {Challenge} challenge.
     */
    getChallengeInfo(challengeId: string): Observable<Challenge> {
        return this.httpSrv.get('/api/challenges/challenge/' + challengeId)
            .map((res:Response) => res.json().challenge)
            .catch((res:Response) => res.json().error);
    }

    /**
     * Check if exists a specified challenge.
     * @param challengeId {string} the challenge identifier.
     * @returns {boolean} exists.
     */
    checkIfChallengeIdExists(challengeId: string): Observable<boolean> {
        return this.httpSrv.get('/api/challenges/check-challenge-id/' + challengeId)
            .map((res:Response) => res.json().exists)
            .catch((res:Response) => res.json().error);
    }

    /**
     * Add the user into a challenge room.
     * @param challengeId {string} the challenge identifier.
     * @param socketId {SocketIO.client} the client-side socket.
     */
    joinToChallengeRoom(challengeId: string, socketId: string) {
        return this.httpSrv.post('/api/challenges/join', {
                challengeId: challengeId,
                playerId: socketId
            })
            .map((res:Response) => res.json())
            .catch((res:Response) => res.json().error);
    }

}
{'fraction_non_alphanumeric': 0.1409082050282596, 'fraction_numerical': 0.0003897875657766517, 'mean_word_length': 2.541752933057281, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7475891', 'n_tokens_mistral': 1502, 'n_tokens_neox': 1415, 'n_words': 327}