<commit_before>// TODO Refactor this all
const WT_KEY = '<KEY>';
const IP_URL = 'http://ip-api.com/json';
const WT_URL = 'http://api.openweathermap.org/data/2.5/weather';
const CARDINAL = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'];

function makeDataCallUrl(locat) {
  switch (locat.type) {
    case 'coords':
      return `${WT_URL}?lat=${locat.lati}&lon=${locat.long}&appid=${WT_KEY}`;
    case 'ip':
      return `${WT_URL}?zip=${locat.zip},${locat.countryCode}&appid=${WT_KEY}`;
    default: throw new Error(`Wrong type of location data: ${locat}`);
  }
}

function getWeatherData(location) {
  return new Promise((resolve, reject) => {
    $.getJSON(makeDataCallUrl(location), data => resolve(data))
        .fail((j, errTxt) => reject(errTxt));
  });
}

function getIpLocation() {
  return new Promise((resolve, reject) => {
    $.getJSON(IP_URL, location => {
      if (!location.message) resolve(Object.assign({ type: 'ip' }, location));
      else reject(Object.assign({ type: 'error' }, location));
    }).fail((j, message) => { reject({ type: 'error', message }); });
  });
}

function getNavCoords() {
  return new Promise(resolve => {
    navigator.geolocation.getCurrentPosition(({ coords: c }) => {
      resolve({ type: 'coords', lati: c.latitude, long: c.longitude });
    }, () => {
      resolve({ type: 'error', message: 'User canceled operation.' });
    });
  });
}

function getWindDirection(degree) {
  return CARDINAL[~~((degree + 22.5) / 45)] || CARDINAL[0];<commit_msg>Started new class<commit_after>// TODO Refactor this all
const WT_KEY = '20e6b4bb024441f12fe889046e1acbd6';
const IP_URL = 'http://ip-api.com/json';
const WT_URL = 'http://api.openweathermap.org/data/2.5/weather';
const CARDINAL = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'];

class OpenWeather {

  constructor(apiKey) {
    this.key = apiKey;
    this.location = {};
  }

  static get weatherUrl() {
    return 'http://api.openweathermap.org/data/2.5/weather';
  }

  static get ipUrl() {
    return 'http://ip-api.com/json';
  }

  getRequestWithCoords({ latitude, longitude }) {
    return `${this.constructor.weatherUrl}?lat=${latitude}&lon=${longitude}` +
        `&appid=${this.key}`;
  }

  getRequestWithIP({ zip, countryCode }) {
    return `${this.constructor.weatherUrl}?zip=${zip},${countryCode}` +
        `&appid=${this.key}`;
  }

}

function getWeatherData(location) {
  return new Promise((resolve, reject) => {
    $.getJSON(makeDataCallUrl(location), data => resolve(data))
        .fail((j, errTxt) => reject(errTxt));
  });
}

function getIpLocation() {
  return new Promise((resolve, reject) => {
    $.getJSON(IP_URL, location => {
      if (!location.message) resolve(Object.assign({ type: 'ip' }, location));
      else reject(Object.assign({ type: 'error' }, location));
    }).fail((j, message) => { reject({ type: 'error', message }); });
  });
}

function getNavCoords() {
  return new Promise(resolve => {
    navigator.geolocation.getCurrentPosition(({ coords: c }) => {
      resolve({ type: 'coords', lati: c.latitude, long: c.longitude });
    }, () => {
      resolve({ type: 'error', message: 'User canceled operation.' });
    });
  });
}

function getWindDirection(degree) {
  return CARDINAL[~~((degree + 22.5) / 45)] || CARDINAL[0];
{'fraction_non_alphanumeric': 0.2047677261613692, 'fraction_numerical': 0.011613691931540342, 'mean_word_length': 3.9070464767616193, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5057577', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1127, 'n_words': 230}