Skip to content
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.

Commit

Permalink
PMA-8255 - Final changes to SDK for new servlet changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jasondantuma committed Jun 3, 2019
1 parent 7f34be1 commit de7e4fd
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import android.util.Log
internal object EvLogger {

fun d(tag: String, message: String? = null, throwable: Throwable? = null) {
// if (BuildConfig.DEBUG) {
if (BuildConfig.DEBUG) {
Log.d(tag, message, throwable)
// }
}
}

fun i(tag: String, message: String? = null, throwable: Throwable? = null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public object EverlyticPush {
* Subscribes a contact email to Everlytic Push Notifications for the current device
* @since 0.0.1-alpha
* @param email
* @param onComplete Callback with result of attempted subscription
* @param onComplete Callback with status of attempted subscription
* @return [Unit]
* */
@JvmStatic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package com.everlytic.android.pushnotificationsdk.models

import org.json.JSONObject

internal data class ApiResponse(var result: String, var data: JSONObject)
internal data class ApiResponse(var status: String, var data: JSONObject)
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package com.everlytic.android.pushnotificationsdk.models.jsonadapters

import com.everlytic.android.pushnotificationsdk.getJSONObjectOrNull
import com.everlytic.android.pushnotificationsdk.models.ApiResponse
import org.json.JSONObject

internal object ApiResponseAdapter : JSONAdapterInterface<ApiResponse> {
override fun toJson(obj: ApiResponse): JSONObject {
return JSONObject()
.put("result", obj.result)
.put("status", obj.status)
.put("data", obj.data)
}

override fun fromJson(json: JSONObject): ApiResponse {
return ApiResponse(
json.getString("result"),
json.getJSONObject("data")
json.getString("status"),
json.getJSONObjectOrNull("data") ?: JSONObject()
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@ internal class EverlyticApi(val http: EverlyticHttp) {

fun subscribe(subscription: SubscriptionEvent, responseHandler: EverlyticHttp.ResponseHandler) {
http.post(
"push-notifications/subscriptions/subscribe",
"push-notifications/subscribe",
JSONAdapter.encodeAsString(subscription),
responseHandler
)
}

fun unsubscribe(unsubscribeEvent: UnsubscribeEvent, responseHandler: EverlyticHttp.ResponseHandler) {
http.post(
"push-notifications/subscriptions/unsubscribe",
"push-notifications/unsubscribe",
JSONAdapter.encodeAsString(unsubscribeEvent),
responseHandler
)
}

fun recordClickEvent(event: NotificationEvent, responseHandler: EverlyticHttp.ResponseHandler) {
http.post("push-notifications/events/clicks", JSONAdapter.encodeAsString(event), responseHandler)
http.post("push-notifications/clicks", JSONAdapter.encodeAsString(event), responseHandler)
}

fun recordDeliveryEvent(event: NotificationEvent, responseHandler: EverlyticHttp.ResponseHandler) {
http.post("push-notifications/events/deliveries", JSONAdapter.encodeAsString(event), responseHandler)
http.post("push-notifications/deliveries", JSONAdapter.encodeAsString(event), responseHandler)
}

fun recordDismissEvent(event: NotificationEvent, responseHandler: EverlyticHttp.ResponseHandler) {
http.post("push-notifications/events/dismissals", JSONAdapter.encodeAsString(event), responseHandler)
http.post("push-notifications/dismissals", JSONAdapter.encodeAsString(event), responseHandler)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ internal class EverlyticHttp(installUrl: String, pushProjectUuid: String) {

val bytes = jsonBodyData.toByteArray()
setFixedLengthStreamingMode(bytes.size)
logd("Writing data...")
logd("Writing data=${jsonBodyData}")
outputStream.write(bytes)
}

Expand Down Expand Up @@ -139,7 +139,7 @@ internal class EverlyticHttp(installUrl: String, pushProjectUuid: String) {
} else {
val response = ApiResponseAdapter.fromJson(JSONObject(jsonResult))

if (response.result == "error") {
if (response.status == "error") {
responseHandler.onFailure(400, jsonResult, null)
} else {
responseHandler.onSuccess(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class App : Application() {
FirebaseApp.initializeApp(this)
EverlyticPush
// .setInTestMode(true)
.init(this, "dT1hZG1pbmlzdHJhdG9yO2s9MlVvZXdYaXJSMEJPZVFHOGh1M1pFRHpLNnVXd0l5NHJfMDtpPWh0dHA6Ly9xYS5ldmVybHl0aWMubmV0O2w9NA==")
.init(this, "cD0zNjhhOGJmZS0yZjA1LTRmNjMtYjY3OS0yOWJhOTAyY2FmOWM7aT1odHRwOi8vcWEuZXZlcmx5dGljLm5ldA==")
}

}

0 comments on commit de7e4fd

Please sign in to comment.