Skip to content

Instantly share code, notes, and snippets.

@levinotik
Created January 20, 2014 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save levinotik/8513759 to your computer and use it in GitHub Desktop.
Save levinotik/8513759 to your computer and use it in GitHub Desktop.
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