From 39fd07f325f5b2ca379b4cae67ca4e0907489cd5 Mon Sep 17 00:00:00 2001
From: Dimitrije Bulaja <dbulaja98@gmail.com>
Date: Tue, 9 May 2023 16:11:09 +0200
Subject: [PATCH] Refactor Bulk response (#210)

---
 .../executor/response/Item.scala              | 32 +++++++++----------
 .../HttpElasticExecutorSpec.scala             |  4 +--
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/modules/library/src/main/scala/zio/elasticsearch/executor/response/Item.scala b/modules/library/src/main/scala/zio/elasticsearch/executor/response/Item.scala
index 5f39ea1e1..db1ac7a43 100644
--- a/modules/library/src/main/scala/zio/elasticsearch/executor/response/Item.scala
+++ b/modules/library/src/main/scala/zio/elasticsearch/executor/response/Item.scala
@@ -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")
@@ -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")
@@ -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")
@@ -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")
@@ -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]
 }
diff --git a/modules/library/src/test/scala/zio/elasticsearch/HttpElasticExecutorSpec.scala b/modules/library/src/test/scala/zio/elasticsearch/HttpElasticExecutorSpec.scala
index 8f323643d..8d73b2e4d 100644
--- a/modules/library/src/test/scala/zio/elasticsearch/HttpElasticExecutorSpec.scala
+++ b/modules/library/src/test/scala/zio/elasticsearch/HttpElasticExecutorSpec.scala
@@ -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
@@ -59,7 +59,7 @@ object HttpElasticExecutorSpec extends SttpBackendStubSpec {
               took = 3,
               errors = false,
               items = List(
-                Create(
+                CreateBulkResponse(
                   index = "repositories",
                   id = "123",
                   version = Some(1),