def main()

in handlers/product-move-api/src/main/scala/com/gu/productmove/endpoint/updateamount/UpdateSupporterPlusAmountEndpoint.scala [45:106]


  def main(args: Array[String]): Unit = LambdaEndpoint.runTest(
    run(
      "A-S00609043",
      ExpectedInput(BigDecimal(20)),
    ),
  )

  val server: sttp.tapir.server.ServerEndpoint.Full[
    Unit,
    Unit,
    (String, ExpectedInput),
    Unit,
    OutputBody,
    Any,
    Task,
  ] = {
    val subscriptionNameCapture: EndpointInput.PathCapture[String] = {
      EndpointInput.PathCapture[String](
        Some("subscriptionName"),
        implicitly,
        EndpointIO.Info.empty.copy(
          description = Some("Name of supporter plus subscription to have its contribution amount updated."),
          examples = List(Example("A-S000001", None, None)),
        ), // A-S000001
      )
    }

    val endpointDescription: PublicEndpoint[
      (String, ExpectedInput),
      Unit,
      OutputBody,
      Any,
    ] =
      endpoint.post
        .in("update-supporter-plus-amount")
        .in(subscriptionNameCapture)
        .in(
          jsonBody[ExpectedInput].copy(info =
            EndpointIO.Info
              .empty[ExpectedInput]
              .copy(description = Some("Definition of the updated total amount of regular payment")),
          ),
        )
        .out(
          oneOf(
            oneOfVariant(
              sttp.model.StatusCode.Ok,
              jsonBody[Success].copy(info = EndpointIO.Info.empty.copy(description = Some("Update Success."))),
            ),
            oneOfVariant(
              sttp.model.StatusCode.InternalServerError,
              jsonBody[InternalServerError]
                .copy(info = EndpointIO.Info.empty.copy(description = Some("InternalServerError."))),
            ),
          ),
        )
        .summary("Updates the price of the supporter plus subscription.")
        .description(
          """Updates the charge amount on the contribution rate plan charge of a supporter plus subscription.""".stripMargin,
        )
    endpointDescription.serverLogic[Task](run)
  }