From 2976d8191bb721d4aae6158a199c195c4ef10cb2 Mon Sep 17 00:00:00 2001 From: Roman Timchenko Date: Tue, 14 Jan 2025 15:50:57 +0400 Subject: [PATCH 1/4] ECWID-155655 - (feat) add new format of snapshots' sanitized versions for devs --- .github/workflows/pull-request.yml | 5 ++++- build.gradle.kts | 27 +++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 40a11e269..9ab6d2c29 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -24,7 +24,9 @@ jobs: cache: 'gradle' - name: Build, run tests and upload dev snapshot to Maven Central with Gradle - run: ./gradlew devSnapshot printDevSnapshotReleaseNote + run: | + ./gradlew devSnapshot printDevSnapshotReleaseNote printSanitizedVersion + cat sanitized_version.md >> $GITHUB_STEP_SUMMARY env: STORE_ID: ${{ secrets.STORE_ID }} API_TOKEN: ${{ secrets.API_TOKEN }} @@ -34,6 +36,7 @@ jobs: OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} GITHUB_HEAD_REF: ${{ github.head_ref }} + GITHUB_HEAD_SHA: ${{ github.event.pull_request.head.sha }} - name: Upload artifacts with checks results uses: actions/upload-artifact@v3 diff --git a/build.gradle.kts b/build.gradle.kts index 6bd6ee04e..8b53b2a42 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -127,6 +127,12 @@ tasks.register(Tasks.PRINT_DEV_SNAPSHOT_RELEASE_NOTE_TASK_NAME) { dependsOn(tasks.getByName("devSnapshot")) } +tasks.register(Tasks.PRINT_SUMMARY_SANITIZED_TASK_NAME) { + doLast { + printSanitizedVersion(project.sanitizeVersion()) + } +} + detekt { allRules = false basePath = "$projectDir" @@ -210,15 +216,16 @@ nexusPublishing { // ..-dev.#+. (local branch) // ..-dev.#+ (github pull request) // to: -// ..-dev+-SNAPSHOT +// ..-dev+_-SNAPSHOT fun Project.sanitizeVersion(): String { val version = version.toString() return if (project.isSnapshotVersion()) { val githubHeadRef = settingsProvider.githubHeadRef + val githubHeadSHA = settingsProvider.githubHeadSHA?.take(Consts.MAX_HEAD_SHA_LENGTH) if (githubHeadRef != null) { // github pull request version - .replace(Regex("-dev\\.\\d+\\+[a-f0-9]+$"), "-dev+$githubHeadRef-SNAPSHOT") + .replace(Regex("-dev\\.\\d+\\+[a-f0-9]+$"), "-dev+${githubHeadRef}_$githubHeadSHA-SNAPSHOT") } else { // local branch version @@ -273,6 +280,16 @@ fun printDevSnapshotReleaseNote(groupId: String, artifactId: String, sanitizedVe println() } +fun printSanitizedVersion(sanitizedVersion: String) { + val markdownMessage = """ + |## Sanitized Version + | + |**Version:** $sanitizedVersion + | + """.trimMargin() + File("sanitized_version.md").writeText(markdownMessage) +} + class SettingsProvider { val gpgSigningKey: String? @@ -290,6 +307,9 @@ class SettingsProvider { val githubHeadRef: String? get() = System.getenv(GITHUB_HEAD_REF_PROPERTY) + val githubHeadSHA: String? + get() = System.getenv(GITHUB_HEAD_SHA_PROPERTY) + fun validateGPGSecrets() = require( value = !gpgSigningKey.isNullOrBlank() && !gpgSigningPassword.isNullOrBlank(), lazyMessage = { @@ -310,6 +330,7 @@ class SettingsProvider { private const val OSSRH_USERNAME_PROPERTY = "OSSRH_USERNAME" private const val OSSRH_PASSWORD_PROPERTY = "OSSRH_PASSWORD" private const val GITHUB_HEAD_REF_PROPERTY = "GITHUB_HEAD_REF" + private const val GITHUB_HEAD_SHA_PROPERTY = "GITHUB_HEAD_SHA" } } @@ -339,9 +360,11 @@ object PublicationSettings { object Consts { const val SLOW_TESTS_LOGGING_THRESHOLD_MS = 30_000L const val MAX_TEST_RETRIES_COUNT = 3 + const val MAX_HEAD_SHA_LENGTH = 8 } object Tasks { const val PRINT_FINAL_RELEASE_NOTE_TASK_NAME = "printFinalReleaseNote" const val PRINT_DEV_SNAPSHOT_RELEASE_NOTE_TASK_NAME = "printDevSnapshotReleaseNote" + const val PRINT_SUMMARY_SANITIZED_TASK_NAME = "printDevSanitizedVersion" } From 24fb42d0f03014d096bab00580bda0593342fa67 Mon Sep 17 00:00:00 2001 From: Roman Timchenko Date: Wed, 15 Jan 2025 13:39:49 +0400 Subject: [PATCH 2/4] ECWID-155655 - (fix) fix tests --- src/test/kotlin/com/ecwid/apiclient/v3/entity/CategoriesTest.kt | 2 +- src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductsTest.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/CategoriesTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/CategoriesTest.kt index ad1a023c7..661d03ea6 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/CategoriesTest.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/entity/CategoriesTest.kt @@ -179,7 +179,7 @@ class CategoriesTest : BaseEntityTest() { // Searching categories with different combinations of baseUrl and cleanUrls parameters assertCategoryUrlMatchesRegex( categorySearchRequest = CategoriesSearchRequest(), - urlPattern = "https://.*.company.site.*/products#!/Category-.*c.*" + urlPattern = "https://.*.company.site.*/products/Category-.*c.*" ) assertCategoryUrlMatchesRegex( categorySearchRequest = CategoriesSearchRequest( diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductsTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductsTest.kt index d97f608db..6dd92a0da 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductsTest.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductsTest.kt @@ -242,7 +242,7 @@ class ProductsTest : BaseEntityTest() { // Searching products with different combinations of baseUrl and cleanUrls parameters assertProductUrlMatchesRegex( productSearchRequest = ByFilters(keyword = productCreateRequest.newProduct.sku), - urlPattern = "https://.*.company.site.*/products#!/Product-.*p.*" + urlPattern = "https://.*.company.site.*/products/Product-.*p.*" ) assertProductUrlMatchesRegex( productSearchRequest = ByFilters( From 31a86ecce34d3c20c967c228851b75c859d89751 Mon Sep 17 00:00:00 2001 From: Roman Timchenko Date: Thu, 16 Jan 2025 13:07:30 +0400 Subject: [PATCH 3/4] ECWID-155668 Add "updateShippingOption" method to ecwid-java-api-client - (feat) make updateShippingOption available in the API client --- .../apiclient/v3/StoreProfileApiClient.kt | 2 +- .../request/ShippingOptionUpdateRequest.kt | 21 +++++ .../profile/request/UpdatedShippingOption.kt | 78 +++++++++++++++++++ .../dto/profile/result/FetchedStoreProfile.kt | 7 +- .../result/ShippingOptionUpdateResult.kt | 7 ++ .../v3/impl/StoreProfileApiClientImpl.kt | 3 + 6 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/ShippingOptionUpdateRequest.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/ShippingOptionUpdateResult.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..6abbaa2a8 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: ShippingOptionUpdateRequest): ShippingOptionUpdateResult 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/ShippingOptionUpdateRequest.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/ShippingOptionUpdateRequest.kt new file mode 100644 index 000000000..1ae2146ea --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/ShippingOptionUpdateRequest.kt @@ -0,0 +1,21 @@ +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 ShippingOptionUpdateRequest( + val optionId: String = "", + val updatedShippingOption: UpdatedShippingOption = UpdatedShippingOption() +) : ApiRequest { + override fun toRequestInfo() = RequestInfo.createPutRequest( + pathSegments = listOf( + "profile", + "shippingOptions", + optionId, + ), + httpBody = HttpBody.JsonBody( + obj = updatedShippingOption + ) + ) +} 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..e193a9659 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdatedShippingOption.kt @@ -0,0 +1,78 @@ +package com.ecwid.apiclient.v3.dto.profile.request + +import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO +import com.ecwid.apiclient.v3.dto.profile.result.FetchedStoreProfile +import java.util.* + +data class UpdatedShippingOption( + val title: String? = null, + val enabled: Boolean? = null, + val orderBy: Int? = null, + val destinationZone: Zone? = null, + val businessHours: String? = null, + val businessHoursLimitationType: String? = null, + val blackoutDates: List? = null, + val scheduled: Boolean? = null, + val scheduledPickup: Boolean? = null, + val fulfillmentTimeInMinutes: Int? = null, + val scheduledTimePrecisionType: String? = null, + val deliveryTimeDays: String? = null, + val timeSlotLengthInMinutes: Int? = null, + val allowSameDayDelivery: Boolean? = null, + val cutoffTimeForSameDayDelivery: String? = null, + val availabilityPeriod: String? = null, + val pickupInstruction: String? = null, + val description: String? = null, + val pickupPreparationTimeHours: Int? = null, + val pickupBusinessHours: String? = null, + val minimumOrderSubtotal: Int? = null, + val flatRate: FlatRate? = null, + val ratesTable: TableRatesDetails? = null, + val estimatedShippingTimeAtCheckoutSettings: EstimatedShippingTimeAtCheckoutSettings? = null, + val details: Details? = null, +) : ApiUpdatedDTO { + override fun getModifyKind(): ApiUpdatedDTO.ModifyKind { + return ApiUpdatedDTO.ModifyKind.ReadWrite(FetchedStoreProfile.ShippingOption::class) + } +} + +data class Zone( + val name: String? = null, + val countryCodes: List? = null, + val stateOrProvinceCodes: List? = null, + val postCodes: List? = null, + val geoPolygons: List? = null, +) + +data class GeoPolygons( + val coordinates: List>? = null, +) + +data class BlackoutDates( + var fromDate: Date? = null, + var toDate: Date? = null, + var repeatedAnnually: Boolean? = null, +) + +data class FlatRate( + val rateType: String? = null, + val rate: Double? = null, +) + +data class TableRatesDetails( + val tableBasedOn: String? = null, + val rates: String? = null, +) + +data class EstimatedShippingTimeAtCheckoutSettings( + val estimatedDeliveryDateAtCheckoutEnabled: Boolean? = null, + val estimatedTransitTimeInDays: List? = null, + val fulfillmentTimeInDays: Int? = null, + val cutoffTimeForSameDayPacking: String? = null, + val shippingBusinessDays: List? = null, + val deliveryDays: List? = null, +) + +data class Details( + val useDefaultAccount: Boolean? = null, +) 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..47c0bb9bb 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 @@ -7,6 +7,7 @@ import com.ecwid.apiclient.v3.dto.common.LocalizedValueMap import com.ecwid.apiclient.v3.dto.common.ProductCondition import com.ecwid.apiclient.v3.dto.profile.enums.ProductFilterType import com.ecwid.apiclient.v3.dto.profile.request.UpdatedPaymentOption +import com.ecwid.apiclient.v3.dto.profile.request.UpdatedShippingOption import com.ecwid.apiclient.v3.dto.profile.request.UpdatedStoreProfile import com.ecwid.apiclient.v3.jsontransformer.JsonFieldName import java.util.* @@ -286,7 +287,11 @@ data class FetchedStoreProfile( val pickupBusinessHours: String? = null, val scheduled: Boolean? = null, val scheduledTimePrecisionType: ScheduledTimePrecisionType? = null, - ) + ) : ApiFetchedDTO { + override fun getModifyKind(): ModifyKind { + return ModifyKind.ReadWrite(UpdatedShippingOption::class) + } + } @Suppress("unused") enum class ScheduledTimePrecisionType { diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/ShippingOptionUpdateResult.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/ShippingOptionUpdateResult.kt new file mode 100644 index 000000000..20bfaa7e9 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/ShippingOptionUpdateResult.kt @@ -0,0 +1,7 @@ +package com.ecwid.apiclient.v3.dto.profile.result + +import com.ecwid.apiclient.v3.dto.common.ApiResultDTO + +data class ShippingOptionUpdateResult( + val success: Boolean = true +) : 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..9367fbb31 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: ShippingOptionUpdateRequest): ShippingOptionUpdateResult = + apiClientHelper.makeObjectResultRequest(request) + override fun getPaymentOptions(request: PaymentOptionsRequest): PaymentOptionsResult = apiClientHelper.makeObjectResultRequest(request) From f58afe4ed5d603bd592d62de4bdfd97e1e9bb8c2 Mon Sep 17 00:00:00 2001 From: Roman Timchenko Date: Thu, 16 Jan 2025 14:54:04 +0400 Subject: [PATCH 4/4] ECWID-155668 Add "updateShippingOption" method to ecwid-java-api-client - (fix) fix issues in DTOs for val and nullable parameters testing --- .../v3/dto/profile/request/UpdatedShippingOption.kt | 7 ++++--- .../apiclient/v3/dto/profile/result/FetchedStoreProfile.kt | 7 ++++++- .../rule/nullablepropertyrules/FetchedStoreProfileRules.kt | 2 ++ 3 files changed, 12 insertions(+), 4 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 e193a9659..bdedc5d31 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 @@ -37,6 +37,7 @@ data class UpdatedShippingOption( } data class Zone( + val id: String? = null, val name: String? = null, val countryCodes: List? = null, val stateOrProvinceCodes: List? = null, @@ -49,9 +50,9 @@ data class GeoPolygons( ) data class BlackoutDates( - var fromDate: Date? = null, - var toDate: Date? = null, - var repeatedAnnually: Boolean? = null, + val fromDate: Date? = null, + val toDate: Date? = null, + val repeatedAnnually: Boolean? = null, ) data class FlatRate( 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 47c0bb9bb..3fe4663f3 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 @@ -309,7 +309,12 @@ data class FetchedStoreProfile( val name: String? = null, val countryCodes: List? = null, val stateOrProvinceCodes: List? = null, - val postCodes: List? = null + val postCodes: List? = null, + val geoPolygons: List? = null, + ) + + data class GeoPolygons( + val coordinates: List>? = null, ) data class CarrierMethod( 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..41052b7a0 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 @@ -212,6 +212,7 @@ val fetchedStoreProfileNullablePropertyRules: List> = IgnoreNullable(FetchedStoreProfile.GeneralInfo::starterSite), IgnoreNullable(FetchedStoreProfile.GeneralInfo::storeUrl), IgnoreNullable(FetchedStoreProfile.GeneralInfo::websitePlatform), + AllowNullable(FetchedStoreProfile.GeoPolygons::coordinates), IgnoreNullable(FetchedStoreProfile.GiftCardProducts::id), IgnoreNullable(FetchedStoreProfile.GiftCardProducts::name), IgnoreNullable(FetchedStoreProfile.GiftCardProducts::url), @@ -376,6 +377,7 @@ val fetchedStoreProfileNullablePropertyRules: List> = IgnoreNullable(FetchedStoreProfile.Zone::name), IgnoreNullable(FetchedStoreProfile.Zone::postCodes), IgnoreNullable(FetchedStoreProfile.Zone::stateOrProvinceCodes), + AllowNullable(FetchedStoreProfile.Zone::geoPolygons), AllowNullable(FetchedStoreProfile.Settings::googleProductCategory), AllowNullable(FetchedStoreProfile.Settings::googleProductCategoryName), AllowNullable(FetchedStoreProfile.InstantSiteInfo::ecwidSubdomainSuffix),