From c7e9991c33f51b07b117dcb9600f660a398c0908 Mon Sep 17 00:00:00 2001 From: Roman Timchenko Date: Tue, 21 Jan 2025 17:14:38 +0400 Subject: [PATCH 1/7] ECWID-155668 Add "updateShippingOption" method to ecwid-java-api-client - (feat) add new DTO classes --- .../v3/converter/FetchedShippingOption.kt | 141 ++++++++++++++++++ .../enums/ApiBusinessHoursLimitationType.kt | 8 + .../enums/AvailabilityPeriodTimeUnit.kt | 7 + .../profile/enums/AvailabilityPeriodType.kt | 8 + .../v3/dto/profile/enums/FulfilmentType.kt | 6 + .../dto/profile/enums/RatesCalculationType.kt | 18 +++ .../enums/ScheduledTimePrecisionType.kt | 7 + .../profile/request/UpdatedShippingOption.kt | 125 ++++++++++++++++ .../profile/result/FetchedShippingOption.kt | 126 ++++++++++++++++ .../v3/rule/NullablePropertyRules.kt | 1 + ...chedShippingoptionNullablePropertyRules.kt | 85 +++++++++++ 11 files changed, 532 insertions(+) create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedShippingOption.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/ApiBusinessHoursLimitationType.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/AvailabilityPeriodTimeUnit.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/AvailabilityPeriodType.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/FulfilmentType.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/RatesCalculationType.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/ScheduledTimePrecisionType.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdatedShippingOption.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedShippingOption.kt create mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedShippingoptionNullablePropertyRules.kt diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedShippingOption.kt b/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedShippingOption.kt new file mode 100644 index 000000000..ca01dde81 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedShippingOption.kt @@ -0,0 +1,141 @@ +package com.ecwid.apiclient.v3.converter + +import com.ecwid.apiclient.v3.dto.profile.request.UpdatedShippingOption +import com.ecwid.apiclient.v3.dto.profile.result.FetchedShippingOption + +fun FetchedShippingOption.toUpdated(): UpdatedShippingOption { + return UpdatedShippingOption( + id = id, + appClientId = appClientId, + title = title, + titleTranslated = titleTranslated, + description = description, + descriptionTranslated = descriptionTranslated, + enabled = enabled, + orderBy = orderBy, + fulfilmentType = fulfilmentType, + minimumOrderSubtotal = minimumOrderSubtotal, + destinationZone = destinationZone?.toUpdated(), + deliveryTimeDays = deliveryTimeDays, + ratesCalculationType = ratesCalculationType, + locationId = locationId, + flatRate = flatRate?.toUpdated(), + ratesTable = ratesTable?.toUpdated(), + shippingCostMarkup = shippingCostMarkup, + pickupPreparationTimeHours = pickupPreparationTimeHours, + pickupBusinessHours = pickupBusinessHours, + pickupInstruction = pickupInstruction, + pickupInstructionTranslated = pickupInstructionTranslated, + scheduledPickup = scheduledPickup, + type = type, + carrier = carrier, + carrierSettings = carrierSettings?.toUpdate(), + carrierMethods = carrierMethods?.map { it.toUpdated() }, + businessHours = businessHours, + businessHoursLimitationType = businessHoursLimitationType, + allowSameDayDelivery = allowSameDayDelivery, + availabilityPeriod = availabilityPeriod, + customAvailabilityPeriodInDays = customAvailabilityPeriodInDays, + scheduled = scheduled, + scheduledTimePrecisionType = scheduledTimePrecisionType, + timeSlotLengthInMinutes = timeSlotLengthInMinutes, + cutoffTimeForSameDayDelivery = cutoffTimeForSameDayDelivery, + fulfillmentTimeInMinutes = fulfillmentTimeInMinutes, + blackoutDates = blackoutDates?.map { it.toUpdated() }, + estimatedShippingTimeAtCheckoutSettings = estimatedShippingTimeAtCheckoutSettings?.toUpdated(), + ) +} + +fun FetchedShippingOption.Zone.toUpdated(): UpdatedShippingOption.Zone { + return UpdatedShippingOption.Zone( + id = id, + name = name, + countryCodes = countryCodes, + stateOrProvinceCodes = stateOrProvinceCodes, + postCodes = postCodes, + ) +} + +fun FetchedShippingOption.FlatRate.toUpdated(): UpdatedShippingOption.FlatRate { + return UpdatedShippingOption.FlatRate( + rateType = rateType, + rate = rate, + ) +} + +fun FetchedShippingOption.TableRates.toUpdated(): UpdatedShippingOption.TableRates { + return UpdatedShippingOption.TableRates( + tableBasedOn = tableBasedOn, + rates = rates?.map { it.toUpdated() }, + ) +} + +fun FetchedShippingOption.Rates.toUpdated(): UpdatedShippingOption.Rates { + return UpdatedShippingOption.Rates( + conditions = conditions?.toUpdated(), + rate = rate?.toUpdated(), + ) +} + +fun FetchedShippingOption.Conditions.toUpdated(): UpdatedShippingOption.Conditions { + return UpdatedShippingOption.Conditions( + subtotalFrom = subtotalFrom, + subtotalTo = subtotalTo, + discountedSubtotalFrom = discountedSubtotalFrom, + discountedSubtotalTo = discountedSubtotalTo, + weightFrom = weightFrom, + weightTo = weightTo, + ) +} + +fun FetchedShippingOption.Rate.toUpdated(): UpdatedShippingOption.Rate { + return UpdatedShippingOption.Rate( + perOrder = perOrder, + percent = percent, + perItem = perItem, + perWeight = perWeight, + ) +} + +fun FetchedShippingOption.BlackoutPeriodItem.toUpdated(): UpdatedShippingOption.BlackoutPeriodItem { + return UpdatedShippingOption.BlackoutPeriodItem( + fromDate = fromDate, + toDate = toDate, + repeatedAnnually = repeatedAnnually, + ) +} + +fun FetchedShippingOption.EstimatedShippingTimeAtCheckoutSettings.toUpdated(): UpdatedShippingOption.EstimatedShippingTimeAtCheckoutSettings { + return UpdatedShippingOption.EstimatedShippingTimeAtCheckoutSettings( + estimatedDeliveryDateAtCheckoutEnabled = estimatedDeliveryDateAtCheckoutEnabled, + estimatedTransitTimeInDays = estimatedTransitTimeInDays, + fulfillmentTimeInDays = fulfillmentTimeInDays, + shippingBusinessDays = shippingBusinessDays, + deliveryDays = deliveryDays, + cutoffTimeForSameDayPacking = cutoffTimeForSameDayPacking, + ) +} + +fun FetchedShippingOption.CarrierSettings.toUpdate(): UpdatedShippingOption.CarrierSettings { + return UpdatedShippingOption.CarrierSettings( + defaultCarrierAccountEnabled = defaultCarrierAccountEnabled, + defaultPostageDimensions = defaultPostageDimensions?.toUpdate(), + ) +} + +fun FetchedShippingOption.DefaultPostageDimensions.toUpdate(): UpdatedShippingOption.DefaultPostageDimensions { + return UpdatedShippingOption.DefaultPostageDimensions( + height = height, + length = length, + width = width, + ) +} + +fun FetchedShippingOption.CarrierMethod.toUpdated(): UpdatedShippingOption.CarrierMethod { + return UpdatedShippingOption.CarrierMethod( + id = id, + name = name, + enabled = enabled, + orderBy = orderBy, + ) +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/ApiBusinessHoursLimitationType.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/ApiBusinessHoursLimitationType.kt new file mode 100644 index 000000000..1052907ed --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/ApiBusinessHoursLimitationType.kt @@ -0,0 +1,8 @@ +package com.ecwid.apiclient.v3.dto.profile.enums + +@Suppress("unused") +enum class ApiBusinessHoursLimitationType { + ALLOW_ORDERS_AND_INFORM_CUSTOMERS, + DISALLOW_ORDERS_AND_INFORM_CUSTOMERS, + ALLOW_ORDERS_AND_DONT_INFORM_CUSTOMERS +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/AvailabilityPeriodTimeUnit.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/AvailabilityPeriodTimeUnit.kt new file mode 100644 index 000000000..661f21dfe --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/AvailabilityPeriodTimeUnit.kt @@ -0,0 +1,7 @@ +package com.ecwid.apiclient.v3.dto.profile.enums + +@Suppress("unused") +enum class AvailabilityPeriodTimeUnit(val valueInMinutes: Int) { + DAYS(24 * 60), + MONTHS(30 * 24 * 60); +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/AvailabilityPeriodType.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/AvailabilityPeriodType.kt new file mode 100644 index 000000000..8205950a0 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/AvailabilityPeriodType.kt @@ -0,0 +1,8 @@ +package com.ecwid.apiclient.v3.dto.profile.enums + +@Suppress("unused") +enum class AvailabilityPeriodType(val unitCount: Int, val unit: AvailabilityPeriodTimeUnit?) { + SEVEN_DAYS(7, AvailabilityPeriodTimeUnit.DAYS), + ONE_MONTH(1, AvailabilityPeriodTimeUnit.MONTHS), + UNLIMITED(1200, AvailabilityPeriodTimeUnit.MONTHS); +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/FulfilmentType.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/FulfilmentType.kt new file mode 100644 index 000000000..43ebecfa8 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/FulfilmentType.kt @@ -0,0 +1,6 @@ +package com.ecwid.apiclient.v3.dto.profile.enums + +@Suppress("unused") +enum class FulfilmentType { + pickup, shipping, delivery +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/RatesCalculationType.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/RatesCalculationType.kt new file mode 100644 index 000000000..f198dda0e --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/RatesCalculationType.kt @@ -0,0 +1,18 @@ +package com.ecwid.apiclient.v3.dto.profile.enums + +@Suppress("unused") +enum class RatesCalculationType { + + carrier_calculated, + table, + flat, + app; + + override fun toString(): String { + return asApiString() + } + + fun asApiString(): String { + return super.toString().replace("_", "-") + } +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/ScheduledTimePrecisionType.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/ScheduledTimePrecisionType.kt new file mode 100644 index 000000000..db9d9b4a5 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/ScheduledTimePrecisionType.kt @@ -0,0 +1,7 @@ +package com.ecwid.apiclient.v3.dto.profile.enums + +@Suppress("unused") +enum class ScheduledTimePrecisionType { + DATE, + DATE_AND_TIME_SLOT, +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdatedShippingOption.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdatedShippingOption.kt new file mode 100644 index 000000000..06420cdbe --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdatedShippingOption.kt @@ -0,0 +1,125 @@ +package com.ecwid.apiclient.v3.dto.profile.request + +import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO +import com.ecwid.apiclient.v3.dto.profile.enums.* +import com.ecwid.apiclient.v3.dto.profile.result.FetchedShippingOption +import java.util.* + +data class UpdatedShippingOption( + val id: String? = null, + val appClientId: String? = null, + val title: String? = null, + val titleTranslated: Map? = null, + val description: String? = null, + val descriptionTranslated: Map? = null, + val enabled: Boolean? = null, + val orderBy: Int? = null, + val fulfilmentType: FulfilmentType? = null, + val minimumOrderSubtotal: Double? = null, + val destinationZone: Zone? = null, + val ratesCalculationType: RatesCalculationType? = null, + val locationId: String? = null, + val flatRate: FlatRate? = null, + val shippingCostMarkup: Double? = null, + val ratesTable: TableRates? = null, + val pickupInstruction: String? = null, + val pickupInstructionTranslated: Map? = null, + val pickupPreparationTimeHours: Int? = null, + val pickupBusinessHours: String? = null, + val scheduledPickup: Boolean? = null, + val type: String? = null, + val carrier: String? = null, + val carrierMethods: List? = null, + val carrierSettings: CarrierSettings? = null, + val businessHours: BusinessHours? = null, + val businessHoursLimitationType: ApiBusinessHoursLimitationType? = null, + val allowSameDayDelivery: Boolean? = null, + val deliveryTimeDays: String? = null, + val availabilityPeriod: AvailabilityPeriodType? = null, + val customAvailabilityPeriodInDays: Int? = null, + val scheduled: Boolean? = null, + val scheduledTimePrecisionType: ScheduledTimePrecisionType? = null, + val timeSlotLengthInMinutes: Int? = null, + val cutoffTimeForSameDayDelivery: String? = null, + val fulfillmentTimeInMinutes: Int? = null, + val blackoutDates: List? = null, + val estimatedShippingTimeAtCheckoutSettings: EstimatedShippingTimeAtCheckoutSettings? = null, +) : ApiUpdatedDTO { + data class Zone( + val id: String? = null, + val name: String? = null, + val countryCodes: List? = null, + val stateOrProvinceCodes: List? = null, + val postCodes: List? = null, + ) + + data class FlatRate( + val rateType: String? = null, + val rate: Double? = null, + ) + + data class TableRates( + val tableBasedOn: String? = null, + val rates: List? = null, + ) + + data class Rates( + val conditions: Conditions? = null, + val rate: Rate? = null, + ) + + data class Conditions( + val subtotalFrom: Double? = null, + val subtotalTo: Double? = null, + val discountedSubtotalFrom: Double? = null, + val discountedSubtotalTo: Double? = null, + val weightFrom: Double? = null, + val weightTo: Double? = null, + ) + + data class Rate( + val perOrder: Double? = null, + val percent: Double? = null, + val perItem: Double? = null, + val perWeight: Double? = null, + ) + + data class CarrierMethod( + val id: String? = null, + val name: String? = null, + val enabled: Boolean? = null, + val orderBy: Int? = null + ) + + data class BlackoutPeriodItem( + val fromDate: Date? = null, + val toDate: Date? = null, + val repeatedAnnually: Boolean? = null, + ) + + data class EstimatedShippingTimeAtCheckoutSettings( + val estimatedDeliveryDateAtCheckoutEnabled: Boolean? = null, + val estimatedTransitTimeInDays: List? = null, + val fulfillmentTimeInDays: List? = null, + val shippingBusinessDays: List? = null, + val deliveryDays: List? = null, + val cutoffTimeForSameDayPacking: String? = null, + ) + + data class CarrierSettings( + val defaultCarrierAccountEnabled: Boolean? = null, + val defaultPostageDimensions: DefaultPostageDimensions? = null + ) + + data class DefaultPostageDimensions( + val length: Double? = null, + val width: Double? = null, + val height: Double? = null + ) + + override fun getModifyKind(): ApiUpdatedDTO.ModifyKind { + return ApiUpdatedDTO.ModifyKind.ReadWrite(FetchedShippingOption::class) + } +} + +typealias BusinessHours = Map>> diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedShippingOption.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedShippingOption.kt new file mode 100644 index 000000000..ab010e011 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedShippingOption.kt @@ -0,0 +1,126 @@ +package com.ecwid.apiclient.v3.dto.profile.result + +import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO +import com.ecwid.apiclient.v3.dto.profile.enums.* +import com.ecwid.apiclient.v3.dto.profile.request.UpdatedShippingOption +import java.util.* + +data class FetchedShippingOption( + val id: String? = null, + val appClientId: String? = null, + val title: String? = null, + val titleTranslated: Map? = null, + val description: String? = null, + val descriptionTranslated: Map? = null, + val enabled: Boolean? = null, + val orderBy: Int? = null, + val fulfilmentType: FulfilmentType? = null, + val minimumOrderSubtotal: Double? = null, + val destinationZone: Zone? = null, + val ratesCalculationType: RatesCalculationType? = null, + val locationId: String? = null, + val flatRate: FlatRate? = null, + val shippingCostMarkup: Double? = null, + val ratesTable: TableRates? = null, + val pickupInstruction: String? = null, + val pickupInstructionTranslated: Map? = null, + val pickupPreparationTimeHours: Int? = null, + val pickupBusinessHours: String? = null, + val scheduledPickup: Boolean? = null, + val type: String? = null, + val carrier: String? = null, + val carrierMethods: List? = null, + val carrierSettings: CarrierSettings? = null, + val businessHours: BusinessHours? = null, + val businessHoursLimitationType: ApiBusinessHoursLimitationType? = null, + val allowSameDayDelivery: Boolean? = null, + val deliveryTimeDays: String? = null, + val availabilityPeriod: AvailabilityPeriodType? = null, + val customAvailabilityPeriodInDays: Int? = null, + val scheduled: Boolean? = null, + val scheduledTimePrecisionType: ScheduledTimePrecisionType? = null, + val timeSlotLengthInMinutes: Int? = null, + val cutoffTimeForSameDayDelivery: String? = null, + val fulfillmentTimeInMinutes: Int? = null, + val blackoutDates: List? = null, + val estimatedShippingTimeAtCheckoutSettings: EstimatedShippingTimeAtCheckoutSettings? = null, +) : ApiFetchedDTO { + + data class Zone( + val id: String? = null, + val name: String? = null, + val countryCodes: List? = null, + val stateOrProvinceCodes: List? = null, + val postCodes: List? = null, + ) + + data class FlatRate( + val rateType: String? = null, + val rate: Double? = null, + ) + + data class TableRates( + val tableBasedOn: String? = null, + val rates: List? = null, + ) + + data class Rates( + val conditions: Conditions? = null, + val rate: Rate? = null, + ) + + data class Conditions( + val subtotalFrom: Double? = null, + val subtotalTo: Double? = null, + val discountedSubtotalFrom: Double? = null, + val discountedSubtotalTo: Double? = null, + val weightFrom: Double? = null, + val weightTo: Double? = null, + ) + + data class Rate( + val perOrder: Double? = null, + val percent: Double? = null, + val perItem: Double? = null, + val perWeight: Double? = null, + ) + + data class CarrierMethod( + val id: String? = null, + val name: String? = null, + val enabled: Boolean? = null, + val orderBy: Int? = null + ) + + data class BlackoutPeriodItem( + val fromDate: Date? = null, + val toDate: Date? = null, + val repeatedAnnually: Boolean? = null, + ) + + data class EstimatedShippingTimeAtCheckoutSettings( + val estimatedDeliveryDateAtCheckoutEnabled: Boolean? = null, + val estimatedTransitTimeInDays: List? = null, + val fulfillmentTimeInDays: List? = null, + val shippingBusinessDays: List? = null, + val deliveryDays: List? = null, + val cutoffTimeForSameDayPacking: String? = null, + ) + + data class CarrierSettings( + val defaultCarrierAccountEnabled: Boolean? = null, + val defaultPostageDimensions: DefaultPostageDimensions? = null + ) + + data class DefaultPostageDimensions( + val length: Double? = null, + val width: Double? = null, + val height: Double? = null + ) + + override fun getModifyKind(): ApiFetchedDTO.ModifyKind { + return ApiFetchedDTO.ModifyKind.ReadWrite(UpdatedShippingOption::class) + } +} + +typealias BusinessHours = Map>> diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt index f139e9d67..f8807699f 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt @@ -183,6 +183,7 @@ val nullablePropertyRules: List> = listOf( fetchedOrderNullablePropertyRules, fetchedProductNullablePropertyRules, fetchedProductTypeNullablePropertyRules, + fetchedShippingOptionNullablePropertyRules, fetchedStoreProfileNullablePropertyRules, fetchedVariationTypeNullablePropertyRules, getProductFiltersRequestNullablePropertyRules, diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedShippingoptionNullablePropertyRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedShippingoptionNullablePropertyRules.kt new file mode 100644 index 000000000..d854f756b --- /dev/null +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedShippingoptionNullablePropertyRules.kt @@ -0,0 +1,85 @@ +package com.ecwid.apiclient.v3.rule.nullablepropertyrules + +import com.ecwid.apiclient.v3.dto.profile.result.FetchedShippingOption +import com.ecwid.apiclient.v3.rule.NullablePropertyRule +import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable + +val fetchedShippingOptionNullablePropertyRules: List> = listOf( + AllowNullable(FetchedShippingOption::id), + AllowNullable(FetchedShippingOption::appClientId), + AllowNullable(FetchedShippingOption::title), + AllowNullable(FetchedShippingOption::titleTranslated), + AllowNullable(FetchedShippingOption::description), + AllowNullable(FetchedShippingOption::descriptionTranslated), + AllowNullable(FetchedShippingOption::enabled), + AllowNullable(FetchedShippingOption::orderBy), + AllowNullable(FetchedShippingOption::fulfilmentType), + AllowNullable(FetchedShippingOption::minimumOrderSubtotal), + AllowNullable(FetchedShippingOption::deliveryTimeDays), + AllowNullable(FetchedShippingOption::destinationZone), + AllowNullable(FetchedShippingOption::ratesCalculationType), + AllowNullable(FetchedShippingOption::locationId), + AllowNullable(FetchedShippingOption::flatRate), + AllowNullable(FetchedShippingOption::ratesTable), + AllowNullable(FetchedShippingOption::pickupInstruction), + AllowNullable(FetchedShippingOption::pickupInstructionTranslated), + AllowNullable(FetchedShippingOption::pickupBusinessHours), + AllowNullable(FetchedShippingOption::pickupPreparationTimeHours), + AllowNullable(FetchedShippingOption::type), + AllowNullable(FetchedShippingOption::carrier), + AllowNullable(FetchedShippingOption::carrierSettings), + AllowNullable(FetchedShippingOption::carrierMethods), + AllowNullable(FetchedShippingOption::businessHours), + AllowNullable(FetchedShippingOption::businessHoursLimitationType), + AllowNullable(FetchedShippingOption::allowSameDayDelivery), + AllowNullable(FetchedShippingOption::availabilityPeriod), + AllowNullable(FetchedShippingOption::customAvailabilityPeriodInDays), + AllowNullable(FetchedShippingOption::scheduled), + AllowNullable(FetchedShippingOption::scheduledTimePrecisionType), + AllowNullable(FetchedShippingOption::scheduledPickup), + AllowNullable(FetchedShippingOption::shippingCostMarkup), + AllowNullable(FetchedShippingOption::timeSlotLengthInMinutes), + AllowNullable(FetchedShippingOption::cutoffTimeForSameDayDelivery), + AllowNullable(FetchedShippingOption::fulfillmentTimeInMinutes), + AllowNullable(FetchedShippingOption::blackoutDates), + AllowNullable(FetchedShippingOption::estimatedShippingTimeAtCheckoutSettings), + AllowNullable(FetchedShippingOption.Zone::id), + AllowNullable(FetchedShippingOption.Zone::name), + AllowNullable(FetchedShippingOption.Zone::countryCodes), + AllowNullable(FetchedShippingOption.Zone::stateOrProvinceCodes), + AllowNullable(FetchedShippingOption.Zone::postCodes), + AllowNullable(FetchedShippingOption.FlatRate::rate), + AllowNullable(FetchedShippingOption.FlatRate::rateType), + AllowNullable(FetchedShippingOption.TableRates::rates), + AllowNullable(FetchedShippingOption.TableRates::tableBasedOn), + AllowNullable(FetchedShippingOption.Rates::rate), + AllowNullable(FetchedShippingOption.Rates::conditions), + AllowNullable(FetchedShippingOption.Rate::perItem), + AllowNullable(FetchedShippingOption.Rate::perOrder), + AllowNullable(FetchedShippingOption.Rate::perWeight), + AllowNullable(FetchedShippingOption.Rate::percent), + AllowNullable(FetchedShippingOption.BlackoutPeriodItem::fromDate), + AllowNullable(FetchedShippingOption.BlackoutPeriodItem::toDate), + AllowNullable(FetchedShippingOption.BlackoutPeriodItem::repeatedAnnually), + AllowNullable(FetchedShippingOption.Conditions::discountedSubtotalFrom), + AllowNullable(FetchedShippingOption.Conditions::discountedSubtotalTo), + AllowNullable(FetchedShippingOption.Conditions::subtotalFrom), + AllowNullable(FetchedShippingOption.Conditions::subtotalTo), + AllowNullable(FetchedShippingOption.Conditions::weightFrom), + AllowNullable(FetchedShippingOption.Conditions::weightTo), + AllowNullable(FetchedShippingOption.EstimatedShippingTimeAtCheckoutSettings::estimatedDeliveryDateAtCheckoutEnabled), + AllowNullable(FetchedShippingOption.EstimatedShippingTimeAtCheckoutSettings::estimatedTransitTimeInDays), + AllowNullable(FetchedShippingOption.EstimatedShippingTimeAtCheckoutSettings::fulfillmentTimeInDays), + AllowNullable(FetchedShippingOption.EstimatedShippingTimeAtCheckoutSettings::shippingBusinessDays), + AllowNullable(FetchedShippingOption.EstimatedShippingTimeAtCheckoutSettings::deliveryDays), + AllowNullable(FetchedShippingOption.EstimatedShippingTimeAtCheckoutSettings::cutoffTimeForSameDayPacking), + AllowNullable(FetchedShippingOption.CarrierMethod::id), + AllowNullable(FetchedShippingOption.CarrierMethod::enabled), + AllowNullable(FetchedShippingOption.CarrierMethod::name), + AllowNullable(FetchedShippingOption.CarrierMethod::orderBy), + AllowNullable(FetchedShippingOption.CarrierSettings::defaultCarrierAccountEnabled), + AllowNullable(FetchedShippingOption.CarrierSettings::defaultPostageDimensions), + AllowNullable(FetchedShippingOption.DefaultPostageDimensions::height), + AllowNullable(FetchedShippingOption.DefaultPostageDimensions::length), + AllowNullable(FetchedShippingOption.DefaultPostageDimensions::width), +) From 0356f3195b9957f4c83ffd4b39a1507323dc4b3f Mon Sep 17 00:00:00 2001 From: Roman Timchenko Date: Tue, 21 Jan 2025 17:15:17 +0400 Subject: [PATCH 2/7] ECWID-155668 Add "updateShippingOption" method to ecwid-java-api-client - (feat) implement updateShippingOption method --- .../apiclient/v3/StoreProfileApiClient.kt | 2 +- .../request/UpdateShippingOptionRequest.kt | 23 +++++++++++++++++++ .../result/UpdateShippingOptionResult.kt | 7 ++++++ .../v3/impl/StoreProfileApiClientImpl.kt | 3 +++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdateShippingOptionRequest.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/UpdateShippingOptionResult.kt diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/StoreProfileApiClient.kt b/src/main/kotlin/com/ecwid/apiclient/v3/StoreProfileApiClient.kt index 94f640bda..0042a16a5 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/StoreProfileApiClient.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/StoreProfileApiClient.kt @@ -17,7 +17,7 @@ interface StoreProfileApiClient { fun getShippingOptions(request: ShippingOptionsRequest): ShippingOptionsResult // fun addShippingOption() - // fun updateShippingOption() + fun updateShippingOption(request: UpdateShippingOptionRequest): UpdateShippingOptionResult fun getPaymentOptions(request: PaymentOptionsRequest): PaymentOptionsResult fun createPaymentOption(request: PaymentOptionCreateRequest): PaymentOptionCreateResult fun deletePaymentOption(request: PaymentOptionDeleteRequest): PaymentOptionDeleteResult diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdateShippingOptionRequest.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdateShippingOptionRequest.kt new file mode 100644 index 000000000..6e6a5c4a6 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdateShippingOptionRequest.kt @@ -0,0 +1,23 @@ +package com.ecwid.apiclient.v3.dto.profile.request + +import com.ecwid.apiclient.v3.dto.ApiRequest +import com.ecwid.apiclient.v3.httptransport.HttpBody +import com.ecwid.apiclient.v3.impl.RequestInfo + +data class UpdateShippingOptionRequest( + private val optionId: String = "", + private val updatedShippingOption: UpdatedShippingOption = UpdatedShippingOption() +) : ApiRequest { + override fun toRequestInfo(): RequestInfo { + return RequestInfo.createPutRequest( + pathSegments = listOf( + "profile", + "shippingOptions", + optionId + ), + httpBody = HttpBody.JsonBody( + obj = updatedShippingOption + ) + ) + } +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/UpdateShippingOptionResult.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/UpdateShippingOptionResult.kt new file mode 100644 index 000000000..0c0a8ea9b --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/UpdateShippingOptionResult.kt @@ -0,0 +1,7 @@ +package com.ecwid.apiclient.v3.dto.profile.result + +import com.ecwid.apiclient.v3.dto.common.ApiResultDTO + +data class UpdateShippingOptionResult( + val updateCount: Int = 0 +) : ApiResultDTO diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/impl/StoreProfileApiClientImpl.kt b/src/main/kotlin/com/ecwid/apiclient/v3/impl/StoreProfileApiClientImpl.kt index a57f4c91c..ba92bef2d 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/impl/StoreProfileApiClientImpl.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/impl/StoreProfileApiClientImpl.kt @@ -55,6 +55,9 @@ internal class StoreProfileApiClientImpl( override fun getShippingOptions(request: ShippingOptionsRequest): ShippingOptionsResult = apiClientHelper.makeObjectResultRequest(request) + override fun updateShippingOption(request: UpdateShippingOptionRequest): UpdateShippingOptionResult = + apiClientHelper.makeObjectResultRequest(request) + override fun getPaymentOptions(request: PaymentOptionsRequest): PaymentOptionsResult = apiClientHelper.makeObjectResultRequest(request) From b7540757cab50b98b3d0cd1e99b43b00efda8d68 Mon Sep 17 00:00:00 2001 From: Roman Timchenko Date: Tue, 21 Jan 2025 17:26:34 +0400 Subject: [PATCH 3/7] ECWID-155668 Add "updateShippingOption" method to ecwid-java-api-client - (feat) extract 'rateType' to separated enum --- .../com/ecwid/apiclient/v3/dto/profile/enums/RateType.kt | 7 +++++++ .../v3/dto/profile/request/UpdatedShippingOption.kt | 2 +- .../v3/dto/profile/result/FetchedShippingOption.kt | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/RateType.kt diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/RateType.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/RateType.kt new file mode 100644 index 000000000..b2bf74ced --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/RateType.kt @@ -0,0 +1,7 @@ +package com.ecwid.apiclient.v3.dto.profile.enums + +@Suppress("unused") +enum class RateType { + ABSOLUTE, + PERCENT +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdatedShippingOption.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdatedShippingOption.kt index 06420cdbe..7533f00b2 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdatedShippingOption.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdatedShippingOption.kt @@ -54,7 +54,7 @@ data class UpdatedShippingOption( ) data class FlatRate( - val rateType: String? = null, + val rateType: RateType? = null, val rate: Double? = null, ) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedShippingOption.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedShippingOption.kt index ab010e011..78e487963 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedShippingOption.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedShippingOption.kt @@ -55,7 +55,7 @@ data class FetchedShippingOption( ) data class FlatRate( - val rateType: String? = null, + val rateType: RateType? = null, val rate: Double? = null, ) From 1109053b47bad3e0ca5e465c805316a1803899bf Mon Sep 17 00:00:00 2001 From: Roman Timchenko Date: Wed, 22 Jan 2025 10:09:30 +0400 Subject: [PATCH 4/7] ECWID-155668 Add "updateShippingOption" method to ecwid-java-api-client - (refactor) fix detekt: get rid of magic numbers --- .../v3/dto/profile/enums/AvailabilityPeriodTimeUnit.kt | 7 +++++-- .../v3/dto/profile/enums/AvailabilityPeriodType.kt | 10 +++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/AvailabilityPeriodTimeUnit.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/AvailabilityPeriodTimeUnit.kt index 661f21dfe..4134dc127 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/AvailabilityPeriodTimeUnit.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/AvailabilityPeriodTimeUnit.kt @@ -1,7 +1,10 @@ package com.ecwid.apiclient.v3.dto.profile.enums +private const val MINUTES_IN_DAY = 1_440 // 24 hours * 60 minutes +private const val MINUTES_IN_MONTH = 43_200 // 30 * MINUTES_IN_DAY + @Suppress("unused") enum class AvailabilityPeriodTimeUnit(val valueInMinutes: Int) { - DAYS(24 * 60), - MONTHS(30 * 24 * 60); + DAYS(MINUTES_IN_DAY), + MONTHS(MINUTES_IN_MONTH) } diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/AvailabilityPeriodType.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/AvailabilityPeriodType.kt index 8205950a0..a9f8571d2 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/AvailabilityPeriodType.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/enums/AvailabilityPeriodType.kt @@ -1,8 +1,12 @@ package com.ecwid.apiclient.v3.dto.profile.enums +private const val DAYS_IN_WEEK = 7 +private const val SINGLE_UNIT = 1 +private const val MONTHS_IN_CENTURY = 1200 + @Suppress("unused") enum class AvailabilityPeriodType(val unitCount: Int, val unit: AvailabilityPeriodTimeUnit?) { - SEVEN_DAYS(7, AvailabilityPeriodTimeUnit.DAYS), - ONE_MONTH(1, AvailabilityPeriodTimeUnit.MONTHS), - UNLIMITED(1200, AvailabilityPeriodTimeUnit.MONTHS); + SEVEN_DAYS(DAYS_IN_WEEK, AvailabilityPeriodTimeUnit.DAYS), + ONE_MONTH(SINGLE_UNIT, AvailabilityPeriodTimeUnit.MONTHS), + UNLIMITED(MONTHS_IN_CENTURY, AvailabilityPeriodTimeUnit.MONTHS) } From ce1efe12bcc9936c6a97193aebf2b266262460ef Mon Sep 17 00:00:00 2001 From: Roman Timchenko Date: Wed, 22 Jan 2025 10:14:19 +0400 Subject: [PATCH 5/7] ECWID-155668 Add "updateShippingOption" method to ecwid-java-api-client - (feat) replace FetchedStoreProfile.ShippingOption with new FetchedShippingOption --- .../dto/profile/result/FetchedStoreProfile.kt | 120 +----------------- .../profile/result/ShippingOptionsResult.kt | 2 +- .../jsontransformer/gson/GsonTransformer.kt | 2 +- .../RatesCalculationTypeDeserializer.kt | 2 +- .../FetchedStoreProfileRules.kt | 48 ------- 5 files changed, 4 insertions(+), 170 deletions(-) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedStoreProfile.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedStoreProfile.kt index 9b10e99dc..d5d9e6a7c 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedStoreProfile.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedStoreProfile.kt @@ -242,7 +242,7 @@ data class FetchedStoreProfile( data class Shipping( val handlingFee: HandlingFee? = null, val shippingOrigin: ShippingOrigin? = null, - val shippingOptions: List? = null + val shippingOptions: List? = null ) data class HandlingFee( @@ -262,43 +262,6 @@ data class FetchedStoreProfile( val phone: String? = null ) - data class ShippingOption( - val id: String? = null, - val title: String? = null, - val enabled: Boolean? = null, - val orderBy: Int? = null, - val fulfilmentType: FulfilmentType? = null, - val destinationZone: Zone? = null, - val deliveryTimeDays: String? = null, - val description: String? = null, - val carrier: String? = null, - val carrierMethods: List? = null, - val carrierSettings: CarrierSettings? = null, - val ratesCalculationType: RatesCalculationType? = null, - val shippingCostMarkup: Double? = null, - val flatRate: FlatRate? = null, - val ratesTable: TableRatesDetails? = null, - val appClientId: String? = null, - val locationId: String? = null, - val pickupInstruction: String? = null, - val scheduledPickup: Boolean? = null, - val pickupPreparationTimeHours: Int? = null, - val pickupBusinessHours: String? = null, - val scheduled: Boolean? = null, - val scheduledTimePrecisionType: ScheduledTimePrecisionType? = null, - ) - - @Suppress("unused") - enum class ScheduledTimePrecisionType { - DATE, - DATE_AND_TIME_SLOT - } - - @Suppress("unused") - enum class FulfilmentType { - pickup, shipping, delivery - } - data class Zone( val id: String? = null, val name: String? = null, @@ -307,87 +270,6 @@ data class FetchedStoreProfile( val postCodes: List? = null ) - data class CarrierMethod( - val id: String? = null, - val name: String? = null, - val enabled: Boolean? = null, - val orderBy: Int? = null - ) - - data class CarrierSettings( - val defaultCarrierAccountEnabled: Boolean? = null, - val defaultPostageDimensions: DefaultPostageDimensions? = null - ) - - data class DefaultPostageDimensions( - val length: Double? = null, - val width: Double? = null, - val height: Double? = null - ) - - @Suppress("unused") - enum class RatesCalculationType { - - carrier_calculated, - table, - flat, - app; - - override fun toString(): String { - return asApiString() - } - - fun asApiString(): String { - return super.toString().replace("_", "-") - } - } - - data class FlatRate( - val rateType: RateType? = null, - val rate: Double? = null - ) { - - @Suppress("unused") - enum class RateType { - ABSOLUTE, - PERCENT - } - } - - data class TableRatesDetails( - val tableBasedOn: RateBase? = null, - val rates: List? = null - ) { - - @Suppress("unused") - enum class RateBase { - subtotal, - discountedSubtotal, - weight - } - } - - data class TableRate( - val tableRateConditions: TableRateConditions? = null, - val rate: TableRateDetails? = null - ) - - data class TableRateConditions( - val weightFrom: Double? = null, - val weightTo: Double? = null, - val subtotalFrom: Double? = null, - val subtotalTo: Double? = null, - val discountedSubtotalFrom: Double? = null, - val discountedSubtotalTo: Double? = null - ) - - data class TableRateDetails( - val perOrderAbs: Double? = null, - val perOrderPercent: Double? = null, - val perItem: Double? = null, - val perWeightUnitRate: Double? = null - ) - data class TaxSettings( val automaticTaxEnabled: Boolean? = null, val taxes: List? = null, diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/ShippingOptionsResult.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/ShippingOptionsResult.kt index 993a93bdc..031308404 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/ShippingOptionsResult.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/ShippingOptionsResult.kt @@ -2,4 +2,4 @@ package com.ecwid.apiclient.v3.dto.profile.result import java.util.* -class ShippingOptionsResult : ArrayList() +class ShippingOptionsResult : ArrayList() diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/jsontransformer/gson/GsonTransformer.kt b/src/main/kotlin/com/ecwid/apiclient/v3/jsontransformer/gson/GsonTransformer.kt index 68b410e2c..44901888a 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/jsontransformer/gson/GsonTransformer.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/jsontransformer/gson/GsonTransformer.kt @@ -1,7 +1,7 @@ package com.ecwid.apiclient.v3.jsontransformer.gson import com.ecwid.apiclient.v3.dto.product.result.GetProductFiltersResult.ProductFilters -import com.ecwid.apiclient.v3.dto.profile.result.FetchedStoreProfile.RatesCalculationType +import com.ecwid.apiclient.v3.dto.profile.enums.RatesCalculationType import com.ecwid.apiclient.v3.exception.JsonDeserializationException import com.ecwid.apiclient.v3.impl.ParsedResponseWithExt import com.ecwid.apiclient.v3.jsontransformer.JsonTransformer diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/jsontransformer/gson/typeadapters/RatesCalculationTypeDeserializer.kt b/src/main/kotlin/com/ecwid/apiclient/v3/jsontransformer/gson/typeadapters/RatesCalculationTypeDeserializer.kt index 85cefa34c..bbb473bb8 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/jsontransformer/gson/typeadapters/RatesCalculationTypeDeserializer.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/jsontransformer/gson/typeadapters/RatesCalculationTypeDeserializer.kt @@ -1,6 +1,6 @@ package com.ecwid.apiclient.v3.jsontransformer.gson.typeadapters -import com.ecwid.apiclient.v3.dto.profile.result.FetchedStoreProfile.RatesCalculationType +import com.ecwid.apiclient.v3.dto.profile.enums.RatesCalculationType import com.google.gson.JsonDeserializationContext import com.google.gson.JsonDeserializer import com.google.gson.JsonElement diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedStoreProfileRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedStoreProfileRules.kt index b39b20bb1..b7b5987e5 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedStoreProfileRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedStoreProfileRules.kt @@ -37,12 +37,6 @@ val fetchedStoreProfileNullablePropertyRules: List> = IgnoreNullable(FetchedStoreProfile.ApplePay::verificationFileUrl), IgnoreNullable(FetchedStoreProfile.BusinessRegistrationID::name), IgnoreNullable(FetchedStoreProfile.BusinessRegistrationID::value), - IgnoreNullable(FetchedStoreProfile.CarrierMethod::enabled), - IgnoreNullable(FetchedStoreProfile.CarrierMethod::id), - IgnoreNullable(FetchedStoreProfile.CarrierMethod::name), - IgnoreNullable(FetchedStoreProfile.CarrierMethod::orderBy), - IgnoreNullable(FetchedStoreProfile.CarrierSettings::defaultCarrierAccountEnabled), - IgnoreNullable(FetchedStoreProfile.CarrierSettings::defaultPostageDimensions), IgnoreNullable(FetchedStoreProfile.Company::city), IgnoreNullable(FetchedStoreProfile.Company::companyName), IgnoreNullable(FetchedStoreProfile.Company::countryCode), @@ -51,9 +45,6 @@ val fetchedStoreProfileNullablePropertyRules: List> = IgnoreNullable(FetchedStoreProfile.Company::postalCode), IgnoreNullable(FetchedStoreProfile.Company::stateOrProvinceCode), IgnoreNullable(FetchedStoreProfile.Company::street), - IgnoreNullable(FetchedStoreProfile.DefaultPostageDimensions::height), - IgnoreNullable(FetchedStoreProfile.DefaultPostageDimensions::length), - IgnoreNullable(FetchedStoreProfile.DefaultPostageDimensions::width), AllowNullable(FetchedStoreProfile.DesignSettings::breadcrumbsHaveHomeItem), AllowNullable(FetchedStoreProfile.DesignSettings::breadcrumbsHomeUrl), AllowNullable(FetchedStoreProfile.DesignSettings::breadcrumbsSeparator), @@ -186,8 +177,6 @@ val fetchedStoreProfileNullablePropertyRules: List> = IgnoreNullable(FetchedStoreProfile.FeatureTogglesInfo::enabled), IgnoreNullable(FetchedStoreProfile.FeatureTogglesInfo::name), IgnoreNullable(FetchedStoreProfile.FeatureTogglesInfo::visible), - IgnoreNullable(FetchedStoreProfile.FlatRate::rate), - IgnoreNullable(FetchedStoreProfile.FlatRate::rateType), IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::currency), IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::currencyDecimalSeparator), IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::currencyGroupSeparator), @@ -310,29 +299,6 @@ val fetchedStoreProfileNullablePropertyRules: List> = IgnoreNullable(FetchedStoreProfile.Shipping::handlingFee), IgnoreNullable(FetchedStoreProfile.Shipping::shippingOptions), IgnoreNullable(FetchedStoreProfile.Shipping::shippingOrigin), - IgnoreNullable(FetchedStoreProfile.ShippingOption::appClientId), - IgnoreNullable(FetchedStoreProfile.ShippingOption::carrier), - IgnoreNullable(FetchedStoreProfile.ShippingOption::carrierMethods), - IgnoreNullable(FetchedStoreProfile.ShippingOption::carrierSettings), - IgnoreNullable(FetchedStoreProfile.ShippingOption::deliveryTimeDays), - IgnoreNullable(FetchedStoreProfile.ShippingOption::description), - IgnoreNullable(FetchedStoreProfile.ShippingOption::destinationZone), - IgnoreNullable(FetchedStoreProfile.ShippingOption::enabled), - IgnoreNullable(FetchedStoreProfile.ShippingOption::flatRate), - IgnoreNullable(FetchedStoreProfile.ShippingOption::fulfilmentType), - IgnoreNullable(FetchedStoreProfile.ShippingOption::id), - AllowNullable(FetchedStoreProfile.ShippingOption::locationId), - IgnoreNullable(FetchedStoreProfile.ShippingOption::orderBy), - IgnoreNullable(FetchedStoreProfile.ShippingOption::pickupBusinessHours), - IgnoreNullable(FetchedStoreProfile.ShippingOption::pickupInstruction), - IgnoreNullable(FetchedStoreProfile.ShippingOption::pickupPreparationTimeHours), - IgnoreNullable(FetchedStoreProfile.ShippingOption::ratesCalculationType), - IgnoreNullable(FetchedStoreProfile.ShippingOption::ratesTable), - IgnoreNullable(FetchedStoreProfile.ShippingOption::scheduledPickup), - IgnoreNullable(FetchedStoreProfile.ShippingOption::shippingCostMarkup), - IgnoreNullable(FetchedStoreProfile.ShippingOption::title), - AllowNullable(FetchedStoreProfile.ShippingOption::scheduled), - AllowNullable(FetchedStoreProfile.ShippingOption::scheduledTimePrecisionType), IgnoreNullable(FetchedStoreProfile.ShippingOrigin::city), IgnoreNullable(FetchedStoreProfile.ShippingOrigin::companyName), IgnoreNullable(FetchedStoreProfile.ShippingOrigin::countryCode), @@ -342,20 +308,6 @@ val fetchedStoreProfileNullablePropertyRules: List> = IgnoreNullable(FetchedStoreProfile.ShippingOrigin::stateOrProvinceCode), IgnoreNullable(FetchedStoreProfile.ShippingOrigin::street), AllowNullable(FetchedStoreProfile.ShippingSettings::enabledShippingMethods), - IgnoreNullable(FetchedStoreProfile.TableRate::rate), - IgnoreNullable(FetchedStoreProfile.TableRate::tableRateConditions), - IgnoreNullable(FetchedStoreProfile.TableRateConditions::discountedSubtotalFrom), - IgnoreNullable(FetchedStoreProfile.TableRateConditions::discountedSubtotalTo), - IgnoreNullable(FetchedStoreProfile.TableRateConditions::subtotalFrom), - IgnoreNullable(FetchedStoreProfile.TableRateConditions::subtotalTo), - IgnoreNullable(FetchedStoreProfile.TableRateConditions::weightFrom), - IgnoreNullable(FetchedStoreProfile.TableRateConditions::weightTo), - IgnoreNullable(FetchedStoreProfile.TableRateDetails::perItem), - IgnoreNullable(FetchedStoreProfile.TableRateDetails::perOrderAbs), - IgnoreNullable(FetchedStoreProfile.TableRateDetails::perOrderPercent), - IgnoreNullable(FetchedStoreProfile.TableRateDetails::perWeightUnitRate), - IgnoreNullable(FetchedStoreProfile.TableRatesDetails::rates), - IgnoreNullable(FetchedStoreProfile.TableRatesDetails::tableBasedOn), IgnoreNullable(FetchedStoreProfile.TaxSettings::automaticTaxEnabled), IgnoreNullable(FetchedStoreProfile.TaxSettings::pricesIncludeTax), IgnoreNullable(FetchedStoreProfile.TaxSettings::taxes), From 0d32e13c61af26548a974d9084c34522ba8ed78f Mon Sep 17 00:00:00 2001 From: Roman Timchenko Date: Wed, 22 Jan 2025 10:26:54 +0400 Subject: [PATCH 6/7] ECWID-155668 Add "updateShippingOption" method to ecwid-java-api-client - (feat) update count of nullable properties in tests --- src/test/kotlin/com/ecwid/apiclient/v3/DtoContractUnitTest.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/DtoContractUnitTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/DtoContractUnitTest.kt index 0505a327b..c5c7b28af 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/DtoContractUnitTest.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/DtoContractUnitTest.kt @@ -195,10 +195,11 @@ class DtoContractUnitTest { @Test @Order(5) fun `test no new exclusions added to file NullablePropertyRules`() { + val expectedNullablePropertiesCount = 931 val ignoreNullablePropertiesCount = nullablePropertyRules .filterIsInstance>() .size - assertEquals(976, ignoreNullablePropertiesCount) { + assertEquals(expectedNullablePropertiesCount, ignoreNullablePropertiesCount) { "You MUST NOT add exclusion with type IgnoreNullable() which is used only for old fields until they are fixed.\n" + "Please make added property non-nullable if possible.\n" + "If Ecwid API sometimes return null as value for this property you CAN add it to as `AllowNullable()` exclusion type instead." From 31cae48556d98abcfa14fe1c284f6175a8da3532 Mon Sep 17 00:00:00 2001 From: Roman Timchenko Date: Wed, 22 Jan 2025 11:19:14 +0400 Subject: [PATCH 7/7] ECWID-155668 Add "updateShippingOption" method to ecwid-java-api-client - (refactor) replace typealias with string --- .../apiclient/v3/dto/profile/request/UpdatedShippingOption.kt | 4 +--- .../apiclient/v3/dto/profile/result/FetchedShippingOption.kt | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdatedShippingOption.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdatedShippingOption.kt index 7533f00b2..3ebd20ad6 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdatedShippingOption.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdatedShippingOption.kt @@ -31,7 +31,7 @@ data class UpdatedShippingOption( val carrier: String? = null, val carrierMethods: List? = null, val carrierSettings: CarrierSettings? = null, - val businessHours: BusinessHours? = null, + val businessHours: String? = null, val businessHoursLimitationType: ApiBusinessHoursLimitationType? = null, val allowSameDayDelivery: Boolean? = null, val deliveryTimeDays: String? = null, @@ -121,5 +121,3 @@ data class UpdatedShippingOption( return ApiUpdatedDTO.ModifyKind.ReadWrite(FetchedShippingOption::class) } } - -typealias BusinessHours = Map>> diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedShippingOption.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedShippingOption.kt index 78e487963..caf93309e 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedShippingOption.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedShippingOption.kt @@ -31,7 +31,7 @@ data class FetchedShippingOption( val carrier: String? = null, val carrierMethods: List? = null, val carrierSettings: CarrierSettings? = null, - val businessHours: BusinessHours? = null, + val businessHours: String? = null, val businessHoursLimitationType: ApiBusinessHoursLimitationType? = null, val allowSameDayDelivery: Boolean? = null, val deliveryTimeDays: String? = null, @@ -122,5 +122,3 @@ data class FetchedShippingOption( return ApiFetchedDTO.ModifyKind.ReadWrite(UpdatedShippingOption::class) } } - -typealias BusinessHours = Map>>