-
Notifications
You must be signed in to change notification settings - Fork 6
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 #64 from mayorJAY/feat-workflow-overrides
Implement Workflow Overrides API
- Loading branch information
Showing
9 changed files
with
425 additions
and
0 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
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,54 @@ | ||
package api | ||
|
||
import co.novu.dto.response.PaginatedResponseWrapper | ||
import co.novu.dto.response.ResponseWrapper | ||
import dto.request.CreateWorkflowOverrideRequest | ||
import dto.workflowoverrides.UpdateWorkflowOverrideRequest | ||
import dto.workflowoverrides.WorkflowOverride | ||
import retrofit2.Response | ||
import retrofit2.http.Body | ||
import retrofit2.http.DELETE | ||
import retrofit2.http.GET | ||
import retrofit2.http.POST | ||
import retrofit2.http.PUT | ||
import retrofit2.http.Path | ||
import retrofit2.http.QueryMap | ||
|
||
interface WorkflowOverrideApi { | ||
|
||
companion object { | ||
const val ENDPOINT = "workflow-overrides" | ||
} | ||
|
||
@POST(ENDPOINT) | ||
suspend fun createWorkflowOverride(@Body request: CreateWorkflowOverrideRequest): Response<ResponseWrapper<WorkflowOverride>> | ||
|
||
@GET(ENDPOINT) | ||
@JvmSuppressWildcards | ||
suspend fun getWorkflowOverrides(@QueryMap params: Map<String, Any>): Response<PaginatedResponseWrapper<WorkflowOverride>> | ||
|
||
@GET("$ENDPOINT/workflows/{workflowId}/tenants/{tenantId}") | ||
suspend fun getWorkflowOverride( | ||
@Path("workflowId") workflowId: String, | ||
@Path("tenantId") tenantId: String | ||
): Response<ResponseWrapper<WorkflowOverride>> | ||
|
||
@GET("$ENDPOINT/{overrideId}") | ||
suspend fun getWorkflowOverrideById(@Path("overrideId") overrideId: String): Response<ResponseWrapper<WorkflowOverride>> | ||
|
||
@PUT("$ENDPOINT/{overrideId}") | ||
suspend fun updateWorkflowOverrideById( | ||
@Path("overrideId") overrideId: String, | ||
@Body request: UpdateWorkflowOverrideRequest | ||
): Response<ResponseWrapper<WorkflowOverride>> | ||
|
||
@PUT("$ENDPOINT/workflows/{workflowId}/tenants/{tenantId}") | ||
suspend fun updateWorkflowOverride( | ||
@Path("workflowId") workflowId: String, | ||
@Path("tenantId") tenantId: String, | ||
@Body request: UpdateWorkflowOverrideRequest | ||
): Response<ResponseWrapper<WorkflowOverride>> | ||
|
||
@DELETE("$ENDPOINT/{overrideId}") | ||
suspend fun deleteWorkflowOverride(@Path("overrideId") overrideId: String): Response<ResponseWrapper<Boolean>> | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/dto/request/CreateWorkflowOverrideRequest.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,10 @@ | ||
package dto.request | ||
|
||
import co.novu.dto.PreferenceSettings | ||
|
||
data class CreateWorkflowOverrideRequest( | ||
var workflowId: String, | ||
var tenantId: String, | ||
var active: Boolean? = null, | ||
var preferenceSettings: PreferenceSettings? = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package co.novu.dto.request | ||
|
||
data class GetWorkflowOverrideRequest( | ||
var page: Int? = null, | ||
var limit: Int? = null | ||
) |
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/dto/workflowoverrides/UpdateWorkflowOverrideRequest.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,8 @@ | ||
package dto.workflowoverrides | ||
|
||
import co.novu.dto.PreferenceSettings | ||
|
||
data class UpdateWorkflowOverrideRequest( | ||
var active: Boolean? = null, | ||
var preferenceSettings: PreferenceSettings? = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package dto.workflowoverrides | ||
|
||
import co.novu.dto.PreferenceSettings | ||
import com.google.gson.annotations.SerializedName | ||
|
||
data class WorkflowOverride( | ||
@SerializedName("_id") | ||
var id: String? = null, | ||
@SerializedName("_organizationId") | ||
var organizationId: String? = null, | ||
@SerializedName("_environmentId") | ||
var environmentId: String? = null, | ||
@SerializedName("_workflowId") | ||
var workflowId: String? = null, | ||
@SerializedName("_tenantId") | ||
var tenantId: String? = null, | ||
var active: Boolean? = null, | ||
var preferenceSettings: PreferenceSettings? = null, | ||
var deleted: Boolean? = null, | ||
var deletedAt: String? = null, | ||
var deletedBy: String? = null, | ||
var createdAt: String? = null, | ||
var updatedAt: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package co.novu.extensions | ||
|
||
import co.novu.Novu | ||
import co.novu.dto.request.GetWorkflowOverrideRequest | ||
import co.novu.dto.response.PaginatedResponseWrapper | ||
import co.novu.dto.response.ResponseWrapper | ||
import co.novu.helpers.extractResponse | ||
import dto.request.CreateWorkflowOverrideRequest | ||
import dto.workflowoverrides.UpdateWorkflowOverrideRequest | ||
import dto.workflowoverrides.WorkflowOverride | ||
import mu.KotlinLogging | ||
|
||
private val logger = KotlinLogging.logger {} | ||
|
||
suspend fun Novu.createWorkflowOverride(request: CreateWorkflowOverrideRequest): ResponseWrapper<WorkflowOverride>? { | ||
val response = workflowOverrideApi.createWorkflowOverride(request) | ||
return response.extractResponse(logger) | ||
} | ||
|
||
suspend fun Novu.getWorkflowOverrides(request: GetWorkflowOverrideRequest): PaginatedResponseWrapper<WorkflowOverride>? { | ||
val params: MutableMap<String, Any> = HashMap() | ||
request.page?.let { params["page"] = it } | ||
request.limit?.let { params["limit"] = it } | ||
val response = workflowOverrideApi.getWorkflowOverrides(params) | ||
return response.extractResponse(logger) | ||
} | ||
|
||
suspend fun Novu.getWorkflowOverride(workflowId: String, tenantId: String): ResponseWrapper<WorkflowOverride>? { | ||
val response = workflowOverrideApi.getWorkflowOverride(workflowId, tenantId) | ||
return response.extractResponse(logger) | ||
} | ||
|
||
suspend fun Novu.getWorkflowOverrideById(overrideId: String): ResponseWrapper<WorkflowOverride>? { | ||
val response = workflowOverrideApi.getWorkflowOverrideById(overrideId) | ||
return response.extractResponse(logger) | ||
} | ||
|
||
suspend fun Novu.updateWorkflowOverrideById(overrideId: String, request: UpdateWorkflowOverrideRequest): ResponseWrapper<WorkflowOverride>? { | ||
val response = workflowOverrideApi.updateWorkflowOverrideById(overrideId, request) | ||
return response.extractResponse(logger) | ||
} | ||
|
||
suspend fun Novu.updateWorkflowOverride(workflowId: String, tenantId: String, request: UpdateWorkflowOverrideRequest): ResponseWrapper<WorkflowOverride>? { | ||
val response = workflowOverrideApi.updateWorkflowOverride(workflowId, tenantId, request) | ||
return response.extractResponse(logger) | ||
} | ||
|
||
suspend fun Novu.deleteWorkflowOverride(overrideId: String): ResponseWrapper<Boolean>? { | ||
val response = workflowOverrideApi.deleteWorkflowOverride(overrideId) | ||
return response.extractResponse(logger) | ||
} |
Oops, something went wrong.