Skip to content

Commit 1289cdf

Browse files
authored
Add other response type support (#26)
* Add other response type support * Updated version * Added other response type support * Minor update
1 parent fcce0b3 commit 1289cdf

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ dependencies {
5050
testImplementation("org.springframework.boot:spring-boot-starter-test")
5151
testImplementation("io.projectreactor:reactor-test")
5252

53-
implementation("com.hrv.mart:api-call:0.0.2")
53+
implementation("com.hrv.mart:api-call:0.0.3")
5454
}
5555

5656
tasks.withType<KotlinCompile> {

src/main/kotlin/com/hrv/mart/product/repository/ProductRepository.kt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.hrv.mart.apicall.APICaller
44
import com.hrv.mart.product.Product
55
import org.springframework.beans.factory.annotation.Autowired
66
import org.springframework.beans.factory.annotation.Value
7+
import org.springframework.http.server.reactive.ServerHttpResponse
78
import org.springframework.stereotype.Repository
89
import org.springframework.web.reactive.function.client.WebClient
910

@@ -15,19 +16,23 @@ class ProductRepository (
1516
private val productURL: String
1617
)
1718
{
18-
fun getProductByProductId(productId: String) =
19+
fun getProductByProductId(productId: String, response: ServerHttpResponse?) =
1920
APICaller(webClientBuilder)
20-
.getData("${productURL}/${productId}", Product::class.java)
21-
fun getCostOfProductByProductId(productId: String) =
22-
getProductByProductId(productId)
21+
.getData(
22+
"${productURL}/${productId}",
23+
Product::class.java,
24+
response
25+
)
26+
fun getCostOfProductByProductId(productId: String, response: ServerHttpResponse? = null) =
27+
getProductByProductId(productId, response)
2328
.map { it.price }
24-
fun createProduct(product: Product) =
29+
fun createProduct(product: Product, response: ServerHttpResponse) =
2530
APICaller(webClientBuilder)
26-
.postRequest(productURL, String::class.java, product)
27-
fun updateProduct(product: Product) =
31+
.postRequest(productURL, String::class.java, product, response)
32+
fun updateProduct(product: Product, response: ServerHttpResponse) =
2833
APICaller(webClientBuilder)
29-
.putRequest(productURL, String::class.java, product)
30-
fun deleteProduct(productId: String) =
34+
.putRequest(productURL, String::class.java, product, response)
35+
fun deleteProduct(productId: String, response: ServerHttpResponse) =
3136
APICaller(webClientBuilder)
32-
.deleteData("${productURL}/${productId}", String::class.java)
37+
.deleteData("${productURL}/${productId}", String::class.java, response)
3338
}

0 commit comments

Comments
 (0)