api-client/helpers/requestParams.js

34 lines
860 B
JavaScript
Raw Normal View History

2020-05-02 17:34:16 +00:00
export function hasPathParams(params) {
return params
2021-05-18 09:27:29 +00:00
.filter((item) =>
Object.prototype.hasOwnProperty.call(item, "active")
? item.active === true
: true
)
.some(({ type }) => type === "path")
2020-05-02 17:34:16 +00:00
}
2020-06-11 14:25:40 +00:00
2020-05-02 17:34:16 +00:00
export function addPathParamsToVariables(params, variables) {
2020-06-11 14:25:40 +00:00
params
2021-05-18 09:27:29 +00:00
.filter((item) =>
Object.prototype.hasOwnProperty.call(item, "active")
? item.active === true
: true
)
2020-06-11 14:25:40 +00:00
.filter(({ key }) => !!key)
.filter(({ type }) => type === "path")
.forEach(({ key, value }) => (variables[key] = value))
return variables
2020-05-02 17:34:16 +00:00
}
export function getQueryParams(params) {
return params
2021-05-18 09:27:29 +00:00
.filter((item) =>
Object.prototype.hasOwnProperty.call(item, "active")
? item.active === true
: true
)
.filter(({ key }) => !!key)
2021-05-18 09:27:29 +00:00
.filter(({ type }) => type !== "path")
2020-06-11 14:25:40 +00:00
}