@@ -3,14 +3,8 @@ package no.nav.hjelpemidler.soknad.db.rapportering.epost
33import io.github.oshai.kotlinlogging.KotlinLogging
44import io.ktor.client.HttpClient
55import io.ktor.client.engine.apache.Apache
6- import io.ktor.client.plugins.defaultRequest
7- import io.ktor.client.plugins.logging.LogLevel
8- import io.ktor.client.plugins.logging.Logging
9- import io.ktor.client.request.accept
106import io.ktor.client.request.post
117import io.ktor.client.request.setBody
12- import io.ktor.http.ContentType
13- import io.ktor.http.contentType
148import kotlinx.coroutines.Dispatchers
159import kotlinx.coroutines.withContext
1610import no.nav.hjelpemidler.http.createHttpClient
@@ -23,32 +17,22 @@ class GraphClient(
2317 private val openIDClient : OpenIDClient ,
2418 private val httpClient : HttpClient = createHttpClient(Apache .create()) {
2519 expectSuccess = true
26-
27- // TODO fjern logging
28- install(Logging ) {
29- level = LogLevel .BODY
30- }
31-
32- defaultRequest {
33- accept(ContentType .Application .Json )
34- contentType(ContentType .Application .Json )
35- }
3620 },
3721 private val baseUrl : String = " https://graph.microsoft.com/v1.0" ,
3822 private val scope : String = " https://graph.microsoft.com/.default" ,
3923) {
4024
41- suspend fun sendEpost (request : SendMailRequest , avsender : String ) {
25+ suspend fun sendEpost (epostRequest : SendMailRequest , avsender : String ) {
4226 try {
4327 withContext(Dispatchers .IO ) {
4428 val tokenSet = openIDClient.grant(scope)
4529 httpClient.post(" $baseUrl /users/$avsender /sendMail" ) {
4630 bearerAuth(tokenSet)
47- setBody(request )
31+ setBody(epostRequest )
4832 }
4933 }
5034 } catch (t: Throwable ) {
51- log.error(t) { " Sending av epost feilet for $request , avsender=$avsender " }
35+ log.error(t) { " Sending av epost feilet for $epostRequest , avsender=$avsender " }
5236 throw t
5337 }
5438 }
0 commit comments