Skip to content

Commit

Permalink
Merge pull request #32 from rees46/feat/app-demo
Browse files Browse the repository at this point in the history
Feat/app demo
  • Loading branch information
TorinAsakura authored Jul 11, 2024
2 parents 580f66d + af63bbe commit 4577d65
Show file tree
Hide file tree
Showing 33 changed files with 1,137 additions and 264 deletions.
4 changes: 2 additions & 2 deletions personalizatio-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ dependencies {
implementation 'com.github.bumptech.glide:glide:4.16.0'
implementation 'androidx.media3:media3-exoplayer:1.2.1'
implementation 'androidx.media3:media3-ui:1.2.1'
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.work:work-runtime-ktx:2.9.0'
implementation 'com.google.code.gson:gson:2.11.0'
}

group = 'com.personalizatio'
apply from: '../publish.gradle'

tasks.register('sourcesJar', Jar) {
archiveClassifier.set('sources')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ abstract class AbstractParams<P : AbstractParams<P>> {
return this as P
}

internal fun put(param: String, value: String): P {
params.put(param, value)
return this as P
}

internal fun put(param: String, value: Int): P {
params.put(param, value)
return this as P
}

internal fun put(param: String, value: Boolean): P {
params.put(param, value)
return this as P
}

fun build(): JSONObject {
return params
}
Expand Down
32 changes: 29 additions & 3 deletions personalizatio-sdk/src/main/kotlin/com/personalizatio/Params.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.personalizatio

import android.util.Log
import com.personalizatio.api.params.ProductItemParams
import org.json.JSONArray
import org.json.JSONException
import org.json.JSONObject
Expand Down Expand Up @@ -66,8 +67,15 @@ class Params : AbstractParams<Params>() {
}

/**
* Товар
* Product
*/
@Deprecated(
"This class will be removed in future versions.",
level = DeprecationLevel.WARNING, replaceWith = ReplaceWith(
"ProductItemParams",
"com.personalizatio.api.params.ProductItemParams"
)
)
class Item(id: String) {
enum class COLUMN(val value: String) {
ID("id"),
Expand Down Expand Up @@ -148,9 +156,27 @@ class Params : AbstractParams<Params>() {
}

/**
* Вставка товара
* Add item
*/
@Deprecated(
"This method will be removed in future versions.",
level = DeprecationLevel.WARNING, replaceWith = ReplaceWith(
"put(productItemParams)",
"com.personalizatio.api.params.ProductItemParams"
)
)
fun put(item: Item): Params {
return putProductParameters(item.columns)
}

/**
* Add product
*/
fun put(productItemParams: ProductItemParams): Params {
return putProductParameters(productItemParams.parameters)
}

private fun putProductParameters(parameters: HashMap<String, String>): Params {
try {
val array: JSONArray
if (params.has("items")) {
Expand All @@ -160,7 +186,7 @@ class Params : AbstractParams<Params>() {
params.put("items", array)
}
val jsonObject = JSONObject()
for ((key, value) in item.columns) {
for ((key, value) in parameters) {
jsonObject.put(key, value)
}
array.put(jsonObject)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.google.android.gms.tasks.Task
import com.google.firebase.messaging.FirebaseMessaging
import com.personalizatio.SDK.Companion.TAG
import com.personalizatio.SDK.Companion.debug
import com.personalizatio.api.ApiMethod
import com.personalizatio.api.OnApiCallbackListener
import com.personalizatio.utils.PreferencesUtils
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -89,7 +88,7 @@ class RegisterManager(val sdk: SDK) {
try {
val params = JSONObject()
params.put("tz", (TimeZone.getDefault().rawOffset / 3600000.0).toInt().toString())
sdk.send(ApiMethod.GET("init"), params, object : OnApiCallbackListener() {
sdk.networkManager.get("init", params, object : OnApiCallbackListener() {
@Volatile
private var attempt = 0

Expand Down
Loading

0 comments on commit 4577d65

Please sign in to comment.