|
|
@@ -2,6 +2,7 @@ package balldontlie
|
|
|
|
|
|
import upickle.default._
|
|
|
import game._
|
|
|
+import os.Path
|
|
|
|
|
|
case class ResponseMetadata(
|
|
|
total_pages: Int,
|
|
|
@@ -28,6 +29,12 @@ object Utils {
|
|
|
val json = ujson.read(r.text())
|
|
|
upickle.default.read[T](json)
|
|
|
}
|
|
|
+
|
|
|
+ def writeToFile[T: Writer](data: T, file: Path): Unit = {
|
|
|
+ val string = upickle.default.write[T](data, indent = 4)
|
|
|
+
|
|
|
+ os.write.over(file, string)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
case class EndpointResponse[T](data: T, meta: ResponseMetadata) {
|