<commit_before>/**
 * Created by wiekonek on 13.12.16.
 */
import {Http, RequestOptions, URLSearchParams} from "@angular/http";
import {Observable} from "rxjs";
import {AppAuthenticationService} from "../../app-authentication.service";
import {PaginateResponse} from "./paginate-response";
import {Card} from "../../card/card";

export abstract class BaseCardService {

  constructor(protected http: Http, protected pluginAuth: AppAuthenticationService) {}

  protected _get<T>(path: string, params?: URLSearchParams): Observable<T> {
   let req = new RequestOptions({search: this.pluginAuth.RequestOptionsWithPluginAuthentication.search});
   if(params != null)
     req.search.appendAll(params);
   return this.http
     .get(path, req)
     .map(res => res.json());
  }

  protected _getPage<T extends Card>(path: string, page: number, size: number): Observable<PaginateResponse<T>> {
    return this._get(path, this.paginationParams(page, size));
  }


  private paginationParams(page: number, size: number): URLSearchParams {
    let params = new URLSearchParams();
    params.append('page', page.toString());
    params.append('size', size.toString());
    return params;
  }
}<commit_msg>Create new instance of UrlSearchParams in base _get method.<commit_after>/**
 * Created by wiekonek on 13.12.16.
 */
import {Http, RequestOptions, URLSearchParams} from "@angular/http";
import {Observable} from "rxjs";
import {AppAuthenticationService} from "../../app-authentication.service";
import {PaginateResponse} from "./paginate-response";
import {Card} from "../../card/card";

export abstract class BaseCardService {

  constructor(protected http: Http, protected pluginAuth: AppAuthenticationService) {}

  protected _get<T>(path: string, params?: URLSearchParams): Observable<T> {
   let req = new RequestOptions({search: new URLSearchParams(
     this.pluginAuth.RequestOptionsWithPluginAuthentication.search.rawParams)});
   if(params != null)
     req.search.appendAll(params);
   return this.http
     .get(path, req)
     .map(res => res.json());
  }

  protected _getPage<T extends Card>(path: string, page: number, size: number): Observable<PaginateResponse<T>> {
    return this._get(path, this.paginationParams(page, size));
  }


  private paginationParams(page: number, size: number): URLSearchParams {
    let params = new URLSearchParams();
    params.append('page', page.toString());
    params.append('size', size.toString());
    return params;
  }
}
{'fraction_non_alphanumeric': 0.1407197735543874, 'fraction_numerical': 0.004852405984634048, 'mean_word_length': 4.726851851851852, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '1452961', 'n_tokens_mistral': 712, 'n_tokens_neox': 700, 'n_words': 186}