Skip to content

Commit

Permalink
Merge pull request #75 from rees46/feat/get-product-info
Browse files Browse the repository at this point in the history
feat: Added func for getting product item info
  • Loading branch information
TorinAsakura authored Nov 15, 2024
2 parents 0004a16 + 549bb9f commit be5f3eb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ interface ProductsManager {
filters: Map<String, Any>?,
listener: OnApiCallbackListener? = null
)

fun getProductInfo(
shopId: String,
itemId: String,
listener: OnApiCallbackListener?
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,34 @@ internal class ProductsManagerImpl @Inject constructor(
)
}

override fun getProductInfo(
shopId: String,
itemId: String,
listener: OnApiCallbackListener?
) {
sendNetworkMethodUseCase.getAsync(
method = GET_PRODUCT_INFO_REQUEST,
params = Params().buildParams(
shopId = shopId,
itemId = itemId,
).build(),
listener = listener
)
}

private fun Params.buildParams(
brands: String?,
merchants: String?,
categories: String?,
locations: String?,
limit: Int?,
page: Int?,
filters: Map<String, Any>?,
shopId: String? = null,
itemId: String? = null,
brands: String? = null,
merchants: String? = null,
categories: String? = null,
locations: String? = null,
limit: Int? = null,
page: Int? = null,
filters: Map<String, Any>? = null,
): Params = this.apply {
shopId?.let { put(SHOP_ID_KEY, it) }
itemId?.let { put(ITEM_ID_KEY, it) }
limit?.let { put(LIMIT_KEY, it) }
page?.let { put(PAGE_KEY, it) }
locations?.let { put(LOCATION_KEY, it) }
Expand All @@ -60,13 +79,16 @@ internal class ProductsManagerImpl @Inject constructor(

companion object {
const val GET_PRODUCT_LIST_REQUEST = "products"
const val GET_PRODUCT_INFO_REQUEST = "products/get"

private const val LIMIT_KEY = "limit"
private const val PAGE_KEY = "page"
private const val LOCATION_KEY = "locations"
private const val BRANDS_KEY = "brands"
private const val MERCHANTS_KEY = "merchants"
private const val CATEGORIES_KEY = "categories"
private const val SHOP_ID_KEY = "shop_id"
private const val ITEM_ID_KEY = "item_id"
private const val FILTERS_KEY = ""
}
}

0 comments on commit be5f3eb

Please sign in to comment.