Push message provider HPK DTO's builder fixes (#105)
* Use correct namings for args, variables and fix builder methods
This commit is contained in:
parent
844c0a9c73
commit
9281a5d213
|
|
@ -11,11 +11,11 @@ internal data class Message private constructor(
|
|||
val notification: Notification?,
|
||||
/** Android message push control. */
|
||||
@JsonProperty("android")
|
||||
val android: AndroidConfig?,
|
||||
val androidConfig: AndroidConfig?,
|
||||
@JsonProperty("apns")
|
||||
val apns: ApnsConfig?,
|
||||
val apnsConfig: ApnsConfig?,
|
||||
@JsonProperty("webpush")
|
||||
val webpush: WebPushConfig?,
|
||||
val webPushConfig: WebPushConfig?,
|
||||
/** Push token of the target user of a message. */
|
||||
val token: Collection<String>?,
|
||||
/** Topic subscribed by the target user of a message. */
|
||||
|
|
@ -42,9 +42,9 @@ internal data class Message private constructor(
|
|||
}
|
||||
|
||||
notification?.also { Notification.validator.check(it) }
|
||||
android?.also { AndroidConfig.validator.check(it, notification) }
|
||||
apns?.also { ApnsConfig.validator.check(it) }
|
||||
webpush?.also { WebPushConfig.validator.check(it) }
|
||||
androidConfig?.also { AndroidConfig.validator.check(it, notification) }
|
||||
apnsConfig?.also { ApnsConfig.validator.check(it) }
|
||||
webPushConfig?.also { WebPushConfig.validator.check(it) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -64,8 +64,8 @@ internal data class Message private constructor(
|
|||
private var data: String? = null
|
||||
private var notification: Notification? = null
|
||||
private var androidConfig: AndroidConfig? = null
|
||||
private var apns: ApnsConfig? = null
|
||||
private var webpush: WebPushConfig? = null
|
||||
private var apnsConfig: ApnsConfig? = null
|
||||
private var webPushConfig: WebPushConfig? = null
|
||||
private val token: MutableList<String> = mutableListOf()
|
||||
private var topic: String? = null
|
||||
private var condition: String? = null
|
||||
|
|
@ -85,13 +85,13 @@ internal data class Message private constructor(
|
|||
return this
|
||||
}
|
||||
|
||||
fun setApns(apns: ApnsConfig): Builder {
|
||||
this.apns = apns
|
||||
fun setApns(apnsConfig: ApnsConfig): Builder {
|
||||
this.apnsConfig = apnsConfig
|
||||
return this
|
||||
}
|
||||
|
||||
fun setWebpush(webpush: WebPushConfig): Builder {
|
||||
this.webpush = webpush
|
||||
fun setWebpush(webPushConfig: WebPushConfig): Builder {
|
||||
this.webPushConfig = webPushConfig
|
||||
return this
|
||||
}
|
||||
|
||||
|
|
@ -114,9 +114,9 @@ internal data class Message private constructor(
|
|||
return Message(
|
||||
data = data,
|
||||
notification = notification,
|
||||
android = androidConfig,
|
||||
apns = apns,
|
||||
webpush = webpush,
|
||||
androidConfig = androidConfig,
|
||||
apnsConfig = apnsConfig,
|
||||
webPushConfig = webPushConfig,
|
||||
topic = topic,
|
||||
condition = condition,
|
||||
token = token.takeIf(Collection<*>::isNotEmpty),
|
||||
|
|
|
|||
|
|
@ -30,13 +30,13 @@ internal data class WebPushConfig private constructor(
|
|||
|
||||
class Builder : Buildable {
|
||||
|
||||
private var headers: WebPushHeaders? = null
|
||||
private var webPushHeaders: WebPushHeaders? = null
|
||||
private var data: String? = null
|
||||
private var notification: WebNotification? = null
|
||||
private var webNotification: WebNotification? = null
|
||||
private var webHmsOptions: WebHmsOptions? = null
|
||||
|
||||
fun setHeaders(webPushHeaders: WebPushHeaders): Builder {
|
||||
this.headers = webPushHeaders
|
||||
this.webPushHeaders = webPushHeaders
|
||||
return this
|
||||
}
|
||||
|
||||
|
|
@ -46,20 +46,20 @@ internal data class WebPushConfig private constructor(
|
|||
}
|
||||
|
||||
fun setNotification(webNotification: WebNotification): Builder {
|
||||
this.notification = notification
|
||||
this.webNotification = webNotification
|
||||
return this
|
||||
}
|
||||
|
||||
fun setWebHmsOptions(webHmsOptions: WebHmsOptions): Builder {
|
||||
this.webHmsOptions
|
||||
this.webHmsOptions = webHmsOptions
|
||||
return this
|
||||
}
|
||||
|
||||
fun build(): WebPushConfig {
|
||||
return WebPushConfig(
|
||||
webPushHeaders = headers,
|
||||
webPushHeaders = webPushHeaders,
|
||||
data = data,
|
||||
webNotification = notification,
|
||||
webNotification = webNotification,
|
||||
webHmsOptions = webHmsOptions,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ internal data class AndroidNotificationConfig private constructor(
|
|||
private var androidLightSettings: AndroidLightSettings? = null
|
||||
private var foregroundShow = false
|
||||
private val inboxContent: MutableList<String> = mutableListOf()
|
||||
private val buttons: MutableList<AndroidButton> = mutableListOf()
|
||||
private val androidButtons: MutableList<AndroidButton> = mutableListOf()
|
||||
private var profileId: String? = null
|
||||
|
||||
fun setTitle(title: String): Builder {
|
||||
|
|
@ -353,8 +353,8 @@ internal data class AndroidNotificationConfig private constructor(
|
|||
return this
|
||||
}
|
||||
|
||||
fun addButton(vararg button: AndroidButton): Builder {
|
||||
buttons.addAll(button)
|
||||
fun addButton(vararg androidButton: AndroidButton): Builder {
|
||||
androidButtons.addAll(androidButton)
|
||||
return this
|
||||
}
|
||||
|
||||
|
|
@ -399,7 +399,7 @@ internal data class AndroidNotificationConfig private constructor(
|
|||
androidLightSettings = androidLightSettings,
|
||||
foregroundShow = foregroundShow,
|
||||
inboxContent = inboxContent.takeIf(Collection<*>::isNotEmpty),
|
||||
androidButtons = buttons.takeIf(Collection<*>::isNotEmpty),
|
||||
androidButtons = androidButtons.takeIf(Collection<*>::isNotEmpty),
|
||||
profileId = profileId,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import ru.touchin.push.message.provider.hpk.base.builders.Buildable
|
|||
@JsonNaming(PropertyNamingStrategies.KebabCaseStrategy::class)
|
||||
internal class Aps private constructor(
|
||||
@JsonProperty("alert")
|
||||
val alert: ApnsAlert?,
|
||||
val apnsAlert: ApnsAlert?,
|
||||
val badge: Int?,
|
||||
val sound: String?,
|
||||
val contentAvailable: Int?,
|
||||
|
|
@ -20,8 +20,8 @@ internal class Aps private constructor(
|
|||
|
||||
fun check(aps: Aps) {
|
||||
with(aps) {
|
||||
if (alert != null) {
|
||||
ApnsAlert.validator.check(alert)
|
||||
if (apnsAlert != null) {
|
||||
ApnsAlert.validator.check(apnsAlert)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@ internal class Aps private constructor(
|
|||
|
||||
class Builder : Buildable {
|
||||
|
||||
private var alert: ApnsAlert? = null
|
||||
private var apnsAlert: ApnsAlert? = null
|
||||
private var badge: Int? = null
|
||||
private var sound: String? = null
|
||||
private var contentAvailable: Int? = null
|
||||
|
|
@ -38,7 +38,7 @@ internal class Aps private constructor(
|
|||
private var threadId: String? = null
|
||||
|
||||
fun setAlert(alert: ApnsAlert): Builder {
|
||||
this.alert = alert
|
||||
this.apnsAlert = alert
|
||||
return this
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ internal class Aps private constructor(
|
|||
|
||||
fun build(): Aps {
|
||||
return Aps(
|
||||
alert = alert,
|
||||
apnsAlert = apnsAlert,
|
||||
badge = badge,
|
||||
sound = sound,
|
||||
contentAvailable = contentAvailable,
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@ internal data class WebNotification private constructor(
|
|||
val tag: String?,
|
||||
val badge: String?,
|
||||
@JsonProperty("dir")
|
||||
val dir: WebDir?,
|
||||
val webDir: WebDir?,
|
||||
val vibrate: Collection<Int>?,
|
||||
val renotify: Boolean,
|
||||
val requireInteraction: Boolean,
|
||||
val silent: Boolean,
|
||||
val timestamp: Long?,
|
||||
@JsonProperty("actions")
|
||||
val actions: Collection<WebActions>?,
|
||||
val webActions: Collection<WebActions>?,
|
||||
) {
|
||||
|
||||
class Validator {
|
||||
|
|
@ -41,13 +41,13 @@ internal data class WebNotification private constructor(
|
|||
private var lang: String? = null
|
||||
private var tag: String? = null
|
||||
private var badge: String? = null
|
||||
private var dir: WebDir? = null
|
||||
private var webDir: WebDir? = null
|
||||
private val vibrate: MutableList<Int> = mutableListOf()
|
||||
private var renotify = false
|
||||
private var requireInteraction = false
|
||||
private var silent = false
|
||||
private var timestamp: Long? = null
|
||||
private val actions: MutableList<WebActions> = mutableListOf()
|
||||
private val webActions: MutableList<WebActions> = mutableListOf()
|
||||
|
||||
fun setTitle(title: String): Builder {
|
||||
this.title = title
|
||||
|
|
@ -84,8 +84,8 @@ internal data class WebNotification private constructor(
|
|||
return this
|
||||
}
|
||||
|
||||
fun setDir(dir: WebDir): Builder {
|
||||
this.dir = dir
|
||||
fun setDir(webDir: WebDir): Builder {
|
||||
this.webDir = webDir
|
||||
return this
|
||||
}
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ internal data class WebNotification private constructor(
|
|||
}
|
||||
|
||||
fun addActions(vararg webActions: WebActions): Builder {
|
||||
this.actions.addAll(webActions)
|
||||
this.webActions.addAll(webActions)
|
||||
return this
|
||||
}
|
||||
|
||||
|
|
@ -128,13 +128,13 @@ internal data class WebNotification private constructor(
|
|||
lang = lang,
|
||||
tag = tag,
|
||||
badge = badge,
|
||||
dir = dir,
|
||||
webDir = webDir,
|
||||
vibrate = vibrate.takeIf(Collection<*>::isNotEmpty),
|
||||
renotify = renotify,
|
||||
requireInteraction = requireInteraction,
|
||||
silent = silent,
|
||||
timestamp = timestamp,
|
||||
actions = actions.takeIf(Collection<*>::isNotEmpty),
|
||||
webActions = webActions.takeIf(Collection<*>::isNotEmpty),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ internal data class WebPushHeaders private constructor(
|
|||
val ttl: String?,
|
||||
val topic: String?,
|
||||
@JsonProperty("urgency")
|
||||
val urgency: WebUrgency?,
|
||||
val webUrgency: WebUrgency?,
|
||||
) {
|
||||
|
||||
class Validator {
|
||||
|
|
@ -54,7 +54,7 @@ internal data class WebPushHeaders private constructor(
|
|||
return WebPushHeaders(
|
||||
ttl = ttl,
|
||||
topic = topic,
|
||||
urgency = urgency,
|
||||
webUrgency = urgency,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue