-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into scala-steward-dependencies
- Loading branch information
Showing
17 changed files
with
18,733 additions
and
12,051 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package services | ||
|
||
import configuration.ApplicationConfig | ||
import io.circe.Encoder | ||
import io.circe.generic.semiauto.deriveEncoder | ||
import io.circe.syntax.EncoderOps | ||
import services.MessagingService.TransferCompleteEvent | ||
import software.amazon.awssdk.services.sns.SnsClient | ||
import software.amazon.awssdk.services.sns.model.PublishResponse | ||
import uk.gov.nationalarchives.aws.utils.sns.SNSClients.sns | ||
import uk.gov.nationalarchives.aws.utils.sns.SNSUtils | ||
|
||
import javax.inject.Inject | ||
import scala.concurrent.ExecutionContext | ||
|
||
class MessagingService @Inject() (val applicationConfig: ApplicationConfig)(implicit val ec: ExecutionContext) { | ||
val client: SnsClient = sns(applicationConfig.snsEndpoint) | ||
val utils: SNSUtils = SNSUtils(client) | ||
|
||
implicit val transferCompletedEventEncoder: Encoder[TransferCompleteEvent] = deriveEncoder[TransferCompleteEvent] | ||
def sendTransferCompleteNotification(transferCompletedEvent: TransferCompleteEvent): PublishResponse = { | ||
utils.publish(transferCompletedEvent.asJson.toString, applicationConfig.notificationSnsTopicArn) | ||
} | ||
} | ||
|
||
object MessagingService { | ||
case class TransferCompleteEvent( | ||
transferringBodyName: Option[String], | ||
consignmentReference: String, | ||
consignmentId: String, | ||
seriesName: Option[String], | ||
userId: String, | ||
userEmail: String | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.