-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
173 additions
and
98 deletions.
There are no files selected for viewing
60 changes: 29 additions & 31 deletions
60
android/app/src/main/kotlin/org/getlantern/lantern/model/ProUser.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 |
---|---|---|
@@ -1,49 +1,47 @@ | ||
package org.getlantern.lantern.model | ||
|
||
import com.google.gson.JsonObject | ||
import org.joda.time.Days | ||
import org.joda.time.Months | ||
import org.joda.time.LocalDateTime | ||
import org.joda.time.Months | ||
|
||
data class ProUser( | ||
val userId: Long, | ||
val token: String, | ||
val referral: String, | ||
val email: String, | ||
val userStatus: String, | ||
val code: String, | ||
val subscription: String, | ||
val expiration: Long, | ||
val devices: List<Device>, | ||
val userLevel: String | ||
val userId: Long, | ||
val token: String, | ||
val referral: String, | ||
val email: String, | ||
val userStatus: String, | ||
val code: String, | ||
val subscription: String, | ||
val expiration: Long, | ||
val devices: List<Device>, | ||
val userLevel: String, | ||
) { | ||
private fun isUserStatus(status: String) = userStatus == status | ||
|
||
private fun isUserStatus(status: String) = userStatus == status | ||
|
||
private fun expirationDate() = if (expiration == null) null else LocalDateTime(expiration * 1000) | ||
private fun expirationDate() = if (expiration == null) null else LocalDateTime(expiration * 1000) | ||
|
||
fun monthsLeft(): Int { | ||
val expDate = expirationDate() | ||
if (expDate == null) return 0 | ||
return Months.monthsBetween(LocalDateTime.now(), expDate).getMonths() | ||
} | ||
fun monthsLeft(): Int { | ||
val expDate = expirationDate() | ||
if (expDate == null) return 0 | ||
return Months.monthsBetween(LocalDateTime.now(), expDate).getMonths() | ||
} | ||
|
||
fun daysLeft(): Int { | ||
val expDate = expirationDate() | ||
if (expDate == null) return 0 | ||
return Days.daysBetween(LocalDateTime.now(), expDate).getDays() | ||
} | ||
fun daysLeft(): Int { | ||
val expDate = expirationDate() | ||
if (expDate == null) return 0 | ||
return Days.daysBetween(LocalDateTime.now(), expDate).getDays() | ||
} | ||
|
||
fun newUserDetails(): String { | ||
return "User ID $userId referral $referral" | ||
} | ||
fun newUserDetails(): String { | ||
return "User ID $userId referral $referral" | ||
} | ||
|
||
val isProUser: Boolean | ||
get() = isUserStatus("active") | ||
|
||
val isActive: Boolean | ||
get() = isProUser | ||
get() = isProUser | ||
|
||
val isExpired: Boolean | ||
get() = isUserStatus("expired") | ||
} | ||
get() = isUserStatus("expired") | ||
} |
Oops, something went wrong.