in handlers/product-move-api/src/main/scala/com/gu/productmove/endpoint/move/ProductMoveEndpoint.scala [154:223]
private[productmove] def run(
switchType: SwitchType,
subscriptionName: SubscriptionName,
postData: ExpectedInput,
maybeIdentityId: Option[IdentityId],
): Task[Right[Nothing, OutputBody]] = {
val stage = GuStageLive.get
val getCatalogueLive = new GetCatalogueLive(
AwsS3Live(AwsS3Live.impl(AwsCredentialsLive.impl)),
stage,
)
val creds = AwsCredentialsLive.impl
(for {
sttpClient <- SttpClientLive.impl
subscriptionUpdate <- ZIO
.service[SubscriptionUpdate] // TODO convert the rest of the custom layers into normal params
zuoraGet <- ZIO.service[ZuoraGet]
getInvoiceItems <- ZIO.service[GetInvoiceItems]
getInvoice <- ZIO.service[GetInvoice]
createPayment <- ZIO.service[CreatePayment]
invoiceItemAdjustment <- ZIO.service[InvoiceItemAdjustment]
getSubscription <- ZIO.service[GetSubscription]
getAccount <- ZIO.service[GetAccount]
sqs <- ZIO.service[SQS]
dynamo <- ZIO.service[Dynamo]
productMoveEndpoint = new ProductMoveEndpointSteps(
new RecurringContributionToSupporterPlusImpl(
new GetRatePlans(
stage,
getCatalogueLive,
),
subscriptionUpdate,
TermRenewalLive(zuoraGet),
getInvoiceItems,
getInvoice,
createPayment,
invoiceItemAdjustment,
sqs,
dynamo,
),
new ToRecurringContributionImpl(
new SubscriptionUpdateLive(
new ZuoraGetLive(ZuoraClientLive.impl(SecretsLive.impl(creds, stage), sttpClient).get),
),
SQSLive.impl(stage, creds).get,
stage,
),
getSubscription,
getAccount,
)
result <- productMoveEndpoint.runWithLayers(switchType, subscriptionName, postData, maybeIdentityId)
} yield Right(result))
.provide(
GetSubscriptionLive.layer,
AwsCredentialsLive.layer,
SttpClientLive.layer,
ZuoraClientLive.layer,
ZuoraGetLive.layer,
SubscriptionUpdateLive.layer,
SQSLive.layer,
GetAccountLive.layer,
InvoiceItemAdjustmentLive.layer,
GuStageLive.layer,
DynamoLive.layer,
GetInvoiceItemsLive.layer,
GetInvoiceLive.layer,
CreatePaymentLive.layer,
SecretsLive.layer,
)
}