Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/backend/mato/MapiVolleyRequest.java
- This file was added.
| package it.reyboz.bustorino.backend.mato; | |||||
| import androidx.annotation.Nullable; | |||||
| import com.android.volley.AuthFailureError; | |||||
| import com.android.volley.Request; | |||||
| import com.android.volley.Response; | |||||
| import java.util.Map; | |||||
| public abstract class MapiVolleyRequest<T> extends Request<T> { | |||||
| private static final String API_URL="https://mapi.5t.torino.it/routing/v1/routers/mat/index/graphql"; | |||||
| protected final Response.Listener<T> listener; | |||||
| private final MatoAPIFetcher.QueryType type; | |||||
| public MapiVolleyRequest( | |||||
| MatoAPIFetcher.QueryType type, | |||||
| Response.Listener<T> listener, | |||||
| @Nullable Response.ErrorListener errorListener) { | |||||
| super(Method.POST, API_URL, errorListener); | |||||
| this.type = type; | |||||
| this.listener = listener; | |||||
| } | |||||
| @Nullable | |||||
| @Override | |||||
| abstract protected Map<String, String> getParams() throws AuthFailureError; | |||||
| @Override | |||||
| protected void deliverResponse(T response) { | |||||
| listener.onResponse(response); | |||||
| } | |||||
| @Override | |||||
| public Map<String, String> getHeaders() throws AuthFailureError { | |||||
| return MatoAPIFetcher.Companion.getREQ_PARAMETERS(); | |||||
| } | |||||
| } | |||||
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register