Skip to content

Commit

Permalink
Implement creating a Github Issue from Ivy Wallet (labels not working)
Browse files Browse the repository at this point in the history
  • Loading branch information
Iliyan Germanov committed Nov 5, 2021
1 parent 6506da2 commit ceb0e76
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
21 changes: 21 additions & 0 deletions app/src/main/java/com/ivy/wallet/network/RestClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.ivy.wallet.network.error.RestError
import com.ivy.wallet.network.service.*
import com.ivy.wallet.session.IvySession
import com.ivy.wallet.session.NoSessionException
import okhttp3.Credentials
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
Expand Down Expand Up @@ -101,6 +102,26 @@ class RestClient private constructor(
response
})

//Github Rest API interceptor (not the best solution)
httpClientBuilder.addInterceptor(Interceptor { chain ->
val request = chain.request()
val finalRequest =
if (request.url.toUrl().toString().startsWith(GithubService.BASE_URL)) {
val credentials = Credentials.basic(
GithubService.GITHUB_SERVICE_ACC_USERNAME,
GithubService.GITHUB_SERVICE_ACC_ACCESS_TOKEN
)

request.newBuilder()
.header("Authorization", credentials)
.build()
} else {
request
}

chain.proceed(request = finalRequest)
})

trustAllSSLCertificates(httpClientBuilder)

return Retrofit.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import retrofit2.http.POST

interface GithubService {
companion object {
private const val BASE_URL = "https://api.github.com"
const val BASE_URL = "https://api.github.com"
const val OPEN_ISSUE_URL = "$BASE_URL/repos/ILIYANGERMANOV/ivy-wallet/issues"

const val GITHUB_SERVICE_ACC_USERNAME = "ivywallet"
const val GITHUB_SERVICE_ACC_ACCESS_TOKEN = "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"

const val LABEL_USER_REQUEST = "user request"
}

Expand Down

0 comments on commit ceb0e76

Please sign in to comment.