pcp-server-nodejs-sdk
Version:
[](https://sonarcloud.io/summary/new_code?id=PAYONE-GmbH_PCP-server-nodeJS-SDK) [ {
super(config);
}
async createCommerceCaseRequest(merchantId, payload) {
if (!merchantId) {
throw new TypeError(MERCHANT_ID_REQUIRED_ERROR);
}
const url = new URL(`/v1/${merchantId}/commerce-cases`, this.getConfig().getHost());
const requestInit = {
method: 'POST',
headers: new Headers({
'Content-Type': 'application/json; charset=utf-8',
}),
body: JSON.stringify(payload),
};
return this.makeApiCall(url.toString(), requestInit);
}
async getCommerceCaseRequest(merchantId, commerceCaseId) {
if (!merchantId) {
throw new TypeError(MERCHANT_ID_REQUIRED_ERROR);
}
if (!commerceCaseId) {
throw new TypeError(COMMERCE_CASE_ID_REQUIRED_ERROR);
}
const url = new URL(`/v1/${merchantId}/commerce-cases/${commerceCaseId}`, this.getConfig().getHost());
const requestInit = {
method: 'GET',
headers: new Headers(),
};
return this.makeApiCall(url.toString(), requestInit);
}
async getCommerceCasesRequest(merchantId, queryParams) {
if (!merchantId) {
throw new TypeError(MERCHANT_ID_REQUIRED_ERROR);
}
const url = new URL(`/v1/${merchantId}/commerce-cases`, this.getConfig().getHost());
if (queryParams) {
const params = new URLSearchParams(queryParams.toQueryMap());
url.search = params.toString();
}
const requestInit = {
method: 'GET',
headers: new Headers(),
};
return this.makeApiCall(url.toString(), requestInit);
}
async updateCommerceCaseRequest(merchantId, commerceCaseId, payload) {
if (!merchantId) {
throw new TypeError(MERCHANT_ID_REQUIRED_ERROR);
}
if (!commerceCaseId) {
throw new TypeError(COMMERCE_CASE_ID_REQUIRED_ERROR);
}
const url = new URL(`/v1/${merchantId}/commerce-cases/${commerceCaseId}`, this.getConfig().getHost());
const requestInit = {
method: 'PATCH',
headers: new Headers({
'Content-Type': 'application/json',
}),
body: JSON.stringify(payload),
};
await this.makeApiCall(url.toString(), requestInit, BaseApiClient.parseVoid);
}
}
//# sourceMappingURL=CommerceCaseApiClient.js.map