-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
299 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 5 additions & 12 deletions
17
app/src/main/java/com/myetherwallet/mewconnect/content/api/mew/MewApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,18 @@ | ||
package com.myetherwallet.mewconnect.content.api.mew | ||
|
||
import com.myetherwallet.mewconnect.content.data.AnalyticsEventsRequest | ||
import com.myetherwallet.mewconnect.feature.main.data.JsonRpcRequest | ||
import com.myetherwallet.mewconnect.feature.main.data.JsonRpcResponse | ||
import org.web3j.protocol.core.methods.request.Transaction | ||
import retrofit2.Call | ||
import retrofit2.http.Body | ||
import retrofit2.http.Headers | ||
import retrofit2.http.POST | ||
import retrofit2.http.Path | ||
import retrofit2.http.* | ||
|
||
/** | ||
* Created by BArtWell on 16.07.2018. | ||
* Created by BArtWell on 26.03.2020. | ||
*/ | ||
|
||
internal interface MewApi { | ||
|
||
@POST("{apiMethod}") | ||
@POST("analytics/record/{platform}") | ||
@Headers("content-type: application/json") | ||
fun getAllBalances(@Path("apiMethod") apiMethod: String, @Body jsonRpc: JsonRpcRequest<Any>): Call<JsonRpcResponse> | ||
|
||
@POST("{apiMethod}") | ||
@Headers("content-type: application/json") | ||
fun getWalletBalance(@Path("apiMethod") apiMethod: String, @Body jsonRpc: JsonRpcRequest<String>): Call<JsonRpcResponse> | ||
fun submit(@Path("platform") platform: String, @Query("iso") iso: String, @Body events: AnalyticsEventsRequest): Call<Any> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
app/src/main/java/com/myetherwallet/mewconnect/content/api/node/NodeApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.myetherwallet.mewconnect.content.api.node | ||
|
||
import com.myetherwallet.mewconnect.feature.main.data.JsonRpcRequest | ||
import com.myetherwallet.mewconnect.feature.main.data.JsonRpcResponse | ||
import retrofit2.Call | ||
import retrofit2.http.Body | ||
import retrofit2.http.Headers | ||
import retrofit2.http.POST | ||
import retrofit2.http.Path | ||
|
||
/** | ||
* Created by BArtWell on 16.07.2018. | ||
*/ | ||
|
||
internal interface NodeApi { | ||
|
||
@POST("{apiMethod}") | ||
@Headers("content-type: application/json") | ||
fun getAllBalances(@Path("apiMethod") apiMethod: String, @Body jsonRpc: JsonRpcRequest<Any>): Call<JsonRpcResponse> | ||
|
||
@POST("{apiMethod}") | ||
@Headers("content-type: application/json") | ||
fun getWalletBalance(@Path("apiMethod") apiMethod: String, @Body jsonRpc: JsonRpcRequest<String>): Call<JsonRpcResponse> | ||
} |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/myetherwallet/mewconnect/content/api/node/NodeApiService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.myetherwallet.mewconnect.content.api.node | ||
|
||
import com.myetherwallet.mewconnect.feature.main.data.JsonRpcRequest | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
/** | ||
* Created by BArtWell on 16.07.2018. | ||
*/ | ||
|
||
@Singleton | ||
class NodeApiService | ||
@Inject constructor(client: NodeClient) : NodeApi { | ||
|
||
private val mewApi by lazy { client.retrofit.create(NodeApi::class.java) } | ||
|
||
override fun getAllBalances(apiMethod: String, jsonRpc: JsonRpcRequest<Any>) = mewApi.getAllBalances(apiMethod, jsonRpc) | ||
|
||
override fun getWalletBalance(apiMethod: String, jsonRpc: JsonRpcRequest<String>) = mewApi.getWalletBalance(apiMethod, jsonRpc) | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/com/myetherwallet/mewconnect/content/api/node/NodeClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.myetherwallet.mewconnect.content.api.node | ||
|
||
import com.myetherwallet.mewconnect.BuildConfig | ||
import com.myetherwallet.mewconnect.core.utils.MewLog | ||
import okhttp3.OkHttpClient | ||
import okhttp3.logging.HttpLoggingInterceptor | ||
import retrofit2.Retrofit | ||
import retrofit2.converter.gson.GsonConverterFactory | ||
|
||
/** | ||
* Created by BArtWell on 01.09.2018. | ||
*/ | ||
|
||
class NodeClient { | ||
|
||
val retrofit = createRetrofit() | ||
|
||
private fun createRetrofit(): Retrofit { | ||
return Retrofit.Builder() | ||
.baseUrl(BuildConfig.NODE_API_END_POINT) | ||
.client(createClient()) | ||
.addConverterFactory(GsonConverterFactory.create()) | ||
.build() | ||
} | ||
|
||
private fun createClient(): OkHttpClient { | ||
val okHttpClientBuilder: OkHttpClient.Builder = OkHttpClient.Builder() | ||
if (MewLog.shouldDisplayLogs()) { | ||
val loggingInterceptor = HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY) | ||
okHttpClientBuilder.addInterceptor(loggingInterceptor) | ||
} | ||
return okHttpClientBuilder.build() | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/myetherwallet/mewconnect/content/data/AnalyticsEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.myetherwallet.mewconnect.content.data | ||
|
||
import java.util.* | ||
|
||
/** | ||
* Created by BArtWell on 26.03.2020. | ||
*/ | ||
|
||
data class AnalyticsEvent( | ||
val id: String, | ||
val timestamp: Date = Date() | ||
) { | ||
|
||
companion object { | ||
val BANNER_SHOWN = "Android-MEWconnectApp-Banner-shown" | ||
val BANNER_FREE_UPGRADE_CLICKED = "Android-MEWconnectApp-Banner-FreeUpgrade-Clicked" | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
app/src/main/java/com/myetherwallet/mewconnect/content/data/AnalyticsEventsRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.myetherwallet.mewconnect.content.data | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
/** | ||
* Created by BArtWell on 26.03.2020. | ||
*/ | ||
|
||
data class AnalyticsEventsRequest( | ||
@SerializedName("events") | ||
val events: List<AnalyticsEvent> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 6 additions & 17 deletions
23
app/src/main/java/com/myetherwallet/mewconnect/core/repository/MewApiRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.