in handlers/holiday-stop-api/src/main/scala/com/gu/holiday_stops/Handler.scala [174:220]
private def createSteps(
httpMethod: String,
path: List[String],
getAccessToken: () => Either[ApiFailure, AccessToken],
getSubscription: (AccessToken, SubscriptionName) => Either[ApiFailure, Subscription],
getAccount: (AccessToken, String) => Either[ApiFailure, ZuoraAccount],
idGenerator: => String,
fulfilmentDatesFetcher: FulfilmentDatesFetcher,
now: () => ZonedDateTime,
) = {
path match {
case "potential" :: _ :: Nil =>
httpMethod match {
case "GET" => stepsForPotentialHolidayStop(getAccessToken, getSubscription, getAccount) _
case _ => unsupported _
}
case "hsr" :: Nil =>
httpMethod match {
case "POST" => stepsToCreate(getAccessToken, getSubscription, getAccount) _
case _ => unsupported _
}
case "bulk-hsr" :: Nil =>
httpMethod match {
case "POST" => stepsToBulkCreate(getAccessToken, getSubscription, getAccount) _
case _ => unsupported _
}
case "hsr" :: _ :: Nil =>
httpMethod match {
case "GET" => stepsToListExisting(getAccessToken, getSubscription, getAccount, fulfilmentDatesFetcher) _
case _ => unsupported _
}
case "hsr" :: _ :: "cancel" :: Nil =>
httpMethod match {
case "POST" => stepsToCancel(idGenerator) _
case "GET" => stepsToGetCancellationDetails(idGenerator) _
case _ => unsupported _
}
case "hsr" :: _ :: _ :: Nil =>
httpMethod match {
case "PATCH" => stepsToAmend(getAccessToken, getSubscription, getAccount) _
case "DELETE" => stepsToWithdraw(now) _
case _ => unsupported _
}
case _ =>
notfound _
}
}