otf: add patch api endpoint for person and thirdparty

This commit is contained in:
2021-09-29 14:56:25 +02:00
parent a8df0070e8
commit bfd95bff39
4 changed files with 56 additions and 17 deletions

View File

@@ -13,7 +13,7 @@ const getThirdparty = (id) => {
};
/*
* POST a new person
* POST a new thirdparty
*/
const postThirdparty = (body) => {
const url = `/api/1.0/thirdparty/thirdparty.json`;
@@ -29,8 +29,27 @@ const postThirdparty = (body) => {
throw Error('Error with request resource response');
});
};
export {
getThirdparty,
postThirdparty
};
/*
* PATCH an existing thirdparty
*/
const patchThirdparty = (id, body) => {
const url = `/api/1.0/thirdparty/thirdparty/${id}.json`;
return fetch(url, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
body: JSON.stringify(body)
})
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
};
export {
getThirdparty,
postThirdparty,
patchThirdparty
};

View File

@@ -55,7 +55,7 @@
<script>
import ThirdPartyRenderBox from '../Entity/ThirdPartyRenderBox.vue';
import AddAddress from 'ChillMainAssets/vuejs/Address/components/AddAddress';
import { getThirdparty, postThirdparty } from '../../_api/OnTheFly';
import { getThirdparty, patchThirdparty } from '../../_api/OnTheFly';
export default {
name: "OnTheFlyThirdParty",
@@ -98,10 +98,10 @@ export default {
resolve();
}));
},
postData() {
postThirdparty(this.thirdparty).then(thirdparty => new Promise((resolve, reject) => {
patchData() {
patchThirdparty(this.thirdparty).then(thirdparty => new Promise((resolve, reject) => {
this.thirdparty = thirdparty;
console.log('post thirdparty', thirdparty);
console.log('patch thirdparty', thirdparty);
resolve();
}))
},