Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Commit

Permalink
Use latest tapir
Browse files Browse the repository at this point in the history
Use latest tapir and case class for request form data as it now does not
give warnings anymore after
softwaremill/tapir#728 has been merged and
released.
  • Loading branch information
2m committed Aug 26, 2020
1 parent ae985fc commit 2e1e05d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name := "auto-gate"
description := "Uses Twilio to make a call to garage opening number"

scalaVersion := "2.13.3"
val Tapir = "0.16.15"
val Tapir = "0.16.16"
val Circe = "0.13.0"

libraryDependencies ++= Seq(
Expand Down
8 changes: 6 additions & 2 deletions src/main/scala/AutoGate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,22 @@ import sttp.client.httpclient.HttpClientSyncBackend
import sttp.model.Uri
import sttp.tapir._
import sttp.tapir.client.sttp._
import sttp.tapir.generic.Configuration
import sttp.tapir.model._

import lt.dvim.autogate.CirisDecoders._

object AutoGate {
case class Request(to: String, from: String, url: String)
implicit val requestConfiguration: Configuration = Configuration(_.capitalize)

val makeCall =
endpoint.post
.in(auth.basic[UsernamePassword])
.in("2010-04-01" / "Accounts")
.in(path[String]("accountId"))
.in("Calls.json")
.in(formBody[Map[String, String]])
.in(formBody[Request])
.out(stringBody)

case class Config(
Expand Down Expand Up @@ -64,7 +68,7 @@ object AutoGate {

def openGate()(implicit config: Config) = {
val auth = UsernamePassword(config.twilioSid, Some(config.twilioToken.value))
val form = Map("To" -> config.to, "From" -> config.from, "Url" -> config.instructions)
val form = Request(config.to, config.from, config.instructions)
val response =
makeCall
.toSttpRequest(config.twilioUri)
Expand Down

0 comments on commit 2e1e05d

Please sign in to comment.