-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implemented get product info method in sdk
- Loading branch information
Showing
8 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...alizatio-sdk/src/main/kotlin/com/personalizatio/entities/products/productInfo/Category.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.personalizatio.entities.products.productInfo | ||
|
||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class Category( | ||
@SerializedName("branch") | ||
val branch: Int, | ||
@SerializedName("id") | ||
val id: String, | ||
@SerializedName("level") | ||
val level: Int, | ||
@SerializedName("name") | ||
val name: String, | ||
@SerializedName("name_with_parent") | ||
val nameWithParent: String, | ||
@SerializedName("parent_id") | ||
val parentId: String, | ||
@SerializedName("url") | ||
val url: String, | ||
@SerializedName("url_handle") | ||
val urlHandle: String | ||
) |
25 changes: 25 additions & 0 deletions
25
...sdk/src/main/kotlin/com/personalizatio/entities/products/productInfo/ImageDownloadData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.personalizatio.entities.products.productInfo | ||
|
||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class ImageDownloadData( | ||
@SerializedName("could_be_widgetable") | ||
val couldBeWidgetable: Boolean, | ||
@SerializedName("image") | ||
val image: String, | ||
@SerializedName("image_changed") | ||
val imageChanged: Boolean, | ||
@SerializedName("name") | ||
val name: String, | ||
@SerializedName("persisted") | ||
val persisted: Boolean, | ||
@SerializedName("price") | ||
val price: String, | ||
@SerializedName("time") | ||
val time: String, | ||
@SerializedName("url") | ||
val url: String, | ||
@SerializedName("widgetable") | ||
val widgetable: Boolean | ||
) |
4 changes: 4 additions & 0 deletions
4
...lizatio-sdk/src/main/kotlin/com/personalizatio/entities/products/productInfo/Locations.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.personalizatio.entities.products.productInfo | ||
|
||
|
||
class Locations |
55 changes: 55 additions & 0 deletions
55
...sdk/src/main/kotlin/com/personalizatio/entities/products/productInfo/ProductInfoEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.personalizatio.entities.products.productInfo | ||
|
||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class ProductInfoEntity( | ||
@SerializedName("brand") | ||
val brand: String, | ||
@SerializedName("brand_downcase") | ||
val brandDowncase: String, | ||
@SerializedName("categories") | ||
val categories: List<Category>, | ||
@SerializedName("category_ids") | ||
val categoryIds: List<String>, | ||
@SerializedName("child_age_max") | ||
val childAgeMax: Int, | ||
@SerializedName("child_age_min") | ||
val childAgeMin: Int, | ||
@SerializedName("child_gender") | ||
val childGender: String, | ||
@SerializedName("child_type") | ||
val childType: String, | ||
@SerializedName("currency") | ||
val currency: String, | ||
@SerializedName("description") | ||
val description: String, | ||
@SerializedName("discount") | ||
val discount: Boolean, | ||
@SerializedName("ignored") | ||
val ignored: Boolean, | ||
@SerializedName("image_download_data") | ||
val imageDownloadData: ImageDownloadData, | ||
@SerializedName("image_download_start_at") | ||
val imageDownloadStartAt: String, | ||
@SerializedName("is_available") | ||
val isAvailable: Boolean, | ||
@SerializedName("is_child") | ||
val isChild: Boolean, | ||
@SerializedName("locations") | ||
val locations: Locations, | ||
@SerializedName("name") | ||
val name: String, | ||
@SerializedName("picture") | ||
val picture: String, | ||
@SerializedName("price") | ||
val price: String, | ||
@SerializedName("sales_rate") | ||
val salesRate: Int, | ||
@SerializedName("uniqid") | ||
val uniqid: String, | ||
@SerializedName("url") | ||
val url: String, | ||
@SerializedName("widgetable") | ||
val widgetable: Boolean | ||
) |
7 changes: 7 additions & 0 deletions
7
personalizatio-sdk/src/main/kotlin/com/personalizatio/products/OnProductsListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.personalizatio.products | ||
|
||
import com.personalizatio.entities.products.productInfo.ProductInfoEntity | ||
|
||
interface OnProductsListener { | ||
fun onGetProductInfo(productInfoEntity: ProductInfoEntity) {} | ||
} |
27 changes: 27 additions & 0 deletions
27
personalizatio-sdk/src/main/kotlin/com/personalizatio/products/ProductsManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.personalizatio.products | ||
|
||
import com.google.gson.Gson | ||
import com.personalizatio.Params | ||
import com.personalizatio.SDK | ||
import com.personalizatio.api.OnApiCallbackListener | ||
import com.personalizatio.entities.products.productInfo.ProductInfoEntity | ||
import org.json.JSONObject | ||
|
||
internal class ProductsManager(val sdk: SDK) { | ||
|
||
internal fun getProductInfo(productId: String, listener: OnProductsListener) { | ||
getProductInfo(productId, object : OnApiCallbackListener() { | ||
override fun onSuccess(response: JSONObject?) { | ||
response?.let { | ||
val productInfoEntity = Gson().fromJson(it.toString(), ProductInfoEntity::class.java) | ||
listener.onGetProductInfo(productInfoEntity) | ||
} | ||
} | ||
}) | ||
} | ||
|
||
internal fun getProductInfo(productId: String, listener: OnApiCallbackListener) { | ||
val params = Params().put(Params.Parameter.ITEM_ID, productId) | ||
sdk.getAsync("products/get/", params.build(), listener) | ||
} | ||
} |