mws-advanced icon indicating copy to clipboard operation
mws-advanced copied to clipboard

Discussion: Dynamic feed generation

Open ericblade opened this issue 6 years ago • 0 comments

With Feed support now functioning at the most basic level, this leaves a lot of possibilities for dynamic feed generation.

What I'm toying with right now, is creating a class that matches a feed type -- such as ListingLoader, that contains class fields for each of the parameters in the feed, and has a static method for getting the header for the feed. (this is for a flat-file feed, by the way, I haven't even begun to investigate XML feeds)

So, what you could do is something like

    let newListings = [];
    const x = new ListingLoader();
    ... code to load data into a ListingLoader, such as from a database, or from user input ...
    const feedContent = `${x.getFeedHeader()}${x.getFeedData()}`;
    mws.callEndpoint('SubmitFeed', { ...params, feedContent });

it seems easy and simple, but I suspect there may be better ways of doing it. This is just my first gut thought.

Perhaps the class should store an array of objects (or of other classes) that stores the required data, and has a method to retrieve the raw data objects, or the feeddata for submission. Or even has a method to actually submit the feed once it's been loaded full of data. Sounds like a nice improvement to what I'm toying with right now.

ericblade avatar Apr 27 '18 20:04 ericblade