-
Notifications
You must be signed in to change notification settings - Fork 4
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
21 changed files
with
444 additions
and
104 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
16 changes: 16 additions & 0 deletions
16
app/src/main/java/com/pwhs/quickmem/data/dto/report/CreateReportRequestDto.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,16 @@ | ||
package com.pwhs.quickmem.data.dto.report | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class CreateReportRequestDto( | ||
@SerializedName("reason") | ||
val reason: String, | ||
@SerializedName("reportedEntityId") | ||
val reportedEntityId: String, | ||
@SerializedName("ownerOfReportedEntityId") | ||
val ownerOfReportedEntityId: String, | ||
@SerializedName("reportedType") | ||
val reportedType: String, | ||
@SerializedName("reporterId") | ||
val reporterId: String, | ||
) |
24 changes: 24 additions & 0 deletions
24
app/src/main/java/com/pwhs/quickmem/data/mapper/report/CreateReportRequestMapper.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.pwhs.quickmem.data.mapper.report | ||
|
||
import com.pwhs.quickmem.data.dto.report.CreateReportRequestDto | ||
import com.pwhs.quickmem.domain.model.report.CreateReportRequestModel | ||
|
||
fun CreateReportRequestModel.toDto(): CreateReportRequestDto { | ||
return CreateReportRequestDto( | ||
reason = reason, | ||
reportedEntityId = reportedEntityId, | ||
ownerOfReportedEntityId = ownerOfReportedEntityId, | ||
reportedType = reportedType, | ||
reporterId = reporterId | ||
) | ||
} | ||
|
||
fun CreateReportRequestDto.toModel(): CreateReportRequestModel { | ||
return CreateReportRequestModel( | ||
reason = reason, | ||
reportedEntityId = reportedEntityId, | ||
ownerOfReportedEntityId = ownerOfReportedEntityId, | ||
reportedType = reportedType, | ||
reporterId = reporterId | ||
) | ||
} |
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
32 changes: 32 additions & 0 deletions
32
app/src/main/java/com/pwhs/quickmem/data/remote/repository/ReportRepositoryImpl.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,32 @@ | ||
package com.pwhs.quickmem.data.remote.repository | ||
|
||
import com.pwhs.quickmem.core.utils.Resources | ||
import com.pwhs.quickmem.data.mapper.report.toDto | ||
import com.pwhs.quickmem.data.remote.ApiService | ||
import com.pwhs.quickmem.domain.model.report.CreateReportRequestModel | ||
import com.pwhs.quickmem.domain.repository.ReportRepository | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import javax.inject.Inject | ||
|
||
class ReportRepositoryImpl @Inject constructor( | ||
private val apiService: ApiService | ||
) : ReportRepository { | ||
override suspend fun createReport( | ||
token: String, | ||
createReportRequestModel: CreateReportRequestModel | ||
): Flow<Resources<Unit>> { | ||
return flow { | ||
emit(Resources.Loading()) | ||
try { | ||
val response = apiService.createReport( | ||
token = token, | ||
createReportRequestDto = createReportRequestModel.toDto() | ||
) | ||
emit(Resources.Success(response)) | ||
} catch (e: Exception) { | ||
emit(Resources.Error(e.message ?: "An error occurred")) | ||
} | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/pwhs/quickmem/domain/model/report/CreateReportRequestModel.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 com.pwhs.quickmem.domain.model.report | ||
|
||
data class CreateReportRequestModel( | ||
val reason: String, | ||
val reportedEntityId: String, | ||
val ownerOfReportedEntityId: String, | ||
val reportedType: String, | ||
val reporterId: String, | ||
) |
12 changes: 12 additions & 0 deletions
12
app/src/main/java/com/pwhs/quickmem/domain/repository/ReportRepository.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.pwhs.quickmem.domain.repository | ||
|
||
import com.pwhs.quickmem.core.utils.Resources | ||
import com.pwhs.quickmem.domain.model.report.CreateReportRequestModel | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface ReportRepository { | ||
suspend fun createReport( | ||
token: String, | ||
createReportRequestModel: CreateReportRequestModel, | ||
): Flow<Resources<Unit>> | ||
} |
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.