From 73fb317c2083c6d3afcb90e883e04a3819b1df4e Mon Sep 17 00:00:00 2001 From: Ondrej Ruttkay Date: Thu, 23 Jan 2020 12:31:04 +0100 Subject: [PATCH] Handle the case where the order can be an empty string --- .../wordpress/android/fluxc/wc/gateways/GatewayFixtures.kt | 4 ++-- .../wordpress/android/fluxc/model/gateways/GatewayMapper.kt | 2 +- .../fluxc/network/rest/wpcom/wc/gateways/GatewayRestClient.kt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/src/test/java/org/wordpress/android/fluxc/wc/gateways/GatewayFixtures.kt b/example/src/test/java/org/wordpress/android/fluxc/wc/gateways/GatewayFixtures.kt index 86eef7e3d4..0b11f67c91 100644 --- a/example/src/test/java/org/wordpress/android/fluxc/wc/gateways/GatewayFixtures.kt +++ b/example/src/test/java/org/wordpress/android/fluxc/wc/gateways/GatewayFixtures.kt @@ -7,7 +7,7 @@ val GATEWAYS_RESPONSE = listOf( "cod", "Cash on Delivery", "Pay cash", - 0, + "", false, "COD: Method title", "COD: Method description", @@ -17,7 +17,7 @@ val GATEWAYS_RESPONSE = listOf( "stripe", "Credit card", "Pay with CC", - 1, + "1", true, "Stripe: Method title", "Stripe: Method description", diff --git a/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/model/gateways/GatewayMapper.kt b/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/model/gateways/GatewayMapper.kt index 2435900995..b2d4739bd6 100644 --- a/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/model/gateways/GatewayMapper.kt +++ b/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/model/gateways/GatewayMapper.kt @@ -10,7 +10,7 @@ class GatewayMapper response.gatewayId, response.title ?: "", response.description ?: "", - response.order ?: 0, + response.order?.toIntOrNull() ?: 0, response.enabled ?: false, response.methodTitle ?: "", response.methodDescription ?: "", diff --git a/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/gateways/GatewayRestClient.kt b/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/gateways/GatewayRestClient.kt index d89857e4b9..580bf27658 100644 --- a/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/gateways/GatewayRestClient.kt +++ b/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/gateways/GatewayRestClient.kt @@ -75,7 +75,7 @@ constructor( @SerializedName("id") val gatewayId: String, @SerializedName("title") val title: String?, @SerializedName("description") val description: String?, - @SerializedName("order") val order: Int?, + @SerializedName("order") val order: String?, @SerializedName("enabled") val enabled: Boolean?, @SerializedName("method_title") val methodTitle: String?, @SerializedName("method_description") val methodDescription: String?,