fun getListOrderStatus(orderStatusAgentRequestDto: OrderStatusAgentRequestDto): ResponseEntity<List<OrderStatusAgentResponseDto>>? {
val accessTokenAgent = agentAuthService.getAccessTokenAgent()
val requestUri = UrlBuilder(mposApiEnpoint.orderStatusListRead)
.addParam(HttpUtils.PARAM_ACCESS_TOKEN, accessTokenAgent!!.accessToken)
.addParam("page_size", "${orderStatusAgentRequestDto.pageSize}")
.addParam("order_codes", if (orderStatusAgentRequestDto.orderCodes != null) orderStatusAgentRequestDto.orderCodes.joinToString(separator = ",") else "")
.addParam("modified_time", "${orderStatusAgentRequestDto.modifiedTime}")
.addParam("service_id", "${orderStatusAgentRequestDto.serviceId}")
.toString()
val restTemplate = RestTemplate()
return restTemplate.exchange(requestUri, HttpMethod.GET, null, object : ParameterizedTypeReference<List<OrderStatusAgentResponseDto>>() {})
}
....
....
val status = orderMappingApi.getListOrderStatus(agentRequestDto)
val orderStatus = status.body!![0]
!! in Kotlin is the not-null assertion operator. it converts any value to a non-null type and throws an exception if the value is null.
val len = query!!.length
if query is not null it will return its length but if query is null we'll get NPE.