'use strict';

const YQL = require('yql');
const _ = require('lodash');

module.exports = (opts, callback) => {
	opts = opts || [];

	let query;

	if (_.isEmpty(opts)) {
		query = new YQL('select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="Dhaka, Bangladesh")');
	} else {
		query = new YQL('select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="' + opts[0] + ', ' + opts[1] + '")');
	}

	query.exec((err, response) => {
		if (err) {
			return callback(err);
		}

		callback(null, response);
	});
};

'use strict';

const axios = require('axios');
const API_URL = 'https://micro-weather.now.sh';

module.exports = (opts) => {
  let city = opts[0] || 'Dhaka';
  let country = opts[1] || 'Bangladesh';

  return axios.get(`${API_URL}?city=${city}&country=${country}`);
};

Refactor main weather module to use API
Refactor main weather module to use API

Signed-off-by: Riyadh Al Nur <d7e60315016355bdcd32d48dde148183e3d8bb86@verticalaxisbd.com>
