Last active
October 9, 2024 18:08
-
-
Save dacr/5de34df6e63f0ec797ead103603aa278 to your computer and use it in GitHub Desktop.
List a user github gists using sttp for client http and json4s for json processing. / published by https://github.com/dacr/code-examples-manager #a3d60a09-897a-450c-a1d5-e73e5bc4ded1/e9e6db6053be495efef21118bb1bc6a629a61b2a
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
// summary : List a user github gists using sttp for client http and json4s for json processing. | |
// keywords : scala, sttp, json4s, json, gists-api | |
// publish : gist | |
// authors : David Crosson | |
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2) | |
// id : a3d60a09-897a-450c-a1d5-e73e5bc4ded1 | |
// created-on : 2019-05-19T16:59:54Z | |
// managed-by : https://github.com/dacr/code-examples-manager | |
// run-with : scala-cli $file | |
//> using scala 2.12.20 | |
//> using dep com.softwaremill.sttp::core:1.5.17 | |
//> using dep com.softwaremill.sttp::json4s:1.5.17 | |
//> using dep org.json4s::json4s-native:3.6.5 | |
import com.softwaremill.sttp.quick._ | |
import com.softwaremill.sttp.json4s._ | |
case class Gist( | |
id:String, | |
description:String, | |
html_url:String, | |
) | |
implicit val serialization = org.json4s.native.Serialization | |
implicit val formats = org.json4s.DefaultFormats | |
val gists =sttp.get(uri"https://api.github.com/users/dacr/gists").response(asJson[Array[Gist]]).send() | |
gists.body.right.get.foreach{ println } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment