diff --git a/lib/discourse_chatbot/functions/stock_data_function.rb b/lib/discourse_chatbot/functions/stock_data_function.rb index cb204752..46335594 100644 --- a/lib/discourse_chatbot/functions/stock_data_function.rb +++ b/lib/discourse_chatbot/functions/stock_data_function.rb @@ -15,15 +15,14 @@ def name def description <<~EOS - An API for MarketStack stock data - - You need to call it using the stock ticker.#{' '} + An API for MarketStack stock data. You need to call it using the stock ticker. You can optionally also provide a specific date. EOS end def parameters [ { name: 'ticker', type: String, description: "ticker for share or stock query" }, + { name: 'date', type: String, description: "date for data in format YYYY-MM-DD" } ] end @@ -46,8 +45,7 @@ def process(args) api_response = JSON.parse(json) ticker = api_response['data'][0]['symbol'] - - uri = URI("http://api.marketstack.com/v1/eod/latest") + uri = args[parameters[1][:name]].blank? ? URI("http://api.marketstack.com/v1/eod/latest") : URI("http://api.marketstack.com/v1/eod/#{args[parameters[1][:name]]}") params = { access_key: "#{SiteSetting.chatbot_marketstack_key}", diff --git a/plugin.rb b/plugin.rb index d2323f93..12e4229f 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # name: discourse-chatbot # about: a plugin that allows you to have a conversation with a configurable chatbot in Discourse Chat, Topics and Private Messages -# version: 0.28 +# version: 0.29 # authors: merefield # url: https://github.com/merefield/discourse-chatbot