or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-6/

Product Price Updater

A utility that fetches product data from an API and applies pricing transformations during the JSON parsing process.

Capabilities

Price Markup Application

Apply a percentage-based markup to product prices as the JSON data streams in.

  • Given a product with price 100 and markup 10%, the transformed price is 110 @test
  • Given a product with price 50 and markup 20%, the transformed price is 60 @test
  • Given multiple products with prices [100, 200, 50] and markup 15%, the transformed prices are [115, 230, 57.5] @test

Currency Conversion

Convert prices from one currency to another during JSON parsing.

  • Given a product price of 100 USD with conversion rate 1.2 to EUR, the converted price is 120 @test
  • Given multiple products with USD prices and a conversion rate of 0.85 to GBP, all prices are converted correctly @test

Implementation

@generates

API

/**
 * Fetches product data from a URL and applies a markup percentage to all prices.
 * Returns a promise that resolves with the complete transformed product list.
 *
 * @param {string} url - The URL to fetch product data from
 * @param {number} markupPercent - The markup percentage to apply (e.g., 10 for 10%)
 * @returns {Promise<Array>} Promise resolving to array of products with transformed prices
 */
function applyMarkup(url, markupPercent) {
  // IMPLEMENTATION HERE
}

/**
 * Fetches product data from a URL and converts all prices using the given conversion rate.
 * Returns a promise that resolves with the complete transformed product list.
 *
 * @param {string} url - The URL to fetch product data from
 * @param {number} conversionRate - The rate to multiply prices by
 * @returns {Promise<Array>} Promise resolving to array of products with converted prices
 */
function convertCurrency(url, conversionRate) {
  // IMPLEMENTATION HERE
}

module.exports = {
  applyMarkup,
  convertCurrency,
};

Dependencies { .dependencies }

oboe { .dependency }

Provides streaming JSON parsing with transformation capabilities.

@satisfied-by