Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class BookingsRestClient @Inject constructor(
site: SiteModel,
resourceId: Long
): WooPayload<BookingResourceDto> {
val endpoint = WOOCOMMERCE.resources.id(resourceId).pathV2Bookings
val endpoint = WOOCOMMERCE.resources.team_members.id(resourceId).pathV2Bookings

val response = wooNetwork.executeGetGsonRequest(
site = site,
Expand All @@ -90,7 +90,7 @@ class BookingsRestClient @Inject constructor(
BookingsFilterOption.AttendanceStatus -> TODO()
BookingsFilterOption.PaymentStatus -> TODO()
BookingsFilterOption.BookingType -> TODO()
is BookingsFilterOption.Customer -> filter.customerId?.let { set("customer", it.toString()) }
is BookingsFilterOption.Customer -> set("customer", filter.customerId.toString())

BookingsFilterOption.Location -> TODO()
is BookingsFilterOption.DateRange -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,16 @@ class BookingsStore @Inject internal constructor(
response.isError -> WooResult(response.error)
response.result != null -> {
val bookingDto = response.result
val orderResult = orderStore.fetchSingleOrderSync(site, bookingDto.orderId)
if (orderResult.isError) {
val orderResult = bookingDto.orderId.takeIf { it != 0L }?.let {
orderStore.fetchSingleOrderSync(site, bookingDto.orderId)
}
if (orderResult?.isError == true) {
return@withDefaultContext WooResult(orderResult.error)
}
val entity = with(bookingDtoMapper) {
bookingDto.toEntity(
localSiteId = site.localId(),
orderEntity = orderResult.model,
orderEntity = orderResult?.model,
)
}
bookingsDao.insertOrReplace(listOf(entity))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@

/bookings
/bookings/<id>/
/resources/<id>/
/resources/team-members/<id>/
Loading