<commit_before>const JsonRestApi = require("qmerce-rest");
const Cart = require("./cart.js");
const Customer = require("./customer.js");
const Order = require("./order.js");
const Product = require("./product.js");

module.exports = function(apiUrl, basicAuth) {
	const server = JsonRestApi(apiUrl, basicAuth);
	
	const lastUrlPart = (url) => {
		const parts = url.split("/");
		return parts[parts.length-1];
	}

	const newCart = (cartUrl)  => {
		const cartId = lastUrlPart(cartUrl);
		return new Cart(cartId, server);
	};

	const newCustomer = (customerUrl)  => {
		const customerId = lastUrlPart(customerUrl);
		return new Customer(customerId, server);
	};

	return {
		createCart: (customerId) => server.postAsync(customerId === undefined ? "/cart" : "/cart/customer/" + customerId, null).then(newCart),
		cart: (id) => new Cart(id, server),
		customer: (id) => new Customer(id, server),
		order: (id) => new Order(id, server),
		product: (id) => new Product(id, server),
		getAllShippingMethods: () => server.getAsync("/shipment").then((data) => data.shippingMethods),
		validateCartAddress: (address) => server.postAsync("/validate/cartAddress", address),
		validateCustomerAddress: (address) => server.postAsync("/validate/customerAddress", address),
		completeAddress: (address) => server.postAsync("/api/service/addressCompletion", address),
		
		createCustomer: (data) => server.postAsync("/customer", data).then(newCustomer)
	}
};<commit_msg>fixed addressCompletion URL<commit_after>const JsonRestApi = require("qmerce-rest");
const Cart = require("./cart.js");
const Customer = require("./customer.js");
const Order = require("./order.js");
const Product = require("./product.js");

module.exports = function(apiUrl, basicAuth) {
	const server = JsonRestApi(apiUrl, basicAuth);
	
	const lastUrlPart = (url) => {
		const parts = url.split("/");
		return parts[parts.length-1];
	}

	const newCart = (cartUrl)  => {
		const cartId = lastUrlPart(cartUrl);
		return new Cart(cartId, server);
	};

	const newCustomer = (customerUrl)  => {
		const customerId = lastUrlPart(customerUrl);
		return new Customer(customerId, server);
	};

	return {
		createCart: (customerId) => server.postAsync(customerId === undefined ? "/cart" : "/cart/customer/" + customerId, null).then(newCart),
		cart: (id) => new Cart(id, server),
		customer: (id) => new Customer(id, server),
		order: (id) => new Order(id, server),
		product: (id) => new Product(id, server),
		getAllShippingMethods: () => server.getAsync("/shipment").then((data) => data.shippingMethods),
		validateCartAddress: (address) => server.postAsync("/validate/cartAddress", address),
		validateCustomerAddress: (address) => server.postAsync("/validate/customerAddress", address),
		completeAddress: (address) => server.postAsync("/service/addressCompletion", address),
		
		createCustomer: (data) => server.postAsync("/customer", data).then(newCustomer)
	}
};
{'fraction_non_alphanumeric': 0.17386831275720166, 'fraction_numerical': 0.0006858710562414266, 'mean_word_length': 5.259656652360515, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, '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': '5340589', 'n_tokens_mistral': 926, 'n_tokens_neox': 877, 'n_words': 198}