|
| 1 | +package com.ecwid.apiclient.v3.converter |
| 2 | + |
| 3 | +import com.ecwid.apiclient.v3.dto.profile.request.UpdatedShippingOption |
| 4 | +import com.ecwid.apiclient.v3.dto.profile.result.FetchedShippingOption |
| 5 | + |
| 6 | +fun FetchedShippingOption.toUpdated(): UpdatedShippingOption { |
| 7 | + return UpdatedShippingOption( |
| 8 | + id = id, |
| 9 | + appClientId = appClientId, |
| 10 | + title = title, |
| 11 | + titleTranslated = titleTranslated, |
| 12 | + description = description, |
| 13 | + descriptionTranslated = descriptionTranslated, |
| 14 | + enabled = enabled, |
| 15 | + orderBy = orderBy, |
| 16 | + fulfilmentType = fulfilmentType, |
| 17 | + minimumOrderSubtotal = minimumOrderSubtotal, |
| 18 | + destinationZone = destinationZone?.toUpdated(), |
| 19 | + deliveryTimeDays = deliveryTimeDays, |
| 20 | + ratesCalculationType = ratesCalculationType, |
| 21 | + locationId = locationId, |
| 22 | + flatRate = flatRate?.toUpdated(), |
| 23 | + ratesTable = ratesTable?.toUpdated(), |
| 24 | + shippingCostMarkup = shippingCostMarkup, |
| 25 | + pickupPreparationTimeHours = pickupPreparationTimeHours, |
| 26 | + pickupBusinessHours = pickupBusinessHours, |
| 27 | + pickupInstruction = pickupInstruction, |
| 28 | + pickupInstructionTranslated = pickupInstructionTranslated, |
| 29 | + scheduledPickup = scheduledPickup, |
| 30 | + type = type, |
| 31 | + carrier = carrier, |
| 32 | + carrierSettings = carrierSettings?.toUpdate(), |
| 33 | + carrierMethods = carrierMethods?.map { it.toUpdated() }, |
| 34 | + businessHours = businessHours, |
| 35 | + businessHoursLimitationType = businessHoursLimitationType, |
| 36 | + allowSameDayDelivery = allowSameDayDelivery, |
| 37 | + availabilityPeriod = availabilityPeriod, |
| 38 | + customAvailabilityPeriodInDays = customAvailabilityPeriodInDays, |
| 39 | + scheduled = scheduled, |
| 40 | + scheduledTimePrecisionType = scheduledTimePrecisionType, |
| 41 | + timeSlotLengthInMinutes = timeSlotLengthInMinutes, |
| 42 | + cutoffTimeForSameDayDelivery = cutoffTimeForSameDayDelivery, |
| 43 | + fulfillmentTimeInMinutes = fulfillmentTimeInMinutes, |
| 44 | + blackoutDates = blackoutDates?.map { it.toUpdated() }, |
| 45 | + estimatedShippingTimeAtCheckoutSettings = estimatedShippingTimeAtCheckoutSettings?.toUpdated(), |
| 46 | + ) |
| 47 | +} |
| 48 | + |
| 49 | +fun FetchedShippingOption.Zone.toUpdated(): UpdatedShippingOption.Zone { |
| 50 | + return UpdatedShippingOption.Zone( |
| 51 | + id = id, |
| 52 | + name = name, |
| 53 | + countryCodes = countryCodes, |
| 54 | + stateOrProvinceCodes = stateOrProvinceCodes, |
| 55 | + postCodes = postCodes, |
| 56 | + ) |
| 57 | +} |
| 58 | + |
| 59 | +fun FetchedShippingOption.FlatRate.toUpdated(): UpdatedShippingOption.FlatRate { |
| 60 | + return UpdatedShippingOption.FlatRate( |
| 61 | + rateType = rateType, |
| 62 | + rate = rate, |
| 63 | + ) |
| 64 | +} |
| 65 | + |
| 66 | +fun FetchedShippingOption.TableRates.toUpdated(): UpdatedShippingOption.TableRates { |
| 67 | + return UpdatedShippingOption.TableRates( |
| 68 | + tableBasedOn = tableBasedOn, |
| 69 | + rates = rates?.map { it.toUpdated() }, |
| 70 | + ) |
| 71 | +} |
| 72 | + |
| 73 | +fun FetchedShippingOption.Rates.toUpdated(): UpdatedShippingOption.Rates { |
| 74 | + return UpdatedShippingOption.Rates( |
| 75 | + conditions = conditions?.toUpdated(), |
| 76 | + rate = rate?.toUpdated(), |
| 77 | + ) |
| 78 | +} |
| 79 | + |
| 80 | +fun FetchedShippingOption.Conditions.toUpdated(): UpdatedShippingOption.Conditions { |
| 81 | + return UpdatedShippingOption.Conditions( |
| 82 | + subtotalFrom = subtotalFrom, |
| 83 | + subtotalTo = subtotalTo, |
| 84 | + discountedSubtotalFrom = discountedSubtotalFrom, |
| 85 | + discountedSubtotalTo = discountedSubtotalTo, |
| 86 | + weightFrom = weightFrom, |
| 87 | + weightTo = weightTo, |
| 88 | + ) |
| 89 | +} |
| 90 | + |
| 91 | +fun FetchedShippingOption.Rate.toUpdated(): UpdatedShippingOption.Rate { |
| 92 | + return UpdatedShippingOption.Rate( |
| 93 | + perOrder = perOrder, |
| 94 | + percent = percent, |
| 95 | + perItem = perItem, |
| 96 | + perWeight = perWeight, |
| 97 | + ) |
| 98 | +} |
| 99 | + |
| 100 | +fun FetchedShippingOption.BlackoutPeriodItem.toUpdated(): UpdatedShippingOption.BlackoutPeriodItem { |
| 101 | + return UpdatedShippingOption.BlackoutPeriodItem( |
| 102 | + fromDate = fromDate, |
| 103 | + toDate = toDate, |
| 104 | + repeatedAnnually = repeatedAnnually, |
| 105 | + ) |
| 106 | +} |
| 107 | + |
| 108 | +fun FetchedShippingOption.EstimatedShippingTimeAtCheckoutSettings.toUpdated(): UpdatedShippingOption.EstimatedShippingTimeAtCheckoutSettings { |
| 109 | + return UpdatedShippingOption.EstimatedShippingTimeAtCheckoutSettings( |
| 110 | + estimatedDeliveryDateAtCheckoutEnabled = estimatedDeliveryDateAtCheckoutEnabled, |
| 111 | + estimatedTransitTimeInDays = estimatedTransitTimeInDays, |
| 112 | + fulfillmentTimeInDays = fulfillmentTimeInDays, |
| 113 | + shippingBusinessDays = shippingBusinessDays, |
| 114 | + deliveryDays = deliveryDays, |
| 115 | + cutoffTimeForSameDayPacking = cutoffTimeForSameDayPacking, |
| 116 | + ) |
| 117 | +} |
| 118 | + |
| 119 | +fun FetchedShippingOption.CarrierSettings.toUpdate(): UpdatedShippingOption.CarrierSettings { |
| 120 | + return UpdatedShippingOption.CarrierSettings( |
| 121 | + defaultCarrierAccountEnabled = defaultCarrierAccountEnabled, |
| 122 | + defaultPostageDimensions = defaultPostageDimensions?.toUpdate(), |
| 123 | + ) |
| 124 | +} |
| 125 | + |
| 126 | +fun FetchedShippingOption.DefaultPostageDimensions.toUpdate(): UpdatedShippingOption.DefaultPostageDimensions { |
| 127 | + return UpdatedShippingOption.DefaultPostageDimensions( |
| 128 | + height = height, |
| 129 | + length = length, |
| 130 | + width = width, |
| 131 | + ) |
| 132 | +} |
| 133 | + |
| 134 | +fun FetchedShippingOption.CarrierMethod.toUpdated(): UpdatedShippingOption.CarrierMethod { |
| 135 | + return UpdatedShippingOption.CarrierMethod( |
| 136 | + id = id, |
| 137 | + name = name, |
| 138 | + enabled = enabled, |
| 139 | + orderBy = orderBy, |
| 140 | + ) |
| 141 | +} |
0 commit comments