Skip to content

Commit a31f54b

Browse files
committed
Change the data models for the input of the lambdas
1 parent 30697da commit a31f54b

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

liveactivities/src/main/scala/com/gu/liveactivities/BroadcastLambda.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import scala.concurrent.Future
2121
import com.gu.liveactivities.models.LiveActivityInvalidStateException
2222

2323
// TODO - we should get the channel ID by looking up the match ID in the datastore
24-
case class BroadcastRequest(matchId: String, channelId: String, payload: String)
24+
case class BroadcastRequest(matchId: String, payload: String)
2525

2626
object BroadcastRequest {
2727
implicit val jf: Format[BroadcastRequest] = Json.format[BroadcastRequest]

liveactivities/src/main/scala/com/gu/liveactivities/ChannelManagerLambda.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import scala.concurrent.Future
2323
import com.gu.liveactivities.models.LiveActivityInvalidStateException
2424

2525
// TODO - we should get the channel ID by looking up the match ID in the datastore
26-
case class ChannelRequest(matchId: String, channelId: String, toCreate: Boolean)
26+
case class ChannelRequest(matchId: String, competitionId: Option[String], eventData: Option[LiveActivityData], toCreate: Boolean)
2727

2828
object ChannelRequest {
2929
implicit val jf: Format[ChannelRequest] = Json.format[ChannelRequest]
@@ -33,7 +33,7 @@ object ChannelManagerLambda extends RequestStreamHandler with Lambda with Loggin
3333

3434
val channelApiClient = new ChannelApiClient(authentication, config.bundleId, config.sendingToProdServer)
3535

36-
def processCreateChannelRequest(matchId: String, eventData: Option[LiveActivityData], competitionId: Option[String]): Future[String] = {
36+
def processCreateChannelRequest(matchId: String, competitionId: Option[String], eventData: Option[LiveActivityData]): Future[String] = {
3737
logger.info(s"Received request to create channel for match ID ${matchId}")
3838
return for {
3939
mappingExists <- repository.containMapping(matchId)
@@ -76,7 +76,7 @@ object ChannelManagerLambda extends RequestStreamHandler with Lambda with Loggin
7676
def processRequest(request: ChannelRequest, context: Context): Unit = {
7777
val channelFuture =
7878
if (request.toCreate)
79-
processCreateChannelRequest(request.matchId, None, None)
79+
processCreateChannelRequest(request.matchId, request.competitionId, request.eventData)
8080
else
8181
processCloseChannelRequest(request.matchId)
8282

liveactivities/src/main/scala/com/gu/liveactivities/LambdaLocalRun.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import java.nio.charset.StandardCharsets
66
object LambdaLocalRun extends App {
77

88
println("Start running ChannelManagerLambda locally")
9-
val createChannelJson = Json.toJson(ChannelRequest("match123", "channel123", toCreate = true)).toString()
9+
val createChannelJson = Json.toJson(ChannelRequest("match123", Some("competiton-001"), None, toCreate = true)).toString()
1010

1111
val createRequestStream = new java.io.ByteArrayInputStream(createChannelJson.getBytes(StandardCharsets.UTF_8))
1212

@@ -16,7 +16,7 @@ object LambdaLocalRun extends App {
1616

1717
val channelId = Json.parse(createResponseStream.toString()).as[String]
1818

19-
val closeRequest = ChannelRequest("match123", channelId, toCreate = false)
19+
val closeRequest = ChannelRequest("match123", None, None, toCreate = false)
2020

2121
val closeRequestStream = new java.io.ByteArrayInputStream(Json.toJson(closeRequest).toString().getBytes(StandardCharsets.UTF_8))
2222

0 commit comments

Comments
 (0)