<commit_before>//
//  ForecastService.swift
//  Stormy
//
//  Created by <NAME> on 01.09.15.
//  Copyright (c) 2015 Closure One. All rights reserved.
//

import Foundation

struct ForecastService {
  let forecastAPIKey: String
  let forecastURL: NSURL?
  
  init (APIKey: String) {
    self.forecastAPIKey = APIKey
    forecastURL = NSURL(string: "https://api.forecast.io/\(forecastAPIKey)")
    
  }
  
  
  func getForecast(latitude: Double, longitude: Double, completion: (CurrentWeather? -> Void)) {
    
  }
  
  
}<commit_msg>Encapsulating the n/w request.<commit_after>//
//  ForecastService.swift
//  Stormy
//
//  Created by <NAME> on 01.09.15.
//  Copyright (c) 2015 Closure One. All rights reserved.
//

import Foundation

struct ForecastService {
  let forecastAPIKey: String
  let forecastURL: NSURL?
  
  init (APIKey: String) {
    self.forecastAPIKey = APIKey
    forecastURL = NSURL(string: "https://api.forecast.io/\(forecastAPIKey)")
    
  }
  
  
  func getForecast(latitude: Double, longitude: Double, completion: (CurrentWeather? -> Void)) {
    if let forecastURL = NSURL(string: "\(latitude), \(longitude)", relativeToURL: self.forecastURL) {
      
      let networkOperation = NetworkOperation(url: forecastURL)
      networkOperation.downloadJsonFromUrl {
        (let JSONDictionary) in
      }
      
    } else {
      println("Could not construct a valid URL")
    }
    
  }
  
  func currentWeatherFromJsonDictionary(jsonDictionary: [String: AnyObject]?) -> CurrentWeather? {
    
    if let currentWeatherDictionary = jsonDictionary?["currently"] as? [String: AnyObject] {
      return CurrentWeather(weatherDictionary: currentWeatherDictionary)
    } else
    {
      println("JSON dictionary returned nil for \"currently\" key.")
      return nil
      
    }
  }
  
  
}
{'fraction_non_alphanumeric': 0.11559734513274336, 'fraction_numerical': 0.011061946902654867, 'mean_word_length': 2.9411764705882355, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2755242', 'n_tokens_mistral': 593, 'n_tokens_neox': 566, 'n_words': 135}