Notes
Notes - notes.io |
Feedtype: [{}]} identify the edit in using this.editedendpoints Loop through endpoint for feed types and find endpoints with id
2 should be single promise and make api call
saveEndpoints = async () => {
try {
this.isSavingEndpoints = true;
let promises = [];
if (this.endpointsViewType === 'create') {
// api for create
promises = Object.keys(this.endpointsForFeedTypes).map(feedType => {
const endpointsList = this.endpointsForFeedTypes[feedType];
return endpointsList?.map(data => {
let endpointName = `${this.partnerInformationForm.name}-${data.endpointName}`;
let includeHeaders = Object.entries(data.includeHeaders)
.filter(([key, value]) => key !== undefined && key !== '')
.reduce((obj, [key, value]) => ({...obj, [key]: value}), {});
const modifiedData = {
...data,
endpointName: endpointName,
channel: {id: data.channel.id},
feedTypes: [feedType],
excludeHeaders: [data.excludeHeaders],
includeHeaders: includeHeaders,
partner: {
id: this.partnerId
}
};
return api.createChannelEndpoint(modifiedData);
});
});
promises = promises.flat();
}
if (this.endpointsViewType === 'edit') {
//api for put
promises = Object.keys(this.editedEndpoint).map(feedType => {
const endpointsList = this.editedEndpoint[feedType];
return endpointsList?.map(data => {
let modifiedData = data;
if (modifiedData['channel']) {
modifiedData['channel'] = {id: data.channel.id};
}
if (modifiedData['feedTypes']) {
modifiedData['feedTypes'] = [feedType];
}
if (modifiedData['excludeHeaders']) {
modifiedData['excludeHeaders'] = [data.excludeHeaders];
}
if ('endpointName' in modifiedData) {
let endpointName = `${this.partnerInformationForm.name}-${data.endpointName}`;
modifiedData.endpointName = endpointName;
}
if (modifiedData['includeHeaders']) {
modifiedData['includeHeaders'] = Object.entries(modifiedData['includeHeaders'])
.filter(([key, value]) => key !== undefined && key !== '')
.reduce((obj, [key, value]) => ({...obj, [key]: value}), {});
}
// const modifiedData = {
// ...data,
// channel: {id: data.channel.id},
// feedTypes: [feedType],
// excludeHeaders: [data.excludeHeaders]
// // not needed for update
// // partner: {
// // id: this.partnerId
// // }
// };
if (data.id) {
modifiedData['partner'] = {
id: this.partnerId
};
return api.updateChannelEndpoint(this.partnerId, modifiedData);
} else {
delete modifiedData.id;
modifiedData['partner'] = {
id: this.partnerId
};
modifiedData['feedTypes'] = [feedType];
if (!('idmsA3Enabled' in modifiedData)) modifiedData['idmsA3Enabled'] = false; // value is not there, setting default value
return api.createChannelEndpoint(modifiedData);
}
});
});
promises = promises.flat();
}
await Promise.all(promises);
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team