// const MUVE_MASTER_API_URL = 'test'
const getUrlQuery = (obj) => {
if(typeof obj !== 'object' || !obj) {
return '';
}
return `?${Object.entries(obj).map(([key, value]) => {
if(Array.isArray(value)) {
return `${key}=${JSON.stringify(value)}`
} else {
const encodedKey = encodeURIComponent(key);
const encodedValue = encodeURIComponent(value);
return `${encodedKey}=${encodedValue}`
}
}).join('&')}`
}
// function getUrlBasedOnType(type, id, obj = null) {
// switch (type) {
// case 'one':
// return `${MUVE_MASTER_API_URL}/case?id=${id}`;
// case 'two':
// return `${MUVE_MASTER_API_URL}/hoowla-person?id=${id}`;
// case 'three':
// return `${MUVE_MASTER_API_URL}/cases/${id}/custom-field${getUrlQuery(obj)}`;
// default:
// throw new Error("Unsupported type");
// }
// }
// console.log(getUrlBasedOnType('three', 1, {
// key: 'value',
// key2: 'value2',
// key3: 'value3'
// }))
const MUVE_MASTER_API_URL = 'https://lsdjkfl'
function getUrlBasedOnType(type, id, customFieldsArray = null) {
switch (type) {
case ENUMS.HOOWLA_CASE:
return `${MUVE_MASTER_API_URL}/case?id=${id}`
case ENUMS.HOOWLA_PERSON:
return `${MUVE_MASTER_API_URL}/hoowla-person?id=${id}`
case 'one':
return `${MUVE_MASTER_API_URL}/cases/${id}/custom-field?${getUrlQuery(customFieldsArray)}`
default:
throw new Error("Unsupported type");
}
}
console.log(getUrlBasedOnType('one', 'tsldkf', {
'fiels': 'one',
'field2': 'two',
'field3': ['one', 'two', 'three']
}))
// const _ = require("lodash")
// console.log(_.sortBy(["C3", "C1", "C2"]));
// const MUVE_MASTER_API_URL = 'test'
// const getUrlQuery = (obj) => {
// if(typeof obj !== 'object' || !obj) {
// return '';
// }
// return `?${Object.entries(obj).map(([key, value]) => {
// const encodedKey = encodeURIComponent(key);
// const encodedValue = encodeURIComponent(value);
// return `${encodedKey}=${encodedValue}`
// }).join('&')}`
// }
// function getUrlBasedOnType(type, id, obj = null) {
// switch (type) {
// case 'one':
// return `${MUVE_MASTER_API_URL}/case?id=${id}`;
// case 'two':
// return `${MUVE_MASTER_API_URL}/hoowla-person?id=${id}`;
// case 'three':
// return `${MUVE_MASTER_API_URL}/cases/${id}/custom-field${getUrlQuery(obj)}`;
// default:
// throw new Error("Unsupported type");
// }
// }
// console.log(getUrlBasedOnType('three', 1, {
// key: ``,
// key2: 'value2',
// key3: 'value3'
// }))