@capillarytech/creatives-library 7.7.20 → 7.7.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/services/api.js +20 -5
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -32,6 +32,16 @@ function parseJSON(response) {
|
|
|
32
32
|
return response.json();
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
function getUrlWithQueryParams({url, queryParams}) {
|
|
36
|
+
let updatedUrl = url;
|
|
37
|
+
Object.entries(queryParams).forEach(([key, value]) => {
|
|
38
|
+
if (value !== undefined) {
|
|
39
|
+
updatedUrl += `${key}=${key === 'name' ? encodeURIComponent(value) : value}&`;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return updatedUrl;
|
|
43
|
+
};
|
|
44
|
+
|
|
35
45
|
// const loginUrl = (process.env.NODE_ENV === 'production') ?
|
|
36
46
|
// config.production.login_url : config.development.login_url;
|
|
37
47
|
|
|
@@ -250,20 +260,25 @@ export const getTemplateDetails = ({id, channel}) => {
|
|
|
250
260
|
return request(url, getAPICallObject('GET'));
|
|
251
261
|
};
|
|
252
262
|
|
|
253
|
-
export const getAllTemplates = ({channel, queryParams}) => {
|
|
254
|
-
const url =
|
|
263
|
+
export const getAllTemplates = ({channel, queryParams = {}}) => {
|
|
264
|
+
const url = getUrlWithQueryParams({
|
|
265
|
+
url: `${API_ENDPOINT}/templates/${channel}?`,
|
|
266
|
+
queryParams,
|
|
267
|
+
});
|
|
255
268
|
return request(url, getAPICallObject('GET'));
|
|
256
269
|
};
|
|
257
270
|
|
|
258
271
|
export const deleteTemplate = ({channel, id}) => {
|
|
259
|
-
|
|
260
272
|
const url = `${API_ENDPOINT}/templates/${id}/${channel}`;
|
|
261
273
|
return request(url, getAPICallObject('DELETE'));
|
|
262
274
|
//return API.deleteResource(url);
|
|
263
275
|
};
|
|
264
276
|
|
|
265
|
-
export const getAllAssets = ({assetType, queryParams}) => {
|
|
266
|
-
const url =
|
|
277
|
+
export const getAllAssets = ({assetType, queryParams = {}}) => {
|
|
278
|
+
const url = getUrlWithQueryParams({
|
|
279
|
+
url: `${API_ENDPOINT}/assets/${assetType}?`,
|
|
280
|
+
queryParams,
|
|
281
|
+
});
|
|
267
282
|
// const url = `https://nightly.capillary.in/arya/api/v1/creatives/assets/${assetType}?query=${JSON.stringify(queryParams)}`;
|
|
268
283
|
return API.get(url);
|
|
269
284
|
}
|