-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #284 from PermanentOrg/VSP-1415
"Mailchip implementation" implementation and some refactoring.
- Loading branch information
Showing
17 changed files
with
232 additions
and
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.permanent.permanent.models | ||
|
||
data class Tags( | ||
val addTags: List<String>? = null, | ||
val removeTags: List<String>? = null, | ||
) |
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
13 changes: 13 additions & 0 deletions
13
app/src/main/java/org/permanent/permanent/network/StelaAccountService.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,13 @@ | ||
package org.permanent.permanent.network | ||
|
||
import org.permanent.permanent.models.Tags | ||
import org.permanent.permanent.network.models.ResponseVO | ||
import retrofit2.Call | ||
import retrofit2.http.Body | ||
import retrofit2.http.PUT | ||
|
||
interface StelaAccountService { | ||
|
||
@PUT("api/v2/account/tags") | ||
fun addRemoveTags(@Body tags: Tags): Call<ResponseVO> | ||
} |
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
9 changes: 9 additions & 0 deletions
9
app/src/main/java/org/permanent/permanent/repositories/StelaAccountRepository.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,9 @@ | ||
package org.permanent.permanent.repositories | ||
|
||
import org.permanent.permanent.models.Tags | ||
import org.permanent.permanent.network.IResponseListener | ||
|
||
interface StelaAccountRepository { | ||
|
||
fun addRemoveTags(tags: Tags, listener: IResponseListener) | ||
} |
42 changes: 42 additions & 0 deletions
42
app/src/main/java/org/permanent/permanent/repositories/StelaAccountRepositoryImpl.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,42 @@ | ||
package org.permanent.permanent.repositories | ||
|
||
import android.content.Context | ||
import org.permanent.permanent.R | ||
import org.permanent.permanent.models.Tags | ||
import org.permanent.permanent.network.IResponseListener | ||
import org.permanent.permanent.network.NetworkClient | ||
import org.permanent.permanent.network.models.ResponseVO | ||
import retrofit2.Call | ||
import retrofit2.Callback | ||
import retrofit2.Response | ||
|
||
class StelaAccountRepositoryImpl(context: Context) : StelaAccountRepository { | ||
|
||
private val appContext = context.applicationContext | ||
override fun addRemoveTags(tags: Tags, listener: IResponseListener) { | ||
|
||
NetworkClient.instance().addRemoveTags(tags).enqueue(object : Callback<ResponseVO> { | ||
|
||
override fun onResponse(call: Call<ResponseVO>, response: Response<ResponseVO>) { | ||
if (response.isSuccessful) { | ||
val newLegacyContact = response.body() | ||
if (newLegacyContact != null) { | ||
listener.onSuccess("") | ||
} else { | ||
listener.onFailed(appContext.getString(R.string.generic_error)) | ||
} | ||
} else { | ||
try { | ||
listener.onFailed(response.errorBody().toString()) | ||
} catch (e: Exception) { | ||
listener.onFailed(e.message) | ||
} | ||
} | ||
} | ||
|
||
override fun onFailure(call: Call<ResponseVO>, t: Throwable) { | ||
listener.onFailed(t.message) | ||
} | ||
}) | ||
} | ||
} |
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
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.