<commit_before>import { Observable, ReplaySubject } from 'rxjs';

import { API_BASE, API_ORDER } from 'common/constants';
import { http } from 'services/net';


export class OrderServiceProvider {

  constructor(){
  }
  checkoutOrder(user,cart){
    let orders = [];
    let totalPrice = 0;
    for(let o of cart) {
      totalPrice += o.cost;
      orders.push(o.checkoutObject);
    }
    user.updateSaldo(-totalPrice);
    return http.post(`${API_BASE}${API_ORDER}`,{
      user: user.id,
      orders: orders
    }).map((ret) => {
      console.log(ret);
      return ret;
    }).catch((ret) => {
      console.log(ret);
      //Error, add saldo back
      user.updateSaldo(totalPrice);
      return Observable.throw("Something went wrong.");
    });
  }
  
}
// Export single instance
export const orderService = new OrderServiceProvider();<commit_msg>Removed unused map and console.logs<commit_after>import { Observable, ReplaySubject } from 'rxjs';

import { API_BASE, API_ORDER } from 'common/constants';
import { http } from 'services/net';


export class OrderServiceProvider {

  constructor(){
  }
  checkoutOrder(user,cart){
    let orders = [];
    let totalPrice = 0;
    for(let o of cart) {
      totalPrice += o.cost;
      orders.push(o.checkoutObject);
    }
    user.updateSaldo(-totalPrice);
    return http.post(`${API_BASE}${API_ORDER}`,{
      user: user.id,
      orders: orders
    }).catch((ret) => {
      //Error, add saldo back
      user.updateSaldo(totalPrice);
      return Observable.throw("Something went wrong.");
    });
  }

}
// Export single instance
export const orderService = new OrderServiceProvider();
{'fraction_non_alphanumeric': 0.13895631067961164, 'fraction_numerical': 0.0012135922330097086, 'mean_word_length': 3.1225, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '4725290', 'n_tokens_mistral': 509, 'n_tokens_neox': 502, 'n_words': 120}