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" } 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..bdedc5d31 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdatedShippingOption.kt @@ -0,0 +1,79 @@ +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 id: String? = null, + 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( + val fromDate: Date? = null, + val toDate: Date? = null, + val 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..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 @@ -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 { @@ -304,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/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) 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( 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),