-
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.
Merge pull request #78 from rees46/feat/connect-in-app-notification
Feat/connect in app notification
- Loading branch information
Showing
37 changed files
with
804 additions
and
341 deletions.
There are no files selected for viewing
317 changes: 179 additions & 138 deletions
317
personalization-sdk/src/main/kotlin/com/personalization/RegisterManager.kt
Large diffs are not rendered by default.
Oops, something went wrong.
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
22 changes: 22 additions & 0 deletions
22
...main/kotlin/com/personalization/api/responses/initialization/SdkInitializationResponse.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,22 @@ | ||
package com.personalization.api.responses.initialization | ||
|
||
import com.personalization.sdk.data.models.dto.popUp.PopupDto | ||
import com.personalization.sdk.data.models.dto.popUp.WebPushSettings | ||
import com.personalization.sdk.data.models.dto.search.Search | ||
|
||
data class SdkInitializationResponse( | ||
val did: String, | ||
val seance: String, | ||
val currency: String, | ||
val emailCollector: Boolean, | ||
val hasEmail: Boolean, | ||
val recommendations: Boolean, | ||
val lazyLoad: Boolean, | ||
val autoCssRecommender: Boolean, | ||
val cms: String, | ||
val snippets: List<String>, | ||
val popupDto: PopupDto?, | ||
val search: Search?, | ||
val webPushSettings: WebPushSettings?, | ||
val recone: Boolean | ||
) |
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
17 changes: 17 additions & 0 deletions
17
personalization-sdk/src/main/kotlin/com/personalization/errors/base.error.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,17 @@ | ||
package com.personalization.errors | ||
|
||
import android.util.Log | ||
|
||
class BaseInfoError( | ||
private val tag: String, | ||
private val exception: Exception? = null, | ||
private val message: String | ||
) { | ||
|
||
fun logError() { | ||
Log.e( | ||
/* tag = */ tag, | ||
/* msg = */"$message: ${exception?.message ?: "Unknown error"}" | ||
) | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
personalization-sdk/src/main/kotlin/com/personalization/errors/firebase.error.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,17 @@ | ||
package com.personalization.errors | ||
|
||
import android.util.Log | ||
|
||
class FirebaseError( | ||
private val tag: String, | ||
private val exception: Exception? | ||
) { | ||
|
||
fun logError() { | ||
Log.e( | ||
/* tag = */ tag, | ||
/* msg = */ | ||
"Failed to retrieve Firebase token: ${exception?.message ?: "Unknown error"}" | ||
) | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
personalization-sdk/src/main/kotlin/com/personalization/errors/response.error.kt.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,50 @@ | ||
package com.personalization.errors | ||
|
||
import android.util.Log | ||
import org.json.JSONObject | ||
|
||
/** | ||
* Class for handling JSON response errors and validation | ||
*/ | ||
class JsonResponseErrorHandler( | ||
private val tag: String, | ||
private val response: JSONObject?, | ||
) { | ||
|
||
/** | ||
* Validates if the response is not null | ||
* @return true if the response is valid, false otherwise | ||
*/ | ||
fun validateResponse(): Boolean { | ||
return if (response == null) { | ||
logError("Response is null or incorrect") | ||
false | ||
} else { | ||
Log.i(tag, "Response is: $response") | ||
true | ||
} | ||
} | ||
|
||
/** | ||
* Extracts a required string field from the JSON response | ||
* Logs an error and returns null if the field is missing or empty | ||
* @param fieldName The name of the field to extract | ||
* @return The field value, or null if invalid | ||
*/ | ||
fun getRequiredField(fieldName: String): String? { | ||
val value = response?.optString(fieldName) | ||
if (value.isNullOrEmpty()) { | ||
logError("Response does not contain the correct field: $fieldName") | ||
return null | ||
} | ||
return value | ||
} | ||
|
||
/** | ||
* Logs the error message with the associated tag | ||
* @param message The error message to log | ||
*/ | ||
fun logError(message: String, exception: Exception? = null) { | ||
Log.e(tag, message, exception) | ||
} | ||
} |
Oops, something went wrong.