mirror of
https://github.com/TanelOrumaa/Estonian-ID-card-mobile-authenticator-POC.git
synced 2024-12-22 12:30:16 +02:00
MOB-23 token emit related code
This commit is contained in:
parent
eca3f92468
commit
64357ca1d3
@ -62,4 +62,7 @@ dependencies {
|
||||
//SecureDataStoring
|
||||
implementation("androidx.security:security-crypto:1.0.0")
|
||||
|
||||
// Retrofit + Moshi Converter
|
||||
implementation 'com.squareup.retrofit2:converter-moshi:2.9.0'
|
||||
implementation 'com.squareup.moshi:moshi-kotlin:1.9.3'
|
||||
}
|
@ -67,7 +67,7 @@ class HomeFragment : Fragment() {
|
||||
(activity as MainActivity).menuAvailable = false
|
||||
// Currently saving is true because the application is not yet integrated with
|
||||
// other applications or websites.
|
||||
// TODO: Check the navigation action default values. Not everything has to be declared implicitly.
|
||||
// TODO: Check the navigation action default values. Not everything has to be declared explicitly.
|
||||
if (auth) {
|
||||
val action = HomeFragmentDirections.actionHomeFragmentToCanFragment(reading = false, auth = true, mobile = mobile)
|
||||
findNavController().navigate(action)
|
||||
|
@ -0,0 +1,9 @@
|
||||
package com.tarkvaraprojekt.mobileauthapp.network
|
||||
|
||||
/**
|
||||
* Placeholder ResponseItem.
|
||||
*/
|
||||
data class ResponseItem (
|
||||
val data1: Int,
|
||||
val data2: Int,
|
||||
)
|
@ -0,0 +1,37 @@
|
||||
package com.tarkvaraprojekt.mobileauthapp.network
|
||||
|
||||
import com.squareup.moshi.Moshi
|
||||
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
|
||||
import retrofit2.Response
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.converter.moshi.MoshiConverterFactory
|
||||
import retrofit2.http.Body
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Headers
|
||||
import retrofit2.http.POST
|
||||
|
||||
/**
|
||||
* Class for making HTTP requests
|
||||
* Based on https://developer.android.com/courses/pathways/android-basics-kotlin-unit-4-pathway-2
|
||||
*/
|
||||
private const val BASE_URL =
|
||||
"add-endpoint-url-here"
|
||||
|
||||
private val moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build()
|
||||
private val retrofit = Retrofit.Builder().addConverterFactory(MoshiConverterFactory.create(moshi))
|
||||
.baseUrl(BASE_URL).build()
|
||||
|
||||
interface TokenApiService {
|
||||
@GET("something")
|
||||
suspend fun getData(): ResponseItem
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("posts")
|
||||
suspend fun addData(@Body data: ResponseItem): Response<ResponseItem>
|
||||
}
|
||||
|
||||
object TokenApi {
|
||||
val retrofitService : TokenApiService by lazy {
|
||||
retrofit.create(TokenApiService::class.java)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user