Skip to content

Commit cc32835

Browse files
authored
refact(search): replaceExistingSynonyms to clearExistingSynonyms (#610)
1 parent cd02bd0 commit cc32835

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

src/main/scala/algolia/AlgoliaDsl.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,11 @@ object AlgoliaDsl extends AlgoliaDsl {
106106

107107
sealed trait ClearExistingRules
108108

109+
@deprecated("Use ClearExistingSynonyms instead")
109110
sealed trait ReplaceExistingSynonyms
110111

112+
sealed trait ClearExistingSynonyms
113+
111114
sealed trait Of
112115

113116
sealed trait In
@@ -418,8 +421,11 @@ object AlgoliaDsl extends AlgoliaDsl {
418421

419422
case object forwardToReplicas extends ForwardToReplicas
420423

424+
@deprecated("Use clearExistingSynonyms instead")
421425
case object replaceExistingSynonyms extends ReplaceExistingSynonyms
422426

427+
case object clearExistingSynonyms extends ClearExistingSynonyms
428+
423429
case object clearExistingRules extends ClearExistingRules
424430

425431
case object of extends Of

src/main/scala/algolia/definitions/SynonymsDefinition.scala

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@
2525

2626
package algolia.definitions
2727

28-
import algolia.AlgoliaDsl.{ForwardToReplicas, ReplaceExistingSynonyms}
28+
import algolia.AlgoliaDsl.{
29+
ClearExistingSynonyms,
30+
ForwardToReplicas,
31+
ReplaceExistingSynonyms,
32+
clearExistingSynonyms
33+
}
2934
import algolia.http._
3035
import algolia.objects.{AbstractSynonym, QuerySynonyms, RequestOptions}
3136
import org.json4s.Formats
@@ -174,7 +179,7 @@ case class BatchSynonymsDefinition(
174179
synonyms: Iterable[AbstractSynonym],
175180
index: Option[String] = None,
176181
forward: Option[ForwardToReplicas] = None,
177-
replace: Option[ReplaceExistingSynonyms] = None,
182+
replace: Option[ClearExistingSynonyms] = None,
178183
requestOptions: Option[RequestOptions] = None
179184
)(implicit val formats: Formats)
180185
extends Definition {
@@ -187,7 +192,11 @@ case class BatchSynonymsDefinition(
187192
def and(forward: ForwardToReplicas): BatchSynonymsDefinition =
188193
copy(forward = Some(forward))
189194

195+
@deprecated("Use ClearExistingSynonyms instead")
190196
def and(replace: ReplaceExistingSynonyms): BatchSynonymsDefinition =
197+
and(clearExistingSynonyms)
198+
199+
def and(replace: ClearExistingSynonyms): BatchSynonymsDefinition =
191200
copy(replace = Some(replace))
192201

193202
override def options(

src/test/scala/algolia/dsl/SynonymsTest.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
package algolia.dsl
2727

2828
import algolia.AlgoliaDsl._
29+
import algolia.definitions.BatchSynonymsDefinition
2930
import algolia.http._
3031
import algolia.objects.Synonym.Placeholder
3132
import algolia.objects.{QuerySynonyms, SynonymType}
@@ -159,12 +160,12 @@ class SynonymsTest extends AlgoliaTest {
159160
describe("batch") {
160161

161162
it("should save batches synonyms of an index") {
162-
save synonyms Seq(Placeholder("oid", "1", Seq("2", "3"))) inIndex "toto" and forwardToSlaves and replaceExistingSynonyms
163-
save synonyms Seq(Placeholder("oid", "1", Seq("2", "3"))) inIndex "toto" and forwardToReplicas and replaceExistingSynonyms
163+
save synonyms Seq(Placeholder("oid", "1", Seq("2", "3"))) inIndex "toto" and forwardToSlaves and clearExistingSynonyms
164+
save synonyms Seq(Placeholder("oid", "1", Seq("2", "3"))) inIndex "toto" and forwardToReplicas and clearExistingSynonyms
164165
}
165166

166167
it("should call API") {
167-
(save synonyms Seq(Placeholder("oid", "1", Seq("2", "3"))) inIndex "toto" and forwardToReplicas and replaceExistingSynonyms)
168+
(save synonyms Seq(Placeholder("oid", "1", Seq("2", "3"))) inIndex "toto" and forwardToReplicas and clearExistingSynonyms)
168169
.build() should be(
169170
HttpPayload(
170171
POST,

0 commit comments

Comments
 (0)