From 88e44c847c2172174ad3b4435c2d7c8ca78012d6 Mon Sep 17 00:00:00 2001 From: Mohammad Dwairi <49045447+Mohammad-Dwairi@users.noreply.github.com> Date: Wed, 6 Nov 2024 18:15:40 +0300 Subject: [PATCH] fix: rebuild SDK with latest schema changes (#90) --- README.md | 4 +- code/src/main/graphql | 2 +- .../supply/reservation/ReservationClient.kt | 29 --------- .../GetPropertyReservationsSummaryFun.kt | 61 ------------------- .../PropertyReservationsSummaryPaginator.kt | 46 -------------- gradle.properties | 2 +- 6 files changed, 4 insertions(+), 140 deletions(-) delete mode 100644 code/src/main/kotlin/com/expediagroup/sdk/lodgingconnectivity/graphql/supply/reservation/function/GetPropertyReservationsSummaryFun.kt delete mode 100644 code/src/main/kotlin/com/expediagroup/sdk/lodgingconnectivity/graphql/supply/reservation/paginator/PropertyReservationsSummaryPaginator.kt diff --git a/README.md b/README.md index 0ceaba26..7e593e23 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Make sure you have **Java 8** or higher. ```groovy // gradle.build dependencies { - implementation 'com.expediagroup:lodging-connectivity-sdk:1.0.5-SNAPSHOT' + implementation 'com.expediagroup:lodging-connectivity-sdk:1.0.6-SNAPSHOT' } ``` @@ -29,7 +29,7 @@ dependencies { com.expediagroup lodging-connectivity-sdk - 1.0.5-SNAPSHOT + 1.0.6-SNAPSHOT ``` diff --git a/code/src/main/graphql b/code/src/main/graphql index dfb6bd11..3242e651 160000 --- a/code/src/main/graphql +++ b/code/src/main/graphql @@ -1 +1 @@ -Subproject commit dfb6bd11798f85ff0510549b630afdf260f7c846 +Subproject commit 3242e651bda1be615ce9ebb33cd717c3f6fcf7f1 diff --git a/code/src/main/kotlin/com/expediagroup/sdk/lodgingconnectivity/graphql/supply/reservation/ReservationClient.kt b/code/src/main/kotlin/com/expediagroup/sdk/lodgingconnectivity/graphql/supply/reservation/ReservationClient.kt index 5814a80a..0b82dddf 100644 --- a/code/src/main/kotlin/com/expediagroup/sdk/lodgingconnectivity/graphql/supply/reservation/ReservationClient.kt +++ b/code/src/main/kotlin/com/expediagroup/sdk/lodgingconnectivity/graphql/supply/reservation/ReservationClient.kt @@ -26,7 +26,6 @@ import com.expediagroup.sdk.lodgingconnectivity.graphql.supply.reservation.funct import com.expediagroup.sdk.lodgingconnectivity.graphql.supply.reservation.function.confirmReservationNotificationFun import com.expediagroup.sdk.lodgingconnectivity.graphql.supply.reservation.function.refundReservationFun import com.expediagroup.sdk.lodgingconnectivity.graphql.supply.reservation.paginator.PropertyReservationsPaginator -import com.expediagroup.sdk.lodgingconnectivity.graphql.supply.reservation.paginator.PropertyReservationsSummariesPaginator import com.expediagroup.sdk.lodgingconnectivity.graphql.supply.type.CancelReservationInput import com.expediagroup.sdk.lodgingconnectivity.graphql.supply.type.CancelReservationReconciliationInput import com.expediagroup.sdk.lodgingconnectivity.graphql.supply.type.CancelVrboReservationInput @@ -128,34 +127,6 @@ class ReservationClient(config: ClientConfiguration) { ) } - @JvmOverloads - fun getPropertyReservationsSummary( - propertyId: String, - pageSize: Int? = null, - initialCursor: String? = null - ) = run { - PropertyReservationsSummariesPaginator( - client = baseGraphQlClient, - input = PropertyReservationsInput(propertyId), - pageSize = pageSize, - initialCursor = initialCursor - ) - } - - @JvmOverloads - fun getPropertyReservationsSummary( - input: PropertyReservationsInput, - pageSize: Int? = null, - initialCursor: String? = null - ) = run { - PropertyReservationsSummariesPaginator( - client = baseGraphQlClient, - input = input, - pageSize = pageSize, - initialCursor = initialCursor - ) - } - @JvmOverloads fun cancelReservation( input: CancelReservationInput, diff --git a/code/src/main/kotlin/com/expediagroup/sdk/lodgingconnectivity/graphql/supply/reservation/function/GetPropertyReservationsSummaryFun.kt b/code/src/main/kotlin/com/expediagroup/sdk/lodgingconnectivity/graphql/supply/reservation/function/GetPropertyReservationsSummaryFun.kt deleted file mode 100644 index 46017ee5..00000000 --- a/code/src/main/kotlin/com/expediagroup/sdk/lodgingconnectivity/graphql/supply/reservation/function/GetPropertyReservationsSummaryFun.kt +++ /dev/null @@ -1,61 +0,0 @@ -package com.expediagroup.sdk.lodgingconnectivity.graphql.supply.reservation.function - -import com.expediagroup.sdk.core.model.exception.service.ExpediaGroupServiceException -import com.expediagroup.sdk.lodgingconnectivity.graphql.GraphQLExecutor -import com.expediagroup.sdk.lodgingconnectivity.graphql.extension.getOrThrow -import com.expediagroup.sdk.lodgingconnectivity.graphql.extension.orNullIfBlank -import com.expediagroup.sdk.lodgingconnectivity.graphql.model.paging.PageInfo -import com.expediagroup.sdk.lodgingconnectivity.graphql.model.response.PaginatedResponse -import com.expediagroup.sdk.lodgingconnectivity.graphql.model.response.RawResponse -import com.expediagroup.sdk.lodgingconnectivity.graphql.supply.PropertyReservationsSummaryQuery -import com.expediagroup.sdk.lodgingconnectivity.graphql.supply.fragment.ReservationSummaryData -import com.expediagroup.sdk.lodgingconnectivity.graphql.supply.reservation.constant.Constant -import com.expediagroup.sdk.lodgingconnectivity.graphql.supply.type.PropertyReservationsInput - -data class ReservationsSummaryResponse( - override val data: List, - override val rawResponse: RawResponse, - override val pageInfo: PageInfo, -) : PaginatedResponse, PropertyReservationsSummaryQuery.Data> - -@JvmOverloads -fun getPropertyReservationsSummaryFun( - client: GraphQLExecutor, - input: PropertyReservationsInput, - cursor: String? = null, - pageSize: Int? = null -): ReservationsSummaryResponse { - val operation = PropertyReservationsSummaryQuery - .Builder() - .propertyId(input.propertyId) - .idSource(input.idSource.getOrNull()) - .pageSize(pageSize ?: Constant.RESERVATIONS_DEFAULT_PAGE_SIZE) - .cursor(cursor) - .filter(input.filter.getOrNull()) - .checkOutDate(input.checkOutDate.getOrNull()) - .build() - - val response = client.execute(operation) - - val property = response.data.property.getOrThrow { - ExpediaGroupServiceException("Failed to fetch property ${input.propertyId}") - } - - val reservationsPage = property.reservations - - val nextPageInfo = reservationsPage.pageInfo - - val currentPageInfo = PageInfo( - cursor = cursor, - nextPageCursor = nextPageInfo?.endCursor?.orNullIfBlank(), - hasNext = nextPageInfo?.hasNextPage ?: false, - pageSize = reservationsPage.edges.size, - totalCount = reservationsPage.totalCount - ) - - return ReservationsSummaryResponse( - data = reservationsPage.edges.map { edgeOptional -> edgeOptional?.node?.reservationSummaryData }, - rawResponse = response, - pageInfo = currentPageInfo - ) -} diff --git a/code/src/main/kotlin/com/expediagroup/sdk/lodgingconnectivity/graphql/supply/reservation/paginator/PropertyReservationsSummaryPaginator.kt b/code/src/main/kotlin/com/expediagroup/sdk/lodgingconnectivity/graphql/supply/reservation/paginator/PropertyReservationsSummaryPaginator.kt deleted file mode 100644 index 1c764f42..00000000 --- a/code/src/main/kotlin/com/expediagroup/sdk/lodgingconnectivity/graphql/supply/reservation/paginator/PropertyReservationsSummaryPaginator.kt +++ /dev/null @@ -1,46 +0,0 @@ -package com.expediagroup.sdk.lodgingconnectivity.graphql.supply.reservation.paginator - -import com.expediagroup.sdk.lodgingconnectivity.graphql.GraphQLExecutor -import com.expediagroup.sdk.lodgingconnectivity.graphql.model.paging.PageInfo -import com.expediagroup.sdk.lodgingconnectivity.graphql.model.response.PaginatedResponse -import com.expediagroup.sdk.lodgingconnectivity.graphql.model.response.RawResponse -import com.expediagroup.sdk.lodgingconnectivity.graphql.supply.PropertyReservationsSummaryQuery -import com.expediagroup.sdk.lodgingconnectivity.graphql.supply.fragment.ReservationSummaryData -import com.expediagroup.sdk.lodgingconnectivity.graphql.supply.reservation.function.getPropertyReservationsSummaryFun -import com.expediagroup.sdk.lodgingconnectivity.graphql.supply.type.PropertyReservationsInput - -data class ReservationsSummaryPaginatedResponse( - override val data: List, - override val rawResponse: RawResponse, - override val pageInfo: PageInfo, -) : PaginatedResponse, PropertyReservationsSummaryQuery.Data> - -class PropertyReservationsSummariesPaginator( - private val client: GraphQLExecutor, - private val input: PropertyReservationsInput, - private val pageSize: Int? = null, - initialCursor: String? = null -) : Iterator { - private var cursor: String? = initialCursor - private var hasNext: Boolean = true - - override fun hasNext(): Boolean = hasNext - - override fun next(): ReservationsSummaryPaginatedResponse { - val response = getPropertyReservationsSummaryFun( - client = client, - input = input, - cursor = cursor, - pageSize = pageSize - ) - - cursor = response.pageInfo.nextPageCursor - hasNext = response.pageInfo.hasNext - - return ReservationsSummaryPaginatedResponse( - data = response.data, - pageInfo = response.pageInfo, - rawResponse = response.rawResponse, - ) - } -} diff --git a/gradle.properties b/gradle.properties index 3166fba0..dd8aa840 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ kotlin.code.style=official groupId=com.expediagroup -version=1.0.5-SNAPSHOT +version=1.0.6-SNAPSHOT artifactName=lodging-connectivity-sdk description=SDK for Lodging Connectivity APIs