-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prepared Retrofit realization for sending encrypted messages through … #1619
Merged
tomholub
merged 3 commits into
master
from
issue_1615_retrofit_for_password_encrypted_msgs
Dec 21, 2021
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -16,11 +16,15 @@ import com.flowcrypt.email.api.retrofit.response.api.DomainOrgRulesResponse | |
import com.flowcrypt.email.api.retrofit.response.api.EkmPrivateKeysResponse | ||
import com.flowcrypt.email.api.retrofit.response.api.FesServerResponse | ||
import com.flowcrypt.email.api.retrofit.response.api.LoginResponse | ||
import com.flowcrypt.email.api.retrofit.response.api.MessageReplyTokenResponse | ||
import com.flowcrypt.email.api.retrofit.response.api.MessageUploadResponse | ||
import com.flowcrypt.email.api.retrofit.response.api.PostHelpFeedbackResponse | ||
import com.flowcrypt.email.api.retrofit.response.attester.InitialLegacySubmitResponse | ||
import com.flowcrypt.email.api.retrofit.response.attester.TestWelcomeResponse | ||
import com.flowcrypt.email.api.retrofit.response.oauth2.MicrosoftOAuth2TokenResponse | ||
import com.google.gson.JsonObject | ||
import okhttp3.MultipartBody | ||
import okhttp3.RequestBody | ||
import okhttp3.ResponseBody | ||
import retrofit2.Call | ||
import retrofit2.Response | ||
|
@@ -29,7 +33,9 @@ import retrofit2.http.Field | |
import retrofit2.http.FormUrlEncoded | ||
import retrofit2.http.GET | ||
import retrofit2.http.Header | ||
import retrofit2.http.Multipart | ||
import retrofit2.http.POST | ||
import retrofit2.http.Part | ||
import retrofit2.http.Path | ||
import retrofit2.http.Query | ||
import retrofit2.http.Streaming | ||
|
@@ -143,7 +149,7 @@ interface ApiService { | |
* @param body POJO model for requests | ||
*/ | ||
@POST(BuildConfig.API_URL + "account/login") | ||
suspend fun postLogin(@Body body: LoginModel, @Header("Authorization") tokenId: String): | ||
suspend fun postLogin(@Body body: LoginModel, @Header("Authorization") idToken: String): | ||
Response<LoginResponse> | ||
|
||
/** | ||
|
@@ -200,7 +206,7 @@ interface ApiService { | |
@GET | ||
suspend fun getPrivateKeysViaEkm( | ||
@Url ekmUrl: String, | ||
@Header("Authorization") tokenId: String | ||
@Header("Authorization") idToken: String | ||
): Response<EkmPrivateKeysResponse> | ||
|
||
/** | ||
|
@@ -214,4 +220,25 @@ interface ApiService { | |
*/ | ||
@GET() | ||
suspend fun isAvailable(@Url url: String): Response<ResponseBody> | ||
|
||
/** | ||
* This method grabs a reply token before uploading a password protected message | ||
*/ | ||
@POST("https://fes.{domain}/api/v1/message/new-reply-token") | ||
suspend fun getReplyTokenForPasswordProtectedMsg( | ||
@Path("domain") domain: String, | ||
@Header("Authorization") idToken: String | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above - rename |
||
): Response<MessageReplyTokenResponse> | ||
|
||
/** | ||
* This method uploads a password protected message to a web portal | ||
*/ | ||
@Multipart | ||
@POST("https://fes.{domain}/api/v1/message") | ||
suspend fun uploadPasswordProtectedMsgToWebPortal( | ||
@Path("domain") domain: String, | ||
@Header("Authorization") idToken: String, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above - rename |
||
@Part("details") details: RequestBody, | ||
@Part content: MultipartBody.Part | ||
): Response<MessageUploadResponse> | ||
} |
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
20 changes: 20 additions & 0 deletions
20
...rypt/src/main/java/com/flowcrypt/email/api/retrofit/request/model/MessageUploadRequest.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 @@ | ||
/* | ||
* © 2016-present FlowCrypt a.s. Limitations apply. Contact [email protected] | ||
* Contributors: DenBond7 | ||
*/ | ||
|
||
package com.flowcrypt.email.api.retrofit.request.model | ||
|
||
/** | ||
* @author Denis Bondarenko | ||
* Date: 12/20/21 | ||
* Time: 12:19 PM | ||
* E-mail: [email protected] | ||
*/ | ||
data class MessageUploadRequest( | ||
val associateReplyToken: String, | ||
val from: String, | ||
val to: List<String>, | ||
val cc: List<String> = emptyList(), | ||
val bcc: List<String> = emptyList() | ||
) |
44 changes: 44 additions & 0 deletions
44
.../src/main/java/com/flowcrypt/email/api/retrofit/response/api/MessageReplyTokenResponse.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,44 @@ | ||
/* | ||
* © 2016-present FlowCrypt a.s. Limitations apply. Contact [email protected] | ||
* Contributors: DenBond7 | ||
*/ | ||
|
||
package com.flowcrypt.email.api.retrofit.response.api | ||
|
||
import android.os.Parcel | ||
import android.os.Parcelable | ||
import com.flowcrypt.email.api.retrofit.response.base.ApiError | ||
import com.flowcrypt.email.api.retrofit.response.base.ApiResponse | ||
import com.google.gson.annotations.Expose | ||
import com.google.gson.annotations.SerializedName | ||
|
||
/** | ||
* @author Denis Bondarenko | ||
* Date: 12/20/21 | ||
* Time: 12:10 PM | ||
* E-mail: [email protected] | ||
*/ | ||
data class MessageReplyTokenResponse( | ||
@SerializedName("error") | ||
@Expose override val apiError: ApiError? = null, | ||
@Expose val replyToken: String? = null | ||
) : ApiResponse { | ||
constructor(parcel: Parcel) : this( | ||
parcel.readParcelable(ApiError::class.java.classLoader), | ||
parcel.readString() | ||
) | ||
|
||
override fun writeToParcel(parcel: Parcel, flags: Int) { | ||
parcel.writeParcelable(apiError, flags) | ||
parcel.writeString(replyToken) | ||
} | ||
|
||
override fun describeContents(): Int { | ||
return 0 | ||
} | ||
|
||
companion object CREATOR : Parcelable.Creator<MessageReplyTokenResponse> { | ||
override fun createFromParcel(parcel: Parcel) = MessageReplyTokenResponse(parcel) | ||
override fun newArray(size: Int): Array<MessageReplyTokenResponse?> = arrayOfNulls(size) | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...rypt/src/main/java/com/flowcrypt/email/api/retrofit/response/api/MessageUploadResponse.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,44 @@ | ||
/* | ||
* © 2016-present FlowCrypt a.s. Limitations apply. Contact [email protected] | ||
* Contributors: DenBond7 | ||
*/ | ||
|
||
package com.flowcrypt.email.api.retrofit.response.api | ||
|
||
import android.os.Parcel | ||
import android.os.Parcelable | ||
import com.flowcrypt.email.api.retrofit.response.base.ApiError | ||
import com.flowcrypt.email.api.retrofit.response.base.ApiResponse | ||
import com.google.gson.annotations.Expose | ||
import com.google.gson.annotations.SerializedName | ||
|
||
/** | ||
* @author Denis Bondarenko | ||
* Date: 12/20/21 | ||
* Time: 12:34 PM | ||
* E-mail: [email protected] | ||
*/ | ||
data class MessageUploadResponse( | ||
@SerializedName("error") | ||
@Expose override val apiError: ApiError? = null, | ||
@Expose val url: String? = null | ||
) : ApiResponse { | ||
constructor(parcel: Parcel) : this( | ||
parcel.readParcelable(ApiError::class.java.classLoader), | ||
parcel.readString() | ||
) | ||
|
||
override fun writeToParcel(parcel: Parcel, flags: Int) { | ||
parcel.writeParcelable(apiError, flags) | ||
parcel.writeString(url) | ||
} | ||
|
||
override fun describeContents(): Int { | ||
return 0 | ||
} | ||
|
||
companion object CREATOR : Parcelable.Creator<MessageUploadResponse> { | ||
override fun createFromParcel(parcel: Parcel) = MessageUploadResponse(parcel) | ||
override fun newArray(size: Int): Array<MessageUploadResponse?> = arrayOfNulls(size) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rename here and in other methods of this class
idToken
intoauthorization
, because it actually contains not only token itself but the whole content of the header.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree 👍