Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import com.woocommerce.android.ui.orders.wooshippinglabels.packages.datasource.C
import com.woocommerce.android.ui.orders.wooshippinglabels.packages.datasource.CarrierType.USPS
import com.woocommerce.android.ui.orders.wooshippinglabels.packages.networking.CarrierPackageGroupDTO
import com.woocommerce.android.ui.orders.wooshippinglabels.packages.networking.CarrierPredefinedPackagesDTO
import com.woocommerce.android.ui.orders.wooshippinglabels.packages.networking.CustomPackageDTO
import com.woocommerce.android.ui.orders.wooshippinglabels.packages.networking.PackageResponse
import com.woocommerce.android.ui.orders.wooshippinglabels.packages.networking.PredefinedPackageDTO
import javax.inject.Inject

class WooShippingLabelPackageMapper @Inject constructor() {
operator fun invoke(response: PackageResponse): StorePackagesDAO {
val savedPackagesResponse = response.packages?.saved?.predefined ?: emptyList()
val savedPackagesResponse = response.packages?.saved?.custom ?: emptyList()

return StorePackagesDAO(
savedPackages = mapSavedPackages(savedPackagesResponse),
carrierPackages = mapCarrierPackages(response.packages?.predefined)
)
}

private fun mapSavedPackages(savedResponse: List<PredefinedPackageDTO>): List<PackageDAO> {
private fun mapSavedPackages(savedResponse: List<CustomPackageDTO>): List<PackageDAO> {
return savedResponse.map {
PackageDAO(
id = it.id.orEmpty(),
Expand Down Expand Up @@ -59,7 +59,7 @@ class WooShippingLabelPackageMapper @Inject constructor() {
PackageDAO(
id = it.id.orEmpty(),
name = it.name.orEmpty(),
dimensions = it.dimensions.orEmpty(),
dimensions = it.outerDimensions.orEmpty(),
isLetter = it.isLetter ?: false
)
} ?: emptyList()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
package com.woocommerce.android.ui.orders.wooshippinglabels.packages.networking

import com.google.gson.annotations.SerializedName

class CarrierPredefinedPackagesDTO {
val usps: USPSPackageDTO? = null

@SerializedName("dhlexpress")
val dhlExpress: DHLPackageDTO? = null
}

class USPSPackageDTO {
@SerializedName("pri_flat_boxes")
val flatBoxes: CarrierPackageGroupDTO? = null

@SerializedName("pri_boxes")
val boxes: CarrierPackageGroupDTO? = null

@SerializedName("pri_express_boxes")
val expressBoxes: CarrierPackageGroupDTO? = null

@SerializedName("pri_envelopes")
val envelopes: CarrierPackageGroupDTO? = null

@SerializedName("pri_express_envelopes")
val expressEnvelopes: CarrierPackageGroupDTO? = null
}

class DHLPackageDTO {
@SerializedName("domestic_and_international")
val domesticAndInternationalPackages: CarrierPackageGroupDTO? = null
}

Expand All @@ -23,15 +37,30 @@ class CarrierPackageGroupDTO {
}

class PredefinedPackageDTO {
val id: String? = null
val name: String? = null

@SerializedName("inner_dimensions")
val innerDimensions: String? = null

@SerializedName("outer_dimensions")
val outerDimensions: String? = null

@SerializedName("box_weight")
val boxWeight: Double? = null

@SerializedName("is_flat_rate")
val isFlatRate: Boolean? = null
val id: String? = null
val name: String? = null
val dimensions: String? = null

@SerializedName("max_weight")
val maxWeight: Double? = null

@SerializedName("is_letter")
val isLetter: Boolean? = null

@SerializedName("group_id")
val groupId: String? = null

@SerializedName("can_ship_international")
val canShipInternational: Boolean? = null
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
package com.woocommerce.android.ui.orders.wooshippinglabels.packages.networking

import com.google.gson.annotations.SerializedName

class PackageResponse {
val storeOptions: PackageStoreOptionsDTO? = null
val packages: PackagesInfoDTO? = null
}

class PackageStoreOptionsDTO {
@SerializedName("currency_symbol")
val currencySymbol: String? = null

@SerializedName("dimension_unit")
val dimensionUnit: String? = null

@SerializedName("weight_unit")
val weightUnit: String? = null

@SerializedName("origin_country")
val originCountry: String? = null
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.woocommerce.android.ui.orders.wooshippinglabels.packages.networking

import com.google.gson.annotations.SerializedName

class SavedPackageInfoDTO {
val custom: List<CustomPackageDTO>? = null
val predefined: List<PredefinedPackageDTO>? = null
}

class CustomPackageDTO {
Expand All @@ -12,8 +13,14 @@ class CustomPackageDTO {
val length: Double? = null
val width: Double? = null
val height: Double? = null
val type: String? = null

@SerializedName("box_weight")
val boxWeight: Double? = null

@SerializedName("is_letter")
val isLetter: Boolean? = null

@SerializedName("is_user_defined")
val isUserDefined: Boolean? = null
val type: String? = null
}
Loading