mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
* init map view * switching off 3d buildings when sattelite view is on * rename menu items * upgrading dependencies, adding provider to popups * adding screenshot for map view * fixing readme * next release version
63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
/*
|
|
* Copyright (c) 2026 by Christian Kellner.
|
|
* Licensed under Apache-2.0 with Commons Clause and Attribution/Naming Clause
|
|
*/
|
|
|
|
import { markdown2Html } from '../../services/markdown.js';
|
|
|
|
const mapListing = (listing) => ({
|
|
address: listing.address,
|
|
description: listing.description,
|
|
id: listing.id,
|
|
imageUrl: listing.image,
|
|
price: listing.price,
|
|
size: listing.size,
|
|
title: listing.title,
|
|
url: listing.link,
|
|
});
|
|
|
|
export const send = ({ serviceName, newListings, notificationConfig, jobKey }) => {
|
|
const { authToken, endpointUrl } = notificationConfig.find((a) => a.id === config.id).fields;
|
|
|
|
const listings = newListings.map(mapListing);
|
|
const body = {
|
|
jobId: jobKey,
|
|
timestamp: new Date().toISOString(),
|
|
provider: serviceName,
|
|
listings,
|
|
};
|
|
|
|
const headers = {
|
|
'Content-Type': 'application/json',
|
|
};
|
|
if (authToken != null) {
|
|
headers['Authorization'] = `Bearer ${authToken}`;
|
|
}
|
|
|
|
return fetch(endpointUrl, {
|
|
method: 'POST',
|
|
headers: headers,
|
|
body: JSON.stringify(body),
|
|
});
|
|
};
|
|
|
|
export const config = {
|
|
id: 'http',
|
|
name: 'HTTP',
|
|
readme: markdown2Html('lib/notification/adapter/http.md'),
|
|
description: 'Fredy will send a generic HTTP POST request.',
|
|
fields: {
|
|
endpointUrl: {
|
|
description: "Your application's endpoint URL.",
|
|
label: 'Endpoint URL',
|
|
type: 'text',
|
|
},
|
|
authToken: {
|
|
description: "Your application's auth token, if required by your endpoint.",
|
|
label: 'Auth token (optional)',
|
|
optional: true,
|
|
type: 'text',
|
|
},
|
|
},
|
|
};
|