Skip to content

Commit e90581f

Browse files
committed
Add authData validator && force helprs to use singleton pattern only
1 parent e5cf914 commit e90581f

13 files changed

Lines changed: 47 additions & 10 deletions

src/main/java/com/aurora/gplayapi/GooglePlayApi.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ class GooglePlayApi(private val authData: AuthData) {
215215
const val URL_TOC = "$URL_FDFE/toc"
216216
const val URL_TOS_ACCEPT = "$URL_FDFE/acceptTos"
217217
const val URL_UPLOAD_DEVICE_CONFIG = "$URL_FDFE/uploadDeviceConfig"
218+
const val URL_SYNC = "$URL_FDFE/apps/contentSync"
219+
const val URL_SELF_UPDATE = "$URL_FDFE/selfUpdate"
218220

219221
//Not part of Google's API
220222
const val SALES_URL = "https://www.bestappsale.com/api/android/getsale.php"

src/main/java/com/aurora/gplayapi/helpers/AppDetailsHelper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import okhttp3.Request
2828
import okhttp3.RequestBody
2929
import java.util.*
3030

31-
class AppDetailsHelper(authData: AuthData) : BaseHelper(authData) {
31+
class AppDetailsHelper private constructor(authData: AuthData) : BaseHelper(authData) {
3232

3333
companion object : SingletonHolder<AppDetailsHelper, AuthData>(::AppDetailsHelper)
3434

src/main/java/com/aurora/gplayapi/helpers/AppSalesHelper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import com.google.gson.Gson
2525
import java.io.IOException
2626
import java.util.*
2727

28-
class AppSalesHelper(authData: AuthData) : BaseHelper(authData) {
28+
class AppSalesHelper private constructor(authData: AuthData) : BaseHelper(authData) {
2929

3030
companion object : SingletonHolder<AppSalesHelper, AuthData>(::AppSalesHelper)
3131

src/main/java/com/aurora/gplayapi/helpers/AuthHelper.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,6 @@ class AuthHelper {
6666
return authData
6767
}
6868
}
69+
70+
private constructor()
6971
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* GPlayApi
3+
* Copyright (C) 2020 Aurora OSS
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*/
15+
16+
package com.aurora.gplayapi.helpers
17+
18+
import com.aurora.gplayapi.GooglePlayApi
19+
import com.aurora.gplayapi.SingletonHolder
20+
import com.aurora.gplayapi.data.models.AuthData
21+
import com.aurora.gplayapi.data.providers.HeaderProvider
22+
import com.aurora.gplayapi.network.HttpClient
23+
24+
class AuthValidator private constructor(authData: AuthData) : BaseHelper(authData) {
25+
26+
companion object : SingletonHolder<AuthValidator, AuthData>(::AuthValidator)
27+
28+
fun isValid(): Boolean {
29+
val headers = HeaderProvider.getDefaultHeaders(authData)
30+
val playResponse = HttpClient.get(GooglePlayApi.URL_SELF_UPDATE, headers) // OR use contentSync
31+
return playResponse.isSuccessful
32+
}
33+
}

src/main/java/com/aurora/gplayapi/helpers/BrowseHelper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import com.aurora.gplayapi.network.HttpClient
2424
import java.io.IOException
2525
import java.util.*
2626

27-
class BrowseHelper(authData: AuthData) : BaseHelper(authData) {
27+
class BrowseHelper private constructor(authData: AuthData) : BaseHelper(authData) {
2828

2929
companion object : SingletonHolder<BrowseHelper, AuthData>(::BrowseHelper)
3030

src/main/java/com/aurora/gplayapi/helpers/CategoryHelper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import com.aurora.gplayapi.data.providers.HeaderProvider
2525
import com.aurora.gplayapi.network.HttpClient
2626
import java.util.*
2727

28-
class CategoryHelper(authData: AuthData) : BaseHelper(authData) {
28+
class CategoryHelper private constructor(authData: AuthData) : BaseHelper(authData) {
2929

3030
companion object : SingletonHolder<CategoryHelper, AuthData>(::CategoryHelper)
3131

src/main/java/com/aurora/gplayapi/helpers/ClusterHelper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import com.aurora.gplayapi.data.providers.HeaderProvider.getDefaultHeaders
2323
import com.aurora.gplayapi.network.HttpClient
2424
import java.util.*
2525

26-
class ClusterHelper(authData: AuthData) : BaseHelper(authData) {
26+
class ClusterHelper private constructor(authData: AuthData) : BaseHelper(authData) {
2727

2828
companion object : SingletonHolder<ClusterHelper, AuthData>(::ClusterHelper)
2929

src/main/java/com/aurora/gplayapi/helpers/PurchaseHelper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import com.aurora.gplayapi.network.HttpClient
2525
import java.io.IOException
2626
import java.util.*
2727

28-
class PurchaseHelper(authData: AuthData) : BaseHelper(authData) {
28+
class PurchaseHelper private constructor(authData: AuthData) : BaseHelper(authData) {
2929

3030
companion object : SingletonHolder<PurchaseHelper, AuthData>(::PurchaseHelper)
3131

src/main/java/com/aurora/gplayapi/helpers/ReviewsHelper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import com.aurora.gplayapi.data.providers.HeaderProvider.getDefaultHeaders
2626
import com.aurora.gplayapi.network.HttpClient
2727
import java.util.*
2828

29-
class ReviewsHelper(authData: AuthData) : BaseHelper(authData) {
29+
class ReviewsHelper private constructor(authData: AuthData) : BaseHelper(authData) {
3030

3131
companion object : SingletonHolder<ReviewsHelper, AuthData>(::ReviewsHelper) {
3232
const val DEFAULT_SIZE = 20

0 commit comments

Comments
 (0)