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

com.ecwid.apiclient.v3.dto.customer.request.DeletedCustomersSearchRequest.kt Maven / Gradle / Ivy

package com.ecwid.apiclient.v3.dto.customer.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 DeletedCustomersSearchRequest(
	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(
			"customers",
			"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