diff --git a/src/main/kotlin/no/nb/mlt/wls/application/restapi/order/ApiOrderPayload.kt b/src/main/kotlin/no/nb/mlt/wls/application/restapi/order/ApiOrderPayload.kt index 7827ea2f..304868e4 100644 --- a/src/main/kotlin/no/nb/mlt/wls/application/restapi/order/ApiOrderPayload.kt +++ b/src/main/kotlin/no/nb/mlt/wls/application/restapi/order/ApiOrderPayload.kt @@ -25,11 +25,7 @@ import org.springframework.web.server.ServerWebInputException "owner": "NB", "receiver": { "name": "Doug Dimmadome", - "location": "Doug Dimmadome's office in the Dimmsdale Dimmadome", - "address": "Dimmsdale Dimmadome", - "city": "Dimmsdale", - "postalCode": "69-420", - "phoneNum": "+47 666 69 420" + "address": "Dimmsdale Dimmadome, 21st Ave. Texas" }, "callbackUrl": "https://example.com/send/callback/here" } diff --git a/src/main/kotlin/no/nb/mlt/wls/application/restapi/order/ApiUpdateOrderPayload.kt b/src/main/kotlin/no/nb/mlt/wls/application/restapi/order/ApiUpdateOrderPayload.kt index 97af7c65..bdd72bd5 100644 --- a/src/main/kotlin/no/nb/mlt/wls/application/restapi/order/ApiUpdateOrderPayload.kt +++ b/src/main/kotlin/no/nb/mlt/wls/application/restapi/order/ApiUpdateOrderPayload.kt @@ -22,11 +22,7 @@ import kotlin.jvm.Throws "orderType": "LOAN", "receiver": { "name": "Doug Dimmadome", - "location": "Doug Dimmadome's office in the Dimmsdale Dimmadome", - "address": "Dimmsdale Dimmadome", - "city": "Dimmsdale", - "postalCode": "69-420", - "phoneNum": "+47 666 69 420" + "address": "Dimmsdale Dimmadome, 21st Ave. Texas" }, "callbackUrl": "https://example.com/send/callback/here" } diff --git a/src/main/kotlin/no/nb/mlt/wls/domain/model/Order.kt b/src/main/kotlin/no/nb/mlt/wls/domain/model/Order.kt index 16af2c00..868a6b77 100644 --- a/src/main/kotlin/no/nb/mlt/wls/domain/model/Order.kt +++ b/src/main/kotlin/no/nb/mlt/wls/domain/model/Order.kt @@ -112,11 +112,7 @@ data class Order( data class Receiver( val name: String, - val location: String, - val address: String?, - val city: String?, - val postalCode: String?, - val phoneNumber: String? + val address: String? ) enum class Status { diff --git a/src/main/kotlin/no/nb/mlt/wls/infrastructure/synq/SynqOrderPayload.kt b/src/main/kotlin/no/nb/mlt/wls/infrastructure/synq/SynqOrderPayload.kt index 07a17526..e1744c7a 100644 --- a/src/main/kotlin/no/nb/mlt/wls/infrastructure/synq/SynqOrderPayload.kt +++ b/src/main/kotlin/no/nb/mlt/wls/infrastructure/synq/SynqOrderPayload.kt @@ -1,6 +1,7 @@ package no.nb.mlt.wls.infrastructure.synq import com.fasterxml.jackson.annotation.JsonFormat +import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.annotation.JsonValue import jakarta.validation.constraints.Min import no.nb.mlt.wls.domain.model.Item @@ -21,8 +22,7 @@ data class SynqOrderPayload( val priority: Int, val owner: SynqOwner, val orderLine: List, - val customer: String? = null, - val shippingAddress: ShippingAddress? = null + val shippingAddress: ShippingAddress ) { data class OrderLine( @Min(1) @@ -31,21 +31,6 @@ data class SynqOrderPayload( val quantityOrdered: Double ) - data class ShippingAddress( - val address: Address? - ) { - data class Address( - val contactPerson: String? = null, - val addressLine1: String? = null, - val city: String? = null, - val state: String? = null, - val postalCode: String? = null, - val country: String? = null, - val phoneNumber: String? = null, - val email: String? = null - ) - } - enum class SynqOrderType(private val type: String) { STANDARD("Standard"); @@ -56,6 +41,16 @@ data class SynqOrderPayload( } } +data class ShippingAddress( + val address: Address +) { + data class Address( + val contactPerson: String, + @JsonInclude(JsonInclude.Include.NON_NULL) + val addressLine1: String? = null + ) +} + fun Order.toSynqPayload() = SynqOrderPayload( orderId = hostOrderId, @@ -65,7 +60,7 @@ fun Order.toSynqPayload() = // When order was made in SynQ, if we want to we can omit it and SynQ will set it to current date itself orderDate = LocalDateTime.now(), // TODO: we don't get it from API so we set it to 1, is other value more appropriate? - priority = 1, + priority = 5, owner = owner?.toSynqOwner() ?: SynqOwner.NB, orderLine = productLine.mapIndexed { index, it -> @@ -75,19 +70,13 @@ fun Order.toSynqPayload() = quantityOrdered = 1.0 ) }, - customer = receiver.name, - shippingAddress = receiver.toShippingAddress() - ) - -fun Order.Receiver.toShippingAddress(): SynqOrderPayload.ShippingAddress = - SynqOrderPayload.ShippingAddress( - SynqOrderPayload.ShippingAddress.Address( - contactPerson = name, - addressLine1 = address, - city = city, - postalCode = postalCode, - phoneNumber = phoneNumber - ) + shippingAddress = + ShippingAddress( + ShippingAddress.Address( + receiver.name, + receiver.address + ) + ) ) fun Item.toSynqPayload() = diff --git a/src/test/kotlin/no/nb/mlt/wls/domain/WLSServiceTest.kt b/src/test/kotlin/no/nb/mlt/wls/domain/WLSServiceTest.kt index c4f9264d..159c0d09 100644 --- a/src/test/kotlin/no/nb/mlt/wls/domain/WLSServiceTest.kt +++ b/src/test/kotlin/no/nb/mlt/wls/domain/WLSServiceTest.kt @@ -236,7 +236,7 @@ class WLSServiceTest { "12345", listOf("mlt-420", "mlt-421"), Order.Type.LOAN, - Order.Receiver("name", "location", null, null, null, null), + Order.Receiver("name", "address"), "https://example.com" ) @@ -344,11 +344,7 @@ class WLSServiceTest { receiver = Order.Receiver( name = "Kåre", - address = "Kåres gate 1", - postalCode = "1234", - city = "Kåresby", - location = "Kåresplass", - phoneNumber = "99999999" + address = "Kåresplass" ), callbackUrl = "http://callback.url/path" ) diff --git a/src/test/kotlin/no/nb/mlt/wls/order/controller/OrderControllerTest.kt b/src/test/kotlin/no/nb/mlt/wls/order/controller/OrderControllerTest.kt index 31d62abc..73f959a2 100644 --- a/src/test/kotlin/no/nb/mlt/wls/order/controller/OrderControllerTest.kt +++ b/src/test/kotlin/no/nb/mlt/wls/order/controller/OrderControllerTest.kt @@ -376,11 +376,7 @@ class OrderControllerTest( receiver = Order.Receiver( name = "name", - address = "address", - postalCode = "postalCode", - city = "city", - phoneNumber = "phoneNumber", - location = "location" + address = "address" ), callbackUrl = "https://callbackUrl.com" ) @@ -401,11 +397,7 @@ class OrderControllerTest( receiver = Order.Receiver( name = "name", - address = "address", - postalCode = "postalCode", - city = "city", - phoneNumber = "phoneNumber", - location = "location" + address = "address" ), callbackUrl = "https://callbackUrl.com" ) diff --git a/src/test/kotlin/no/nb/mlt/wls/order/model/MongoOrderModelConversionTest.kt b/src/test/kotlin/no/nb/mlt/wls/order/model/MongoOrderModelConversionTest.kt index a4addea9..5485c18d 100644 --- a/src/test/kotlin/no/nb/mlt/wls/order/model/MongoOrderModelConversionTest.kt +++ b/src/test/kotlin/no/nb/mlt/wls/order/model/MongoOrderModelConversionTest.kt @@ -6,6 +6,7 @@ import no.nb.mlt.wls.application.restapi.order.toOrder import no.nb.mlt.wls.domain.model.HostName import no.nb.mlt.wls.domain.model.Order import no.nb.mlt.wls.domain.model.Owner +import no.nb.mlt.wls.infrastructure.synq.ShippingAddress import no.nb.mlt.wls.infrastructure.synq.SynqOrderPayload import no.nb.mlt.wls.infrastructure.synq.SynqOwner import no.nb.mlt.wls.infrastructure.synq.toSynqPayload @@ -26,11 +27,7 @@ class MongoOrderModelConversionTest { receiver = Order.Receiver( name = "name", - address = "address", - postalCode = "postalCode", - city = "city", - phoneNumber = "phoneNumber", - location = "location" + address = "address" ), callbackUrl = "callbackUrl" ) @@ -46,11 +43,7 @@ class MongoOrderModelConversionTest { receiver = Order.Receiver( name = "name", - address = "address", - postalCode = "postalCode", - city = "city", - phoneNumber = "phoneNumber", - location = "location" + address = "address" ), callbackUrl = "callbackUrl" ) @@ -61,9 +54,18 @@ class MongoOrderModelConversionTest { orderType = SynqOrderPayload.SynqOrderType.STANDARD, dispatchDate = LocalDateTime.now(), orderDate = LocalDateTime.now(), - priority = 1, + priority = 5, owner = SynqOwner.NB, - orderLine = listOf(SynqOrderPayload.OrderLine(1, "hostProductId", 1.0)) + orderLine = + listOf( + SynqOrderPayload.OrderLine(1, "hostProductId", 1.0) + ), + shippingAddress = + ShippingAddress( + ShippingAddress.Address( + "contactPerson" + ) + ) ) @Test