mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
otf: add patch api endpoint for person and thirdparty
This commit is contained in:
parent
a8df0070e8
commit
bfd95bff39
@ -28,7 +28,26 @@ const postPerson = (body) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PATCH an existing person
|
||||||
|
*/
|
||||||
|
const patchPerson = (id, body) => {
|
||||||
|
const url = `/api/1.0/person/person/${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 {
|
export {
|
||||||
getPerson,
|
getPerson,
|
||||||
postPerson
|
postPerson,
|
||||||
|
patchPerson
|
||||||
};
|
};
|
||||||
|
@ -163,11 +163,12 @@ export default {
|
|||||||
resolve();
|
resolve();
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
postData() {
|
patchData() {
|
||||||
postPerson(this.person)
|
console.log('id', this.id, 'and body', this.person);
|
||||||
|
patchPerson(this.id, this.person)
|
||||||
.then(person => new Promise((resolve, reject) => {
|
.then(person => new Promise((resolve, reject) => {
|
||||||
this.person = person;
|
this.person = person;
|
||||||
console.log('post person', this.person);
|
console.log('patch person', this.person);
|
||||||
resolve();
|
resolve();
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ const getThirdparty = (id) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* POST a new person
|
* POST a new thirdparty
|
||||||
*/
|
*/
|
||||||
const postThirdparty = (body) => {
|
const postThirdparty = (body) => {
|
||||||
const url = `/api/1.0/thirdparty/thirdparty.json`;
|
const url = `/api/1.0/thirdparty/thirdparty.json`;
|
||||||
@ -30,7 +30,26 @@ const postThirdparty = (body) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 {
|
export {
|
||||||
getThirdparty,
|
getThirdparty,
|
||||||
postThirdparty
|
postThirdparty,
|
||||||
|
patchThirdparty
|
||||||
};
|
};
|
@ -55,7 +55,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import ThirdPartyRenderBox from '../Entity/ThirdPartyRenderBox.vue';
|
import ThirdPartyRenderBox from '../Entity/ThirdPartyRenderBox.vue';
|
||||||
import AddAddress from 'ChillMainAssets/vuejs/Address/components/AddAddress';
|
import AddAddress from 'ChillMainAssets/vuejs/Address/components/AddAddress';
|
||||||
import { getThirdparty, postThirdparty } from '../../_api/OnTheFly';
|
import { getThirdparty, patchThirdparty } from '../../_api/OnTheFly';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "OnTheFlyThirdParty",
|
name: "OnTheFlyThirdParty",
|
||||||
@ -98,10 +98,10 @@ export default {
|
|||||||
resolve();
|
resolve();
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
postData() {
|
patchData() {
|
||||||
postThirdparty(this.thirdparty).then(thirdparty => new Promise((resolve, reject) => {
|
patchThirdparty(this.thirdparty).then(thirdparty => new Promise((resolve, reject) => {
|
||||||
this.thirdparty = thirdparty;
|
this.thirdparty = thirdparty;
|
||||||
console.log('post thirdparty', thirdparty);
|
console.log('patch thirdparty', thirdparty);
|
||||||
resolve();
|
resolve();
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user