<commit_before>import { Injectable } from 'angular2/core';
import { Http, Response, Headers, RequestOptions } from 'angular2/http';

import { Observable } from 'rxjs/Observable';

// export interface IExpense {
// 	name: string,
// 	amount: number,
// 	currency: string,
// 	vat: number,
// 	invoiceDate: Date,
// 	paymentDate: Date,
// 	category: string,
// 	remark: string,
// 	indexNumber: number
// }

@Injectable()
export class ExpenseService {
  constructor(private _http:Http) {}

  all(): Observable<any> {
    return this._http
      .request("http://localhost:3000/api/expenses")
      .flatMap((res:Response) => <any> res.json()._embedded.expenses);
  }
  
  get(id: string): Observable<any> {
    return this._http
      .request(`http://localhost:3000/api/expenses/${id}`)
      .map((res:Response) => <any> res.json());
  }

  create(expense) {
    let requestOptions = new RequestOptions();
    requestOptions.headers = new Headers();
    requestOptions.headers.append('Content-Type', 'application/hal+json');
        
    return this._http
      .post('http://localhost:3000/api/expenses/', expense, requestOptions)
      .map((res:Response) => <any> res.json());
  }

  update(relSelf, expense) {
    let requestOptions = new RequestOptions();
    requestOptions.headers = new Headers();
    requestOptions.headers.append('Content-Type', 'application/hal+json');
        
    return this._http
      .put(relSelf, expense, requestOptions)
      .map((res:Response) => <any> res.json());
  }

  delete(relSelf) {
    let requestOptions = new RequestOptions();
    requestOptions.headers = new Headers();
    requestOptions.headers.append('Content-Type', 'application/hal+json');
        
    return this._http.delete(relSelf, requestOptions);
  }
}<commit_msg>update to cope with new backend context path<commit_after>import { Injectable } from 'angular2/core';
import { Http, Response, Headers, RequestOptions } from 'angular2/http';

import { Observable } from 'rxjs/Observable';

// export interface IExpense {
// 	name: string,
// 	amount: number,
// 	currency: string,
// 	vat: number,
// 	invoiceDate: Date,
// 	paymentDate: Date,
// 	category: string,
// 	remark: string,
// 	indexNumber: number
// }

@Injectable()
export class ExpenseService {
  constructor(private _http:Http) {}

  all(): Observable<any> {
    return this._http
      .request("http://localhost:3000/accounting/api/expenses")
      .flatMap((res:Response) => <any> res.json()._embedded.expenses);
  }

  get(id: string): Observable<any> {
    return this._http
      .request(`http://localhost:3000/accounting/api/expenses/${id}`)
      .map((res:Response) => <any> res.json());
  }

  create(expense) {
    let requestOptions = new RequestOptions();
    requestOptions.headers = new Headers();
    requestOptions.headers.append('Content-Type', 'application/hal+json');

    return this._http
      .post('http://localhost:3000/accounting/api/expenses/', expense, requestOptions)
      .map((res:Response) => <any> res.json());
  }

  update(relSelf, expense) {
    let requestOptions = new RequestOptions();
    requestOptions.headers = new Headers();
    requestOptions.headers.append('Content-Type', 'application/hal+json');

    return this._http
      .put(relSelf, expense, requestOptions)
      .map((res:Response) => <any> res.json());
  }

  delete(relSelf) {
    let requestOptions = new RequestOptions();
    requestOptions.headers = new Headers();
    requestOptions.headers.append('Content-Type', 'application/hal+json');

    return this._http.delete(relSelf, requestOptions);
  }
}
{'fraction_non_alphanumeric': 0.15793871866295264, 'fraction_numerical': 0.007799442896935933, 'mean_word_length': 3.6216216216216215, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, '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': '352132', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1103, 'n_words': 225}