Skip to content

Commit c174d63

Browse files
committed
map external payment notifications
1 parent e86ffb1 commit c174d63

18 files changed

+373
-17
lines changed

InPlayer/src/main/java/com/sdk/inplayer/di/InjectModules.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,12 @@ internal object InjectModules : KoinComponent {
314314
factory { PaymentSuccessMapper() }
315315
factory { SubscriptionSuccessMapper() }
316316

317-
factory { NotificationMapper(get(), get()) }
317+
// external payment
318+
factory { ExternalPaymentSuccessMapper() }
319+
factory { ExternalPaymentFailedMapper() }
320+
factory { ExternalSubscriberCancelMapper() }
321+
322+
factory { NotificationMapper(get(), get(), get(), get(), get(), get(), get()) }
318323

319324

320325
//SubscribtionMapper
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.sdk.inplayer.mapper.notification
2+
3+
import com.sdk.domain.entity.mapper.DomainMapper
4+
import com.sdk.inplayer.mapper.payment.InPlayerExternalPaymentFailedMapper
5+
import com.sdk.notification.model.legacy.InPlayerExternalPaymentFailedNotification
6+
import com.sdk.notification.model.legacy.InPlayerExternalPaymentFailedNotificationResource
7+
8+
9+
internal class ExternalPaymentFailedMapper :
10+
DomainMapper<InPlayerExternalPaymentFailedNotification, InPlayerExternalPaymentFailedMapper> {
11+
12+
override fun mapFromDomain(domainEntity: InPlayerExternalPaymentFailedNotification): InPlayerExternalPaymentFailedMapper {
13+
return InPlayerExternalPaymentFailedMapper(
14+
resource = mapResource(domainEntity.resource),
15+
type = domainEntity.type,
16+
timestamp = domainEntity.timestamp
17+
)
18+
}
19+
20+
private fun mapResource(resource: InPlayerExternalPaymentFailedNotificationResource): InPlayerExternalPaymentFailedNotificationResource {
21+
return InPlayerExternalPaymentFailedNotificationResource(
22+
code = resource.code,
23+
explain = resource.explain ?: "",
24+
message = resource.message ?: ""
25+
)
26+
}
27+
28+
override fun mapToDomain(viewModel: InPlayerExternalPaymentFailedMapper): InPlayerExternalPaymentFailedNotification {
29+
TODO("Not yet implemented")
30+
}
31+
32+
33+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.sdk.inplayer.mapper.notification
2+
3+
import com.sdk.domain.entity.mapper.DomainMapper
4+
import com.sdk.inplayer.mapper.payment.InPlayerExternalPaymentSuccessNotificationMapper
5+
import com.sdk.notification.model.legacy.InPlayerExternalPaymentSuccessNotification
6+
import com.sdk.notification.model.legacy.InPlayerExternalPaymentSuccessNotificationResource
7+
8+
9+
internal class ExternalPaymentSuccessMapper :
10+
DomainMapper<InPlayerExternalPaymentSuccessNotification, InPlayerExternalPaymentSuccessNotificationMapper> {
11+
12+
override fun mapFromDomain(domainEntity: InPlayerExternalPaymentSuccessNotification): InPlayerExternalPaymentSuccessNotificationMapper {
13+
return InPlayerExternalPaymentSuccessNotificationMapper(
14+
resource = mapResource(domainEntity.resource),
15+
type = domainEntity.type,
16+
timestamp = domainEntity.timestamp
17+
)
18+
}
19+
20+
private fun mapResource(resource: InPlayerExternalPaymentSuccessNotificationResource): InPlayerExternalPaymentSuccessNotificationResource {
21+
return InPlayerExternalPaymentSuccessNotificationResource(
22+
access_fee_id = resource.access_fee_id,
23+
amount = resource.amount ?: "0",
24+
code = resource.code,
25+
currency_iso = resource.currency_iso ?: "",
26+
customer_id = resource.customer_id,
27+
description = resource.description ?: "",
28+
discount_percent = resource.discount_percent,
29+
email = resource.email ?: "",
30+
formatted_amount = resource.formatted_amount ?: "",
31+
full_amount = resource.full_amount ?: "",
32+
item_id = resource.item_id,
33+
next_rebill_date = resource.next_rebill_date,
34+
payment_method = resource.payment_method ?: "",
35+
previewTitle = resource.previewTitle ?: "",
36+
status = resource.status ?: "",
37+
timestamp = resource.timestamp,
38+
transaction = resource.transaction ?: "",
39+
voucher_code = resource.voucher_code ?: ""
40+
)
41+
}
42+
43+
override fun mapToDomain(viewModel: InPlayerExternalPaymentSuccessNotificationMapper): InPlayerExternalPaymentSuccessNotification {
44+
TODO("Not yet implemented")
45+
}
46+
47+
48+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.sdk.inplayer.mapper.notification
2+
3+
import com.sdk.domain.entity.mapper.DomainMapper
4+
import com.sdk.inplayer.mapper.payment.InPlayerExternalSubscriberCancelMapper
5+
import com.sdk.notification.model.legacy.InPlayerExternalSubscriberCancelNotification
6+
import com.sdk.notification.model.legacy.InPlayerExternalSubscriberCancelNotificationResource
7+
8+
internal class ExternalSubscriberCancelMapper :
9+
DomainMapper<InPlayerExternalSubscriberCancelNotification, InPlayerExternalSubscriberCancelMapper> {
10+
11+
override fun mapFromDomain(domainEntity: InPlayerExternalSubscriberCancelNotification): InPlayerExternalSubscriberCancelMapper {
12+
return InPlayerExternalSubscriberCancelMapper(
13+
resource = mapResource(domainEntity.resource),
14+
type = domainEntity.type,
15+
timestamp = domainEntity.timestamp
16+
)
17+
}
18+
19+
private fun mapResource(resource: InPlayerExternalSubscriberCancelNotificationResource): InPlayerExternalSubscriberCancelNotificationResource {
20+
return InPlayerExternalSubscriberCancelNotificationResource(
21+
access_fee_id = resource.access_fee_id,
22+
amount = resource.amount ?: "0",
23+
code = resource.code,
24+
currency_iso = resource.currency_iso ?: "",
25+
customer_id = resource.customer_id,
26+
description = resource.description ?: "",
27+
discount_percent = resource.discount_percent,
28+
email = resource.email ?: "",
29+
formatted_amount = resource.formatted_amount ?: "",
30+
full_amount = resource.full_amount ?: "",
31+
item_id = resource.item_id,
32+
next_rebill_date = resource.next_rebill_date,
33+
payment_method = resource.payment_method ?: "",
34+
previewTitle = resource.previewTitle ?: "",
35+
status = resource.status ?: "",
36+
timestamp = resource.timestamp,
37+
transaction = resource.transaction ?: "",
38+
voucher_code = resource.voucher_code ?: ""
39+
)
40+
}
41+
42+
override fun mapToDomain(viewModel: InPlayerExternalSubscriberCancelMapper): InPlayerExternalSubscriberCancelNotification {
43+
TODO("Not yet implemented")
44+
}
45+
46+
47+
}

InPlayer/src/main/java/com/sdk/inplayer/mapper/notification/NotificationMapper.kt

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ package com.sdk.inplayer.mapper.notification
33
import android.util.Log
44
import com.sdk.domain.entity.mapper.DomainMapper
55
import com.sdk.inplayer.model.notification.*
6+
import com.sdk.notification.model.legacy.*
67
import com.sdk.notification.model.notification.*
78
import com.sdk.notification.model.notification.InPlayerAccessRevokedNotification
89

910
internal class NotificationMapper constructor(
1011
private val accessGrantedNotificationMapper: AccessGrantedNotificationMapper,
11-
private val accessRevokedNotificationMapper: AccessRevokedNotificationMapper
12+
private val accessRevokedNotificationMapper: AccessRevokedNotificationMapper,
13+
private val subscriptionSuccessMapper: SubscriptionSuccessMapper,
14+
private val paymentSuccessMapper: PaymentSuccessMapper,
15+
private val externalPaymentSuccessMapper: ExternalPaymentSuccessMapper,
16+
private val externalPaymentFailedMapper: ExternalPaymentFailedMapper,
17+
private val externalSubscriberCancelMapper: ExternalSubscriberCancelMapper
1218
) : DomainMapper<InPlayerNotificationEntity, InPlayerNotification> {
1319

1420
override fun mapFromDomain(inPlayerNotification: InPlayerNotificationEntity): InPlayerNotification {
@@ -44,6 +50,30 @@ internal class NotificationMapper constructor(
4450
)
4551
}
4652

53+
// it was not handle
54+
if (inPlayerNotification is InPlayerSubscribeSuccessNotification) {
55+
return subscriptionSuccessMapper.mapFromDomain(inPlayerNotification)
56+
}
57+
58+
// it was not handle
59+
if (inPlayerNotification is InPlayerPaymentCardSuccessNotifcation) {
60+
return paymentSuccessMapper.mapFromDomain(inPlayerNotification)
61+
}
62+
63+
// it was not handle EXTERNAL PAYMENT
64+
if (inPlayerNotification is InPlayerExternalPaymentFailedNotification) {
65+
return externalPaymentFailedMapper.mapFromDomain(inPlayerNotification)
66+
}
67+
68+
// it was not handle
69+
if (inPlayerNotification is InPlayerExternalPaymentSuccessNotification) {
70+
return externalPaymentSuccessMapper.mapFromDomain(inPlayerNotification)
71+
}
72+
73+
// it was not handle
74+
if (inPlayerNotification is InPlayerExternalSubscriberCancelNotification) {
75+
return externalSubscriberCancelMapper.mapFromDomain(inPlayerNotification)
76+
}
4777
try {
4878
return InPlayerDefaultNotification(
4979
type = inPlayerNotification.type,
@@ -53,15 +83,6 @@ internal class NotificationMapper constructor(
5383
throw ClassCastException("NotificationMapper Unsupported mapping instance of class $inPlayerNotification")
5484
}
5585

56-
// // it was not handle
57-
// if (inPlayerNotification is InPlayerSubscribeSuccessNotification) {
58-
// return subscriptionSuccessMapper.mapFromDomain(inPlayerNotification)
59-
// }
60-
//
61-
// // it was not handle
62-
// if (inPlayerNotification is InPlayerPaymentCardSuccessNotifcation) {
63-
// return paymentSuccessMapper.mapFromDomain(inPlayerNotification)
64-
// }
6586

6687
throw ClassCastException("NotificationMapper Unsupported mapping instance of class $inPlayerNotification")
6788
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.sdk.inplayer.mapper.notification
2+
3+
import com.sdk.domain.entity.mapper.DomainMapper
4+
import com.sdk.inplayer.mapper.payment.InPlayerPaymentSuccessNotification
5+
import com.sdk.notification.model.legacy.InPlayerPaymentCardSuccessNotifcation
6+
import com.sdk.notification.model.legacy.InPlayerPaymentCardSuccessNotificationResource
7+
8+
9+
internal class PaymentSuccessMapper :
10+
DomainMapper<InPlayerPaymentCardSuccessNotifcation, InPlayerPaymentSuccessNotification> {
11+
12+
override fun mapFromDomain(domainEntity: InPlayerPaymentCardSuccessNotifcation): InPlayerPaymentSuccessNotification {
13+
return InPlayerPaymentSuccessNotification(
14+
resource = mapResource(domainEntity.resource),
15+
type = domainEntity.type,
16+
timestamp = domainEntity.timestamp
17+
)
18+
}
19+
20+
private fun mapResource(resource: InPlayerPaymentCardSuccessNotificationResource): InPlayerPaymentCardSuccessNotificationResource {
21+
return InPlayerPaymentCardSuccessNotificationResource(
22+
access_fee_id = resource.access_fee_id,
23+
amount = resource.amount ?: "0",
24+
code = resource.code,
25+
currency_iso = resource.currency_iso ?: "",
26+
customer_id = resource.customer_id,
27+
description = resource.description ?: "",
28+
email = resource.email ?: "",
29+
formatted_amount = resource.formatted_amount ?: "",
30+
status = resource.status ?: "",
31+
timestamp = resource.timestamp,
32+
transaction = resource.transaction ?: ""
33+
)
34+
}
35+
36+
override fun mapToDomain(viewModel: InPlayerPaymentSuccessNotification): InPlayerPaymentCardSuccessNotifcation {
37+
TODO("Not yet implemented")
38+
}
39+
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.sdk.inplayer.mapper.notification
2+
3+
import com.sdk.domain.entity.mapper.DomainMapper
4+
import com.sdk.inplayer.mapper.subscription.InPlayerSubscriptionSuccessNotification
5+
import com.sdk.notification.model.legacy.InPlayerSubscribeSuccessNotification
6+
import com.sdk.notification.model.legacy.InPlayerSubscribeSuccessNotificationResource
7+
8+
9+
internal class SubscriptionSuccessMapper :
10+
DomainMapper<InPlayerSubscribeSuccessNotification, InPlayerSubscriptionSuccessNotification> {
11+
12+
override fun mapFromDomain(domainEntity: InPlayerSubscribeSuccessNotification): InPlayerSubscriptionSuccessNotification {
13+
return InPlayerSubscriptionSuccessNotification(
14+
resource = mapResource(domainEntity.resource),
15+
type = domainEntity.type,
16+
timestamp = domainEntity.timestamp
17+
)
18+
}
19+
20+
private fun mapResource(resource: InPlayerSubscribeSuccessNotificationResource): InPlayerSubscribeSuccessNotificationResource {
21+
return InPlayerSubscribeSuccessNotificationResource(
22+
access_fee_id = resource.access_fee_id,
23+
amount = resource.amount ?: "0",
24+
code = resource.code,
25+
currency_iso = resource.currency_iso ?: "",
26+
customer_id = resource.customer_id,
27+
description = resource.description ?: "",
28+
email = resource.email ?: "",
29+
formatted_amount = resource.formatted_amount ?: "",
30+
status = resource.status ?: "",
31+
timestamp = resource.timestamp,
32+
transaction = resource.transaction ?: ""
33+
)
34+
}
35+
36+
override fun mapToDomain(viewModel: InPlayerSubscriptionSuccessNotification): InPlayerSubscribeSuccessNotification {
37+
TODO("Not yet implemented")
38+
}
39+
40+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.sdk.inplayer.mapper.payment
2+
3+
import com.sdk.inplayer.model.notification.InPlayerNotification
4+
import com.sdk.notification.model.legacy.InPlayerExternalPaymentFailedNotificationResource
5+
6+
class InPlayerExternalPaymentFailedMapper(
7+
val resource: InPlayerExternalPaymentFailedNotificationResource,
8+
override val type: String, override val timestamp: Long
9+
) : InPlayerNotification
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.sdk.inplayer.mapper.payment
2+
3+
import com.sdk.inplayer.model.notification.InPlayerNotification
4+
import com.sdk.notification.model.legacy.InPlayerExternalPaymentSuccessNotificationResource
5+
6+
data class InPlayerExternalPaymentSuccessNotificationMapper(
7+
val resource: InPlayerExternalPaymentSuccessNotificationResource,
8+
override val type: String, override val timestamp: Long
9+
) : InPlayerNotification
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.sdk.inplayer.mapper.payment
2+
3+
import com.sdk.inplayer.model.notification.InPlayerNotification
4+
import com.sdk.notification.model.legacy.InPlayerExternalSubscriberCancelNotificationResource
5+
6+
data class InPlayerExternalSubscriberCancelMapper(
7+
val resource: InPlayerExternalSubscriberCancelNotificationResource,
8+
override val type: String, override val timestamp: Long
9+
) : InPlayerNotification

0 commit comments

Comments
 (0)