Sha256: 457168fead04862ded82b346c8d914e588615f89ca748a735203f9a1d039d946

Contents?: true

Size: 785 Bytes

Versions: 3

Compression:

Stored size: 785 Bytes

Contents

class SlackSmartBot
  def get_countries_candelarific()
    http = NiceHttp.new("#{config[:public_holidays][:host]}/api/v2")
    if File.exist?("#{config.path}/vacations/countries_candelarific.json")
      @countries_candelarific = JSON.parse(File.read("#{config.path}/vacations/countries_candelarific.json"))
    else
      response = http.get "/countries?api_key=#{config[:public_holidays][:api_key]}"
      countries_candelarific = response.data.json(:countries)
      if countries_candelarific.is_a?(Array)
        File.write("#{config.path}/vacations/countries_candelarific.json", countries_candelarific.to_json)
        @countries_candelarific = JSON.parse(countries_candelarific.to_json)
      else
        @countries_candelarific = []
      end
    end
    http.close
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slack-smart-bot-1.15.25 lib/slack/smart-bot/utils/get_countries_candelarific.rb
slack-smart-bot-1.15.1 lib/slack/smart-bot/utils/get_countries_candelarific.rb
slack-smart-bot-1.15.0 lib/slack/smart-bot/utils/get_countries_candelarific.rb