Skip to content

Commit

Permalink
Refactor Bulk response (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbulaja98 authored May 9, 2023
1 parent 5c9d907 commit 39fd07f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ sealed trait Item {
def error: Option[Error]
}

private[elasticsearch] object Item {
implicit val decoder: JsonDecoder[Item] = DeriveJsonDecoder.gen[Item]
}

@jsonHint("create")
final case class Create private[elasticsearch] (
final case class CreateBulkResponse private[elasticsearch] (
@jsonField("_index")
index: String,
@jsonField("_id")
Expand All @@ -43,12 +47,12 @@ final case class Create private[elasticsearch] (
error: Option[Error]
) extends Item

private[elasticsearch] object Create {
implicit val decoder: JsonDecoder[Create] = DeriveJsonDecoder.gen[Create]
private[elasticsearch] object CreateBulkResponse {
implicit val decoder: JsonDecoder[CreateBulkResponse] = DeriveJsonDecoder.gen[CreateBulkResponse]
}

@jsonHint("delete")
final case class Delete private[elasticsearch] (
final case class DeleteBulkResponse private[elasticsearch] (
@jsonField("_index")
index: String,
@jsonField("_id")
Expand All @@ -62,12 +66,12 @@ final case class Delete private[elasticsearch] (
error: Option[Error]
) extends Item

private[elasticsearch] object Delete {
implicit val decoder: JsonDecoder[Delete] = DeriveJsonDecoder.gen[Delete]
private[elasticsearch] object DeleteBulkResponse {
implicit val decoder: JsonDecoder[DeleteBulkResponse] = DeriveJsonDecoder.gen[DeleteBulkResponse]
}

@jsonHint("index")
final case class Index private[elasticsearch] (
final case class IndexBulkResponse private[elasticsearch] (
@jsonField("_index")
index: String,
@jsonField("_id")
Expand All @@ -81,12 +85,12 @@ final case class Index private[elasticsearch] (
error: Option[Error]
) extends Item

private[elasticsearch] object Index {
implicit val decoder: JsonDecoder[Index] = DeriveJsonDecoder.gen[Index]
private[elasticsearch] object IndexBulkResponse {
implicit val decoder: JsonDecoder[IndexBulkResponse] = DeriveJsonDecoder.gen[IndexBulkResponse]
}

@jsonHint("update")
final case class Update private[elasticsearch] (
final case class UpdateBulkResponse private[elasticsearch] (
@jsonField("_index")
index: String,
@jsonField("_id")
Expand All @@ -100,10 +104,6 @@ final case class Update private[elasticsearch] (
error: Option[Error]
) extends Item

private[elasticsearch] object Update {
implicit val decoder: JsonDecoder[Update] = DeriveJsonDecoder.gen[Update]
}

private[elasticsearch] object Item {
implicit val decoder: JsonDecoder[Item] = DeriveJsonDecoder.gen[Item]
private[elasticsearch] object UpdateBulkResponse {
implicit val decoder: JsonDecoder[UpdateBulkResponse] = DeriveJsonDecoder.gen[UpdateBulkResponse]
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import zio.elasticsearch.domain.TestDocument
import zio.elasticsearch.executor.Executor
import zio.elasticsearch.executor.response.{
BulkResponse,
Create,
CreateBulkResponse,
Shards,
TermsAggregationBucket,
TermsAggregationResponse
Expand Down Expand Up @@ -59,7 +59,7 @@ object HttpElasticExecutorSpec extends SttpBackendStubSpec {
took = 3,
errors = false,
items = List(
Create(
CreateBulkResponse(
index = "repositories",
id = "123",
version = Some(1),
Expand Down

0 comments on commit 39fd07f

Please sign in to comment.