Skip to content

Commit cfbaa26

Browse files
mikemillacodegen
andauthored
feat(api): filter notification templates by tag [C-21172] (#171)
Co-authored-by: courier-codegen <codegen@users.noreply.github.com>
1 parent bbc5b8a commit cfbaa26

4 files changed

Lines changed: 33 additions & 3 deletions

File tree

‎courier-java-core/src/main/kotlin/com/courier/models/notifications/NotificationListParams.kt‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ private constructor(
1818
private val cursor: String?,
1919
private val eventId: String?,
2020
private val notes: Boolean?,
21+
private val tags: String?,
2122
private val additionalHeaders: Headers,
2223
private val additionalQueryParams: QueryParams,
2324
) : Params {
@@ -31,6 +32,12 @@ private constructor(
3132
/** Include template notes in the response. Only applies to legacy templates. */
3233
fun notes(): Optional<Boolean> = Optional.ofNullable(notes)
3334

35+
/**
36+
* Comma-delimited list of tag names. Only templates carrying all of the listed tags are
37+
* returned. Matching is case-insensitive. Filtering is applied before pagination.
38+
*/
39+
fun tags(): Optional<String> = Optional.ofNullable(tags)
40+
3441
/** Additional headers to send with the request. */
3542
fun _additionalHeaders(): Headers = additionalHeaders
3643

@@ -53,6 +60,7 @@ private constructor(
5360
private var cursor: String? = null
5461
private var eventId: String? = null
5562
private var notes: Boolean? = null
63+
private var tags: String? = null
5664
private var additionalHeaders: Headers.Builder = Headers.builder()
5765
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
5866

@@ -61,6 +69,7 @@ private constructor(
6169
cursor = notificationListParams.cursor
6270
eventId = notificationListParams.eventId
6371
notes = notificationListParams.notes
72+
tags = notificationListParams.tags
6473
additionalHeaders = notificationListParams.additionalHeaders.toBuilder()
6574
additionalQueryParams = notificationListParams.additionalQueryParams.toBuilder()
6675
}
@@ -90,6 +99,15 @@ private constructor(
9099
/** Alias for calling [Builder.notes] with `notes.orElse(null)`. */
91100
fun notes(notes: Optional<Boolean>) = notes(notes.getOrNull())
92101

102+
/**
103+
* Comma-delimited list of tag names. Only templates carrying all of the listed tags are
104+
* returned. Matching is case-insensitive. Filtering is applied before pagination.
105+
*/
106+
fun tags(tags: String?) = apply { this.tags = tags }
107+
108+
/** Alias for calling [Builder.tags] with `tags.orElse(null)`. */
109+
fun tags(tags: Optional<String>) = tags(tags.getOrNull())
110+
93111
fun additionalHeaders(additionalHeaders: Headers) = apply {
94112
this.additionalHeaders.clear()
95113
putAllAdditionalHeaders(additionalHeaders)
@@ -198,6 +216,7 @@ private constructor(
198216
cursor,
199217
eventId,
200218
notes,
219+
tags,
201220
additionalHeaders.build(),
202221
additionalQueryParams.build(),
203222
)
@@ -211,6 +230,7 @@ private constructor(
211230
cursor?.let { put("cursor", it) }
212231
eventId?.let { put("event_id", it) }
213232
notes?.let { put("notes", it.toString()) }
233+
tags?.let { put("tags", it) }
214234
putAll(additionalQueryParams)
215235
}
216236
.build()
@@ -224,13 +244,14 @@ private constructor(
224244
cursor == other.cursor &&
225245
eventId == other.eventId &&
226246
notes == other.notes &&
247+
tags == other.tags &&
227248
additionalHeaders == other.additionalHeaders &&
228249
additionalQueryParams == other.additionalQueryParams
229250
}
230251

231252
override fun hashCode(): Int =
232-
Objects.hash(cursor, eventId, notes, additionalHeaders, additionalQueryParams)
253+
Objects.hash(cursor, eventId, notes, tags, additionalHeaders, additionalQueryParams)
233254

234255
override fun toString() =
235-
"NotificationListParams{cursor=$cursor, eventId=$eventId, notes=$notes, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
256+
"NotificationListParams{cursor=$cursor, eventId=$eventId, notes=$notes, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
236257
}

‎courier-java-core/src/test/kotlin/com/courier/models/notifications/NotificationListParamsTest.kt‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ internal class NotificationListParamsTest {
1010

1111
@Test
1212
fun create() {
13-
NotificationListParams.builder().cursor("cursor").eventId("event_id").notes(true).build()
13+
NotificationListParams.builder()
14+
.cursor("cursor")
15+
.eventId("event_id")
16+
.notes(true)
17+
.tags("tags")
18+
.build()
1419
}
1520

1621
@Test
@@ -20,6 +25,7 @@ internal class NotificationListParamsTest {
2025
.cursor("cursor")
2126
.eventId("event_id")
2227
.notes(true)
28+
.tags("tags")
2329
.build()
2430

2531
val queryParams = params._queryParams()
@@ -30,6 +36,7 @@ internal class NotificationListParamsTest {
3036
.put("cursor", "cursor")
3137
.put("event_id", "event_id")
3238
.put("notes", "true")
39+
.put("tags", "tags")
3340
.build()
3441
)
3542
}

‎courier-java-core/src/test/kotlin/com/courier/services/async/NotificationServiceAsyncTest.kt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ internal class NotificationServiceAsyncTest {
115115
.cursor("cursor")
116116
.eventId("event_id")
117117
.notes(true)
118+
.tags("tags")
118119
.build()
119120
)
120121

‎courier-java-core/src/test/kotlin/com/courier/services/blocking/NotificationServiceTest.kt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ internal class NotificationServiceTest {
113113
.cursor("cursor")
114114
.eventId("event_id")
115115
.notes(true)
116+
.tags("tags")
116117
.build()
117118
)
118119

0 commit comments

Comments
 (0)