Skip to content

Commit ac7ee10

Browse files
Enhance Taxonomy publish function to accept optional query parameters, including branch for request headers.
1 parent 501c8f8 commit ac7ee10

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/stack/taxonomy/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ export function Taxonomy (http, data = {}) {
273273
* @func publish
274274
* @param {Object} data - Publish details
275275
* @param {string} [api_version=''] - Optional API version (e.g., '3.2')
276+
* @param {Object=} params - Optional query parameters. If params.branch is set, it is sent as the branch request header.
276277
* @returns {Promise<Object>} Response object with publish job details
277278
* @example
278279
* import * as contentstack from '@contentstack/management'
@@ -295,14 +296,19 @@ export function Taxonomy (http, data = {}) {
295296
* client.stack({ api_key: 'api_key'}).taxonomy().publish(publishData, '3.2')
296297
* .then((response) => console.log(response))
297298
*/
298-
this.publish = async function (data, api_version = '') {
299+
this.publish = async function (data, api_version = '', params = {}) {
299300
try {
301+
const { branch, ...queryParams } = params
300302
const headers = {
301-
headers: { ...cloneDeep(this.stackHeaders) }
303+
headers: { ...cloneDeep(this.stackHeaders) },
304+
params: queryParams
302305
}
303306
if (api_version) {
304307
headers.headers.api_version = api_version
305308
}
309+
if (branch) {
310+
headers.headers.branch = branch
311+
}
306312
const response = await http.post(`${this.urlPath}/publish`, data, headers)
307313
if (response.data) {
308314
return response.data

0 commit comments

Comments
 (0)