Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ecwid 142216 #420

Merged
merged 5 commits into from
Jul 9, 2024
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
17 changes: 0 additions & 17 deletions src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -136,23 +136,6 @@ open class ApiClient private constructor(
}
}

// Orders
// https://developers.ecwid.com/api-documentation/orders
interface OrdersApiClient {
fun searchOrders(request: OrdersSearchRequest): OrdersSearchResult
fun searchOrdersAsSequence(request: OrdersSearchRequest): Sequence<FetchedOrder>
fun getOrderDetails(request: OrderDetailsRequest): FetchedOrder
fun getOrderInvoice(request: OrderInvoiceRequest): String
fun createOrder(request: OrderCreateRequest): OrderCreateResult
fun updateOrder(request: OrderUpdateRequest): OrderUpdateResult
fun deleteOrder(request: OrderDeleteRequest): OrderDeleteResult
fun uploadOrderItemOptionFile(request: OrderItemOptionFileUploadRequest): OrderItemOptionFileUploadResult
fun deleteOrderItemOptionFile(request: OrderItemOptionFileDeleteRequest): OrderItemOptionFileDeleteResult
fun deleteOrderItemOptionFiles(request: OrderItemOptionFilesDeleteRequest): OrderItemOptionFileDeleteResult
fun searchDeletedOrders(request: DeletedOrdersSearchRequest): DeletedOrdersSearchResult
fun searchDeletedOrdersAsSequence(request: DeletedOrdersSearchRequest): Sequence<DeletedOrder>
}

// Product types
// https://developers.ecwid.com/api-documentation/product-types
interface ProductTypesApiClient {
Expand Down
30 changes: 30 additions & 0 deletions src/main/kotlin/com/ecwid/apiclient/v3/OrdersApiClient.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.ecwid.apiclient.v3

import com.ecwid.apiclient.v3.dto.common.PartialResult
import com.ecwid.apiclient.v3.dto.order.request.*
import com.ecwid.apiclient.v3.dto.order.result.*
import kotlin.reflect.KClass

// Orders
// https://developers.ecwid.com/api-documentation/orders
interface OrdersApiClient {
fun searchOrders(request: OrdersSearchRequest): OrdersSearchResult
fun <Result> searchOrders(request: OrdersSearchRequest, resultClass: KClass<Result>): Result
where Result : PartialResult<OrdersSearchResult>
fun searchOrdersAsSequence(request: OrdersSearchRequest): Sequence<FetchedOrder>
fun getOrderDetails(request: OrderDetailsRequest): FetchedOrder
fun getOrderInvoice(request: OrderInvoiceRequest): String
fun createOrder(request: OrderCreateRequest): OrderCreateResult
fun updateOrder(request: OrderUpdateRequest): OrderUpdateResult
fun deleteOrder(request: OrderDeleteRequest): OrderDeleteResult
fun uploadOrderItemOptionFile(request: OrderItemOptionFileUploadRequest): OrderItemOptionFileUploadResult
fun deleteOrderItemOptionFile(request: OrderItemOptionFileDeleteRequest): OrderItemOptionFileDeleteResult
fun deleteOrderItemOptionFiles(request: OrderItemOptionFilesDeleteRequest): OrderItemOptionFileDeleteResult
fun searchDeletedOrders(request: DeletedOrdersSearchRequest): DeletedOrdersSearchResult
fun searchDeletedOrdersAsSequence(request: DeletedOrdersSearchRequest): Sequence<DeletedOrder>
}

@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
inline fun <reified Result : PartialResult<OrdersSearchResult>> OrdersApiClient.searchOrders(request: OrdersSearchRequest): Result {
return searchOrders(request, Result::class)
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ interface StoreProfileApiClient {
fun updateExtrafieldConfig(request: ExtrafieldConfigUpdateRequest): ExtrafieldConfigUpdateResult
fun deleteExtrafieldConfig(request: ExtrafieldConfigDeleteRequest): ExtrafieldConfigDeleteResult
fun searchOrderStatusesSettings(request: OrderStatusSettingsSearchRequest): OrderStatusSettingsSearchResult
fun <Result> searchOrderStatusesSettings(request: OrderStatusSettingsSearchRequest, resultClass: KClass<Result>): Result
where Result : PartialResult<OrderStatusSettingsSearchResult>
fun getOrderStatusSettingsDetails(request: OrderStatusSettingsDetailsRequest): FetchedOrderStatusSettings
fun updateOrderStatusSettings(request: OrderStatusSettingsUpdateRequest): OrderStatusSettingsUpdateResult
}
Expand All @@ -43,3 +45,8 @@ interface StoreProfileApiClient {
inline fun <reified Result : PartialResult<FetchedStoreProfile>> StoreProfileApiClient.getStoreProfile(request: StoreProfileRequest): Result {
return getStoreProfile(request, Result::class)
}

@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
inline fun <reified Result : PartialResult<OrderStatusSettingsSearchResult>> StoreProfileApiClient.searchOrderStatusesSettings(request: OrderStatusSettingsSearchRequest): Result {
return searchOrderStatusesSettings(request, Result::class)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ecwid.apiclient.v3.dto.order.result

import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO
import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO.ModifyKind
import com.ecwid.apiclient.v3.dto.common.ApiResultDTO
import com.ecwid.apiclient.v3.dto.common.ExtendedOrderTax
import com.ecwid.apiclient.v3.dto.common.OrderedStringToListStringMap
import com.ecwid.apiclient.v3.dto.common.OrderedStringToStringMap
Expand Down Expand Up @@ -119,7 +120,7 @@ data class FetchedOrder(
val loyalty: Loyalty? = null,
val customerFiscalCode: String? = null,

) : ApiFetchedDTO {
) : ApiFetchedDTO, ApiResultDTO {

data class CreditCardStatus(
val avsMessage: String? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ecwid.apiclient.v3.dto.profile.result

import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO
import com.ecwid.apiclient.v3.dto.common.ApiResultDTO
import com.ecwid.apiclient.v3.dto.common.LocalizedValueMap
import com.ecwid.apiclient.v3.dto.profile.request.UpdatedOrderStatusSettings

Expand All @@ -13,6 +14,6 @@ data class FetchedOrderStatusSettings(
val nameTranslations: LocalizedValueMap? = null,
val sendNotificationWhenStatusIsAssigned: Boolean = true,
val lastNameChangeDate: String? = null,
) : ApiFetchedDTO {
) : ApiFetchedDTO, ApiResultDTO {
override fun getModifyKind() = ApiFetchedDTO.ModifyKind.ReadWrite(UpdatedOrderStatusSettings::class)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ import com.ecwid.apiclient.v3.dto.common.ApiResultDTO

data class OrderStatusSettingsSearchResult(
val items: List<FetchedOrderStatusSettings> = listOf(),
val limit: Int = 0,
) : ApiResultDTO
12 changes: 12 additions & 0 deletions src/main/kotlin/com/ecwid/apiclient/v3/impl/OrdersApiClientImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package com.ecwid.apiclient.v3.impl

import com.ecwid.apiclient.v3.ApiClientHelper
import com.ecwid.apiclient.v3.OrdersApiClient
import com.ecwid.apiclient.v3.dto.common.PartialResult
import com.ecwid.apiclient.v3.dto.order.request.*
import com.ecwid.apiclient.v3.dto.order.result.*
import com.ecwid.apiclient.v3.responsefields.AS_SEQUENCE_SEARCH_RESULT_REQUIRED_FIELDS
import kotlin.reflect.KClass

internal class OrdersApiClientImpl(
private val apiClientHelper: ApiClientHelper
Expand All @@ -13,6 +15,16 @@ internal class OrdersApiClientImpl(
override fun searchOrders(request: OrdersSearchRequest) =
apiClientHelper.makeObjectResultRequest<OrdersSearchResult>(request)

override fun <Result : PartialResult<OrdersSearchResult>> searchOrders(
request: OrdersSearchRequest,
resultClass: KClass<Result>
): Result {
return apiClientHelper.makeObjectPartialResultRequest(
request = request,
resultClass = resultClass,
)
}

override fun searchOrdersAsSequence(request: OrdersSearchRequest) = sequence {
var offsetRequest = request.copy(
responseFields = request.responseFields + AS_SEQUENCE_SEARCH_RESULT_REQUIRED_FIELDS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,11 @@ internal class StoreProfileApiClientImpl(
override fun <Result : PartialResult<FetchedStoreProfile>> getStoreProfile(request: StoreProfileRequest, resultClass: KClass<Result>): Result {
return apiClientHelper.makeObjectPartialResultRequest(request, resultClass)
}

override fun <Result : PartialResult<OrderStatusSettingsSearchResult>> searchOrderStatusesSettings(
request: OrderStatusSettingsSearchRequest,
resultClass: KClass<Result>
): Result {
return apiClientHelper.makeObjectPartialResultRequest(request, resultClass)
}
}
Loading