-
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
8 changed files
with
94 additions
and
231 deletions.
There are no files selected for viewing
45 changes: 0 additions & 45 deletions
45
android/app/src/main/java/org/getlantern/lantern/model/ProError.java
This file was deleted.
Oops, something went wrong.
164 changes: 0 additions & 164 deletions
164
android/app/src/main/java/org/getlantern/lantern/model/ProUser.java
This file was deleted.
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
17 changes: 17 additions & 0 deletions
17
android/app/src/main/kotlin/org/getlantern/lantern/model/ProError.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 org.getlantern.lantern.model | ||
|
||
import com.google.gson.JsonObject | ||
|
||
data class ProError( | ||
val id: String, | ||
val message: String, | ||
val details: JsonObject? = null | ||
) { | ||
constructor(result: JsonObject) : this( | ||
result.get("errorId").asString, | ||
result.get("error").asString, | ||
result.get("details").asJsonObject, | ||
) { | ||
|
||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
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 | ||
|
||
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 | ||
) { | ||
|
||
private fun isUserStatus(status: String) = userStatus == status | ||
|
||
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 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" | ||
} | ||
|
||
val isProUser: Boolean | ||
get() = isUserStatus("active") | ||
|
||
val isActive: Boolean | ||
get() = isProUser | ||
|
||
val isExpired: Boolean | ||
get() = isUserStatus("expired") | ||
} |
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