Skip to content
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

Implement Organizations API #56

Merged
merged 3 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,17 @@ The client methods map directly to the Novu API endpoints. Here is a list of all
- `updateTenant(identifier)`
- `deleteTenant(identifier)`

### Organizations

- `createOrganization(body)`
- `fetchAllOrganizations()`
- `updateOrganizationName(body)`
- `fetchCurrentOrganization()`
- `removeMemberWithId(identifier)`
- `updateMemberRole(identifier, body)`
- `fetchMembersOfOrganization()`
- `updateOrganizationBrand(body)`

### For more information about these methods and their parameters, see the [API documentation](https://docs.novu.co/api-reference/overview).

## Contributing
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/Novu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import co.novu.api.MessagesApi
import co.novu.api.NotificationGroupsApi
import co.novu.api.NotificationTemplatesApi
import co.novu.api.NotificationsApi
import co.novu.api.OrganizationsApi
import co.novu.api.SubscribersApi
import co.novu.api.TenantsApi
import co.novu.api.TopicsApi
Expand Down Expand Up @@ -65,4 +66,6 @@ class Novu(
internal val blueprintsApi by lazy { retrofitInstance.create(BlueprintsApi::class.java) }

internal val tenantsApi by lazy { retrofitInstance.create(TenantsApi::class.java) }

internal val organizationsApi by lazy { retrofitInstance.create(OrganizationsApi::class.java) }
}
8 changes: 6 additions & 2 deletions src/main/kotlin/api/BlueprintsApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ import retrofit2.http.Path

interface BlueprintsApi {

@GET("blueprints/group-by-category")
companion object {
const val ENDPOINT = "blueprints"
}

@GET("$ENDPOINT/group-by-category")
suspend fun getBlueprintsByCategory(): Response<ResponseWrapper<BlueprintsResponse>>

@GET("blueprints/{templateId}")
@GET("$ENDPOINT/{templateId}")
suspend fun getBlueprint(@Path("templateId") templateId: String): Response<Blueprint>
}
12 changes: 8 additions & 4 deletions src/main/kotlin/api/ChangesApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ import java.math.BigInteger

interface ChangesApi {

@GET("changes")
companion object {
const val ENDPOINT = "changes"
}

@GET(ENDPOINT)
suspend fun getChanges(@Query("page") page: BigInteger? = null, @Query("limit") limit: BigInteger? = null, @Query("promoted") promoted: String? = null): Response<PaginatedResponseWrapper<ChangesResponse>>

@GET("changes/count")
@GET("$ENDPOINT/count")
suspend fun getChangesCount(): Response<ResponseWrapper<BigInteger>>

@POST("changes/bulk/apply")
@POST("$ENDPOINT/bulk/apply")
suspend fun applyBulkChanges(@Body request: ChangesRequest): Response<ResponseWrapper<List<ChangesResponse>>>

@POST("changes/{changedId}/apply")
@POST("$ENDPOINT/{changedId}/apply")
suspend fun applyChange(@Path("changedId") changedId: String): Response<ResponseWrapper<List<ChangesResponse>>>
}
18 changes: 11 additions & 7 deletions src/main/kotlin/api/EnvironmentsApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,28 @@ import retrofit2.http.Path

interface EnvironmentsApi {

@GET("environments/me")
companion object {
const val ENDPOINT = "environments"
}

@GET("$ENDPOINT/me")
suspend fun getCurrentEnvironment(): Response<ResponseWrapper<GetEnvironmentResponse>>

@POST("environments")
@POST(ENDPOINT)
suspend fun createEnvironment(@Body request: CreateEnvironmentRequest): Response<ResponseWrapper<GetEnvironmentResponse>>

@GET("environments")
@GET(ENDPOINT)
suspend fun getEnvironments(): Response<ResponseWrapper<List<GetEnvironmentResponse>>>

@PUT("environments/{environmentId}")
@PUT("$ENDPOINT/{environmentId}")
suspend fun updateEnvironment(@Path("environmentId") environmentId: String, @Body request: UpdateEnvironmentRequest): Response<ResponseWrapper<GetEnvironmentResponse>>

@GET("environments/api-keys")
@GET("$ENDPOINT/api-keys")
suspend fun getApiKeys(): Response<ResponseWrapper<List<ApiKeys>>>

@POST("environments/api-keys/regenerate")
@POST("$ENDPOINT/api-keys/regenerate")
suspend fun regenerateApiKey(): Response<ResponseWrapper<List<ApiKeys>>>

@PUT("environments/api-keys/widget/settings")
@PUT("$ENDPOINT/api-keys/widget/settings")
suspend fun updateWidgetSettings(@Body request: Widget): Response<ResponseWrapper<GetEnvironmentResponse>>
}
12 changes: 8 additions & 4 deletions src/main/kotlin/api/EventsApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@ import retrofit2.http.Path

interface EventsApi {

@POST("events/trigger")
companion object {
const val ENDPOINT = "events"
}

@POST("$ENDPOINT/trigger")
suspend fun triggerEvent(@Body body: TriggerEventRequest): Response<ResponseWrapper<TriggerResponse>>

@POST("events/trigger/bulk")
@POST("$ENDPOINT/trigger/bulk")
suspend fun bulkTriggerEvent(@Body body: BulkTriggerEventRequest): Response<ResponseWrapper<TriggerResponse>>

@POST("events/trigger/broadcast")
@POST("$ENDPOINT/trigger/broadcast")
suspend fun broadcastEvent(@Body body: BroadcastEventRequest): Response<ResponseWrapper<TriggerResponse>>

@DELETE("events/trigger/{transactionId}")
@DELETE("$ENDPOINT/trigger/{transactionId}")
suspend fun cancelTriggerEvent(@Path("transactionId") transactionId: String): Response<ResponseWrapper<Boolean>>
}
7 changes: 6 additions & 1 deletion src/main/kotlin/api/ExecutionDetailsApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import retrofit2.http.GET
import retrofit2.http.Query

interface ExecutionDetailsApi {
@GET("execution-details")

companion object {
const val ENDPOINT = "execution-details"
}

@GET(ENDPOINT)
suspend fun getExecutionDetails(
@Query("notificationId") notificationId: String,
@Query("subscriberId") subscriberId: String
Expand Down
10 changes: 7 additions & 3 deletions src/main/kotlin/api/FeedsApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ import retrofit2.http.Path

interface FeedsApi {

@POST("feeds")
companion object {
const val ENDPOINT = "feeds"
}

@POST(ENDPOINT)
suspend fun createFeed(@Body body: CreateByNameRequest): Response<ResponseWrapper<FeedResponse>>

@GET("feeds")
@GET(ENDPOINT)
suspend fun getFeeds(): Response<ResponseWrapper<List<FeedResponse>>>

@DELETE("feeds/{feedId}")
@DELETE("$ENDPOINT/{feedId}")
suspend fun deleteFeed(@Path("feedId") feedId: String): Response<ResponseWrapper<FeedResponse>>
}
6 changes: 5 additions & 1 deletion src/main/kotlin/api/InboundParseApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import retrofit2.http.GET

interface InboundParseApi {

@GET("inbound-parse/mx/status")
companion object {
const val ENDPOINT = "inbound-parse"
}

@GET("$ENDPOINT/mx/status")
suspend fun validateMxRecordSetupForInboundParse(): Response<ValidateMxRecordSetupForInboundParseResponse>
}
19 changes: 12 additions & 7 deletions src/main/kotlin/api/IntegrationsApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,29 @@ import retrofit2.http.PUT
import retrofit2.http.Path

interface IntegrationsApi {
@GET("integrations")

companion object {
const val ENDPOINT = "integrations"
}

@GET(ENDPOINT)
suspend fun getIntegrations(): Response<ResponseWrapper<List<IntegrationResponse>>>

@POST("integrations")
@POST(ENDPOINT)
suspend fun createIntegration(@Body request: IntegrationRequest): Response<ResponseWrapper<IntegrationResponse>>

@GET("integrations/active")
@GET("$ENDPOINT/active")
suspend fun getActiveIntegrations(): Response<ResponseWrapper<List<IntegrationResponse>>>

@GET("integrations/webhook/provider/{providerId}/status")
@GET("$ENDPOINT/webhook/provider/{providerId}/status")
suspend fun getProviderWebhook(@Path("providerId") providerId: String): Response<ResponseWrapper<Boolean>>

@PUT("integrations/{integrationId}")
@PUT("$ENDPOINT/{integrationId}")
suspend fun updateIntegration(@Path("integrationId") integrationId: String, @Body request: IntegrationRequest): Response<ResponseWrapper<IntegrationResponse>>

@DELETE("integrations/{integrationId}")
@DELETE("$ENDPOINT/{integrationId}")
suspend fun deleteIntegration(@Path("integrationId") integrationId: String): Response<ResponseWrapper<List<IntegrationResponse>>>

@POST("integrations/{integrationId}/set-primary")
@POST("$ENDPOINT/{integrationId}/set-primary")
suspend fun setPrimaryIntegration(@Path("integrationId") integrationId: String): Response<ResponseWrapper<IntegrationResponse>>
}
16 changes: 10 additions & 6 deletions src/main/kotlin/api/LayoutsApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,25 @@ import java.math.BigInteger

interface LayoutsApi {

@POST("layouts")
companion object {
const val ENDPOINT = "layouts"
}

@POST(ENDPOINT)
suspend fun createLayout(@Body request: CreateLayoutRequest): Response<ResponseWrapper<CreateLayoutResponse>>

@GET("layouts")
@GET(ENDPOINT)
suspend fun filterLayouts(@Query("page") page: BigInteger, @Query("pageSize") pageSize: BigInteger, @Query("sortBy") sortBy: String, @Query("orderBy") orderBy: BigInteger): Response<PaginatedResponseWrapper<GetLayoutsResponse>>

@GET("layouts/{layoutId}")
@GET("$ENDPOINT/{layoutId}")
suspend fun getLayout(@Path("layoutId") layoutId: String): Response<ResponseWrapper<GetLayoutsResponse>>

@DELETE("layouts/{layoutId}")
@DELETE("$ENDPOINT/{layoutId}")
suspend fun deleteLayout(@Path("layoutId") layoutId: String): Response<Unit>

@PATCH("layouts/{layoutId}")
@PATCH("$ENDPOINT/{layoutId}")
suspend fun updateLayout(@Path("layoutId") layoutId: String, @Body request: CreateLayoutRequest): Response<ResponseWrapper<GetLayoutsResponse>>

@POST("layouts/{layoutId}/default")
@POST("$ENDPOINT/{layoutId}/default")
suspend fun setDefaultLayout(@Path("layoutId") layoutId: String): Response<Unit>
}
9 changes: 7 additions & 2 deletions src/main/kotlin/api/MessagesApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import retrofit2.http.Query
import java.math.BigInteger

interface MessagesApi {
@GET("messages")

companion object {
const val ENDPOINT = "messages"
}

@GET(ENDPOINT)
suspend fun getMessages(
@Query("channel") channel: String? = null,
@Query("subscriberId") subscriberId: String? = null,
Expand All @@ -21,6 +26,6 @@ interface MessagesApi {
@Query("transactionId") transactionId: String? = null
): Response<PaginatedResponseWrapper<Message>>

@DELETE("messages/{messageId}")
@DELETE("$ENDPOINT/{messageId}")
suspend fun deleteMessage(@Path("messageId") messageId: String): Response<ResponseWrapper<TriggerResponse>>
}
15 changes: 10 additions & 5 deletions src/main/kotlin/api/NotificationGroupsApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,23 @@ import retrofit2.http.POST
import retrofit2.http.Path

interface NotificationGroupsApi {
@GET("notification-groups")

companion object {
const val ENDPOINT = "notification-groups"
}

@GET(ENDPOINT)
suspend fun getNotificationGroups(): Response<ResponseWrapper<List<NotificationGroupsResponse>>>

@POST("notification-groups")
@POST(ENDPOINT)
suspend fun createNotificationGroup(@Body request: CreateByNameRequest): Response<ResponseWrapper<NotificationGroupsResponse>>

@GET("notification-groups/{id}")
@GET("$ENDPOINT/{id}")
suspend fun getWorkflowGroup(@Path("id") id: String): Response<ResponseWrapper<NotificationGroupsResponse>>

@PATCH("notification-groups/{id}")
@PATCH("$ENDPOINT/{id}")
suspend fun updateWorkflowGroup(@Path("id") id: String, @Body request: CreateByNameRequest): Response<ResponseWrapper<NotificationGroupsResponse>>

@DELETE("notification-groups/{id}")
@DELETE("$ENDPOINT/{id}")
suspend fun deleteWorkflowGroup(@Path("id") id: String): Response<ResponseWrapper<DeleteWorkflowGroupResponse>>
}
16 changes: 10 additions & 6 deletions src/main/kotlin/api/NotificationTemplatesApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,25 @@ import java.math.BigInteger

interface NotificationTemplatesApi {

@GET("notification-templates")
companion object {
const val ENDPOINT = "notification-templates"
}

@GET(ENDPOINT)
suspend fun getNotificationTemplates(@Query("page") page: BigInteger? = BigInteger.valueOf(1), @Query("limit") limit: BigInteger? = BigInteger.valueOf(10)): Response<PaginatedResponseWrapper<NotificationTemplates>>

@POST("notification-templates")
@POST(ENDPOINT)
suspend fun createNotificationTemplates(@Body request: NotificationTemplates): Response<ResponseWrapper<NotificationTemplates>>

@PUT("notification-templates/{templateId}")
@PUT("$ENDPOINT/{templateId}")
suspend fun updateNotificationTemplates(@Path("templateId") templateId: String, @Body request: NotificationTemplates): Response<ResponseWrapper<NotificationTemplates>>

@DELETE("notification-templates/{templateId}")
@DELETE("$ENDPOINT/{templateId}")
suspend fun deleteNotificationTemplate(@Path("templateId") templateId: String): Response<ResponseWrapper<Boolean>>

@GET("notification-templates/{templateId}")
@GET("$ENDPOINT/{templateId}")
suspend fun getNotificationTemplate(@Path("templateId") templateId: String): Response<ResponseWrapper<NotificationTemplates>>

@PUT("notification-templates/{templateId}/status")
@PUT("$ENDPOINT/{templateId}/status")
suspend fun updateNotificationTemplateStatus(@Path("templateId") templateId: String, @Body request: UpdateNotificationTemplateStatusRequest): Response<ResponseWrapper<NotificationTemplates>>
}
12 changes: 8 additions & 4 deletions src/main/kotlin/api/NotificationsApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import java.math.BigInteger

interface NotificationsApi {

@GET("notifications")
companion object {
const val ENDPOINT = "notifications"
}

@GET(ENDPOINT)
suspend fun getNotifications(
@Query("channels") channels: List<String>?,
@Query("templates") templates: List<String>?,
Expand All @@ -23,12 +27,12 @@ interface NotificationsApi {
@Query("transactionId") transactionId: String?
): Response<PaginatedResponseWrapper<Notification>>

@GET("notifications/stats")
@GET("$ENDPOINT/stats")
suspend fun getNotificationsStats(): Response<ResponseWrapper<NotificationStatsResponse>>

@GET("notifications/graph/stats")
@GET("$ENDPOINT/graph/stats")
suspend fun getNotificationGraphStats(): Response<ResponseWrapper<List<NotificationGraphStatsResponse>>>

@GET("notifications/{notificationId}")
@GET("$ENDPOINT/{notificationId}")
suspend fun getNotification(@Path("notificationId") notificationId: String): Response<ResponseWrapper<Notification>>
}
Loading