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

Commit

Permalink
Merge pull request #1 from 2m/fix/latest-tapir-2m
Browse files Browse the repository at this point in the history
Use latest tapir
  • Loading branch information
2m authored Aug 26, 2020
2 parents ae985fc + 2e1e05d commit 751e973
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 751e973

Please sign in to comment.