Created
January 20, 2014 02:07
-
-
Save levinotik/8513759 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.film42.forecastioapi | |
import com.eclipsesource.json.JsonObject | |
import java.net.URL | |
import java.util.{Date, Scanner} | |
import spray.json._ | |
import model.ForecastJsonProtocol._ | |
import model._ | |
import scala.util.{Success, Try} | |
case class ForecastIO(apiKey: String, units: String) { | |
def forecast(apiKey: String, lat: String, lon: String, date: Date = new Date()): Try[Forecast] = { | |
Success( new Forecast(apiKey, lat, lon, units) ) | |
} | |
def forecast(lat: String, lon: String, date: Date): Try[Forecast] = { | |
forecast(apiKey, lat, lon, date) | |
} | |
def forecast(lat: String, lon: String): Try[Forecast] = { | |
forecast(apiKey, lat, lon) | |
} | |
} | |
//here someone creates one.. | |
val client1 = ForecastIO("mykey", "us") | |
client1.forecast("352155", "4178247") | |
//now wants to change "us" to "is" | |
val client2 = client1.copy(units = "is") | |
client2.forecast("352155", "4178247") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment