All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ecwid.apiclient.v3.dto.order.request.DeletedOrdersSearchRequest.kt Maven / Gradle / Ivy

The newest version!
package com.ecwid.apiclient.v3.dto.order.request

import com.ecwid.apiclient.v3.dto.ApiRequest
import com.ecwid.apiclient.v3.impl.RequestInfo
import com.ecwid.apiclient.v3.responsefields.ResponseFields
import java.util.*
import java.util.concurrent.TimeUnit

data class DeletedOrdersSearchRequest(
	val deletedFrom: Date? = null,
	val deletedTo: Date? = null,
	val offset: Int = 0,
	val limit: Int = 100,
	val responseFields: ResponseFields = ResponseFields.All,
) : ApiRequest {
	override fun toRequestInfo() = RequestInfo.createGetRequest(
		pathSegments = listOf(
			"orders",
			"deleted"
		),
		params = toParams(),
		responseFields = responseFields,
	)

	private fun toParams(): Map {
		val request = this
		return mutableMapOf().apply {
			request.deletedFrom?.let { put("from_date", TimeUnit.MILLISECONDS.toSeconds(it.time).toString()) }
			request.deletedTo?.let { put("to_date", TimeUnit.MILLISECONDS.toSeconds(it.time).toString()) }
			put("offset", request.offset.toString())
			put("limit", request.limit.toString())
		}.toMap()
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy