'use strict';

const client = require('better-call/client');

function createApiClient(options) {
  const { baseURL = "", basePath = "/" } = options ?? {};
  const normalizedBaseURL = baseURL ? baseURL.replace(/\/$/, "") : "";
  const normalizedBasePath = basePath.startsWith("/") ? basePath : `/${basePath}`;
  const finalBasePath = normalizedBasePath.replace(/\/$/, "");
  const apiPath = normalizedBaseURL + finalBasePath;
  return client.createClient({
    baseURL: apiPath
  });
}

exports.createApiClient = createApiClient;
