Skip to content

Commit

Permalink
create :: vworld mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
ani2689 committed Aug 7, 2024
1 parent 8f264f6 commit 7473d3d
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.ondosee.thirdparty.vworld.mapper

import com.ondosee.thirdparty.vworld.data.res.PageResponseData
import com.ondosee.thirdparty.vworld.data.res.PointResponseData
import com.ondosee.thirdparty.vworld.data.res.ResultResponseData
import com.ondosee.thirdparty.vworld.data.res.SearchDistrictResponseData
import com.ondosee.thirdparty.vworld.data.web.Page
import com.ondosee.thirdparty.vworld.data.web.Point
import com.ondosee.thirdparty.vworld.data.web.SearchDistrictResultWebResponse
import com.ondosee.thirdparty.vworld.data.web.SearchDistrictVWoldWebResponse

fun SearchDistrictVWoldWebResponse.toResponse() = SearchDistrictResponseData(
status = response.status,
page = response.page!!.toResponse(),
result = response.result?.toResponse() ?: listOf()
)

fun SearchDistrictResultWebResponse.toResponse() =
items.map {
ResultResponseData(
title = it.title,
point = it.point.toResponse()
)
}

fun Page.toResponse() = PageResponseData(
total = total,
current = current,
size = size
)

fun Point.toResponse() = PointResponseData(
x = x,
y = y
)

0 comments on commit 7473d3d

Please sign in to comment.