@capillarytech/creatives-library 7.7.19 → 7.7.21
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 +18 -5
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -32,6 +32,14 @@ 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
|
+
updatedUrl += `${key}=${key === 'name' ? encodeURIComponent(value) : value}&`;
|
|
39
|
+
});
|
|
40
|
+
return updatedUrl;
|
|
41
|
+
};
|
|
42
|
+
|
|
35
43
|
// const loginUrl = (process.env.NODE_ENV === 'production') ?
|
|
36
44
|
// config.production.login_url : config.development.login_url;
|
|
37
45
|
|
|
@@ -250,20 +258,25 @@ export const getTemplateDetails = ({id, channel}) => {
|
|
|
250
258
|
return request(url, getAPICallObject('GET'));
|
|
251
259
|
};
|
|
252
260
|
|
|
253
|
-
export const getAllTemplates = ({channel, queryParams}) => {
|
|
254
|
-
const url =
|
|
261
|
+
export const getAllTemplates = ({channel, queryParams = {}}) => {
|
|
262
|
+
const url = getUrlWithQueryParams({
|
|
263
|
+
url: `${API_ENDPOINT}/templates/${channel}?`,
|
|
264
|
+
queryParams,
|
|
265
|
+
});
|
|
255
266
|
return request(url, getAPICallObject('GET'));
|
|
256
267
|
};
|
|
257
268
|
|
|
258
269
|
export const deleteTemplate = ({channel, id}) => {
|
|
259
|
-
|
|
260
270
|
const url = `${API_ENDPOINT}/templates/${id}/${channel}`;
|
|
261
271
|
return request(url, getAPICallObject('DELETE'));
|
|
262
272
|
//return API.deleteResource(url);
|
|
263
273
|
};
|
|
264
274
|
|
|
265
|
-
export const getAllAssets = ({assetType, queryParams}) => {
|
|
266
|
-
const url =
|
|
275
|
+
export const getAllAssets = ({assetType, queryParams = {}}) => {
|
|
276
|
+
const url = getUrlWithQueryParams({
|
|
277
|
+
url: `${API_ENDPOINT}/assets/${assetType}?`,
|
|
278
|
+
queryParams,
|
|
279
|
+
});
|
|
267
280
|
// const url = `https://nightly.capillary.in/arya/api/v1/creatives/assets/${assetType}?query=${JSON.stringify(queryParams)}`;
|
|
268
281
|
return API.get(url);
|
|
269
282
|
}
|