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

com.ecwid.apiclient.v3.dto.customergroup.request.CustomerGroupsSearchRequest.kt Maven / Gradle / Ivy

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

import com.ecwid.apiclient.v3.dto.ApiRequest
import com.ecwid.apiclient.v3.impl.RequestInfo
import com.ecwid.apiclient.v3.responsefields.ResponseFields

data class CustomerGroupsSearchRequest(
	val offset: Int = 0,
	val limit: Int = 100,
	val keyword: String? = null,
	val customerGroupIds: List? = null,
	val responseFields: ResponseFields = ResponseFields.All,
) : ApiRequest {
	override fun toRequestInfo() = RequestInfo.createGetRequest(
		pathSegments = listOf(
			"customer_groups"
		),
		params = toParams(),
		responseFields = responseFields,
	)

	private fun toParams(): Map {
		val request = this
		return mutableMapOf().apply {
			put("offset", request.offset.toString())
			put("limit", request.limit.toString())
			if (!request.keyword.isNullOrBlank()) {
				put("keyword", request.keyword)
			}
			if (!request.customerGroupIds.isNullOrEmpty()) {
				put("customerGroupIds", request.customerGroupIds.joinToString(","))
			}
		}.toMap()
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy