Skip to content

Commit

Permalink
F - Legger til REST api for henting av landkoder fra TEN
Browse files Browse the repository at this point in the history
  • Loading branch information
dskarpas committed Aug 15, 2024
1 parent f6da78e commit 250eb67
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
24 changes: 24 additions & 0 deletions src/main/kotlin/no/nav/eessi/pensjon/api/geo/KodeverkService.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package no.nav.eessi.pensjon.api.geo

import org.springframework.http.*
import org.springframework.stereotype.Service
import org.springframework.web.client.RestTemplate

@Service
class KodeverkService(private val euxNavIdentRestTemplate: RestTemplate) {

fun getLandkoderAkseptertAvRina(format: String? = null): String? {
val url = "/cpi/landkoder/rina"

val response: ResponseEntity<String> = euxNavIdentRestTemplate.exchange(
if (format != null) "$url?format=$format" else url,
HttpMethod.GET,
HttpEntity<String>(HttpHeaders().apply {
contentType = MediaType.APPLICATION_JSON
}),
String::class.java
)

return response.body
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package no.nav.eessi.pensjon.api.geo

import com.google.api.client.json.Json
import no.nav.eessi.pensjon.kodeverk.KodeverkClient
import no.nav.security.token.support.core.api.Unprotected
import org.slf4j.LoggerFactory
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.bind.annotation.*


@Unprotected
@RestController
@RequestMapping("/landkoder")
class LandkodeController(private val kodeverkClient: KodeverkClient) {
class LandkodeController(private val kodeverkClient: KodeverkClient, private val kodeverkService: KodeverkService) {

private val logger = LoggerFactory.getLogger(LandkodeController::class.java)

Expand All @@ -38,5 +36,11 @@ class LandkodeController(private val kodeverkClient: KodeverkClient) {
logger.info("Henter Alpha2 landkode for Alpha3")
return kodeverkClient.finnLandkode(land3)
}

@GetMapping("/rina")
fun landkoderAkseptertAvRina(
@RequestParam(required = false) format: String?): String? {
return kodeverkService.getLandkoderAkseptertAvRina(format)
}
}

0 comments on commit 250eb67

Please sign in to comment.