Rename the authenticated request.
This commit is contained in:
parent
e13572ae67
commit
7cd3706b7d
|
@ -7,7 +7,7 @@ import com.android.volley.toolbox.StringRequest
|
||||||
* General request aimed at a protected endpoint of the API. The token can be retrieved
|
* General request aimed at a protected endpoint of the API. The token can be retrieved
|
||||||
* via a [LoginRequest], or, if you've made it past the login screen, via Shared Preferences.
|
* via a [LoginRequest], or, if you've made it past the login screen, via Shared Preferences.
|
||||||
*
|
*
|
||||||
* The [AuthenticatedRequest] expects to receive a string from the API endpoint; how this string
|
* The [AuthenticatedGetRequest] expects to receive a string from the API endpoint; how this string
|
||||||
* is handled is determined by the [Response.Listener] object. One may use
|
* is handled is determined by the [Response.Listener] object. One may use
|
||||||
* [Response.Listener.toGsonListener] to create a JSON deserializer that expects a [String].
|
* [Response.Listener.toGsonListener] to create a JSON deserializer that expects a [String].
|
||||||
*
|
*
|
||||||
|
@ -17,10 +17,10 @@ import com.android.volley.toolbox.StringRequest
|
||||||
* @param listener the listener object called if a valid response is received.
|
* @param listener the listener object called if a valid response is received.
|
||||||
* @param error the error listener for the request.
|
* @param error the error listener for the request.
|
||||||
*/
|
*/
|
||||||
open class AuthenticatedRequest(
|
open class AuthenticatedGetRequest(
|
||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
apiEndpoint: String,
|
apiEndpoint: String,
|
||||||
private val token: String,
|
val token: String,
|
||||||
listener: Response.Listener<String>,
|
listener: Response.Listener<String>,
|
||||||
error: Response.ErrorListener
|
error: Response.ErrorListener
|
||||||
) : StringRequest(
|
) : StringRequest(
|
|
@ -20,7 +20,7 @@ class CollarDetailRequest(
|
||||||
token : String,
|
token : String,
|
||||||
listener: Response.Listener<CollarDetails>,
|
listener: Response.Listener<CollarDetails>,
|
||||||
error: Response.ErrorListener
|
error: Response.ErrorListener
|
||||||
) : AuthenticatedRequest(
|
) : AuthenticatedGetRequest(
|
||||||
baseUrl, "/collars/$collarId/details", token,
|
baseUrl, "/collars/$collarId/details", token,
|
||||||
listener.toGsonListener(), error
|
listener.toGsonListener(), error
|
||||||
)
|
)
|
|
@ -21,7 +21,7 @@ class CollarHistoryRequest(
|
||||||
token : String,
|
token : String,
|
||||||
listener: Response.Listener<List<CollarPos>>,
|
listener: Response.Listener<List<CollarPos>>,
|
||||||
error: Response.ErrorListener
|
error: Response.ErrorListener
|
||||||
) : AuthenticatedRequest(
|
) : AuthenticatedGetRequest(
|
||||||
baseUrl, "/collars/$collarId/history", token,
|
baseUrl, "/collars/$collarId/history", token,
|
||||||
listener.toGsonListener(), error
|
listener.toGsonListener(), error
|
||||||
)
|
)
|
|
@ -18,7 +18,7 @@ class CollarRequest(
|
||||||
token : String,
|
token : String,
|
||||||
listener: Response.Listener<List<CollarSummary>>,
|
listener: Response.Listener<List<CollarSummary>>,
|
||||||
error: Response.ErrorListener
|
error: Response.ErrorListener
|
||||||
) : AuthenticatedRequest(
|
) : AuthenticatedGetRequest(
|
||||||
baseUrl, "/collars", token,
|
baseUrl, "/collars", token,
|
||||||
listener.toGsonListener(), error
|
listener.toGsonListener(), error
|
||||||
)
|
)
|
|
@ -19,7 +19,7 @@ class DistanceTraveledRequest(
|
||||||
token : String,
|
token : String,
|
||||||
listener: Response.Listener<List<CollarDistance>>,
|
listener: Response.Listener<List<CollarDistance>>,
|
||||||
error: Response.ErrorListener
|
error: Response.ErrorListener
|
||||||
) : AuthenticatedRequest(
|
) : AuthenticatedGetRequest(
|
||||||
baseUrl, "/collars/stats/distance", token,
|
baseUrl, "/collars/stats/distance", token,
|
||||||
listener.toGsonListener(), error
|
listener.toGsonListener(), error
|
||||||
)
|
)
|
Loading…
Reference in New Issue
Block a user