Module:PriceServer: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
local Prices = {}
local PriceServer = {}


local function fetchPrices()
local function fetchPrices()
local http = require('requests')
local apiUrl = "http://priceserver.theblockheads.net/get_prices.php"
local apiUrl = "http://priceserver.theblockheads.net/get_prices.php"
local response, code = http.get(apiUrl)
local response, code = http.get(apiUrl)
Line 15: Line 14:
end
end


function Prices.getPrice(id)
function PriceServer.getPrice(id)
     local pricesData, err = fetchPrices()
     local pricesData, err = fetchPrices()


Line 33: Line 32:
end
end


return Prices
function PriceServer.getPriceGraphImage(id)
        return string.format('<img src="http://priceserver.theblockheads.net/get_price_graph_data.php?item_id=%s" alt="Price graph for item %s" />', tostring(id), tostring(id))
end
 
return PriceServer