diff --git a/pom.xml b/pom.xml
index 4156cce..b105299 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.unq-ui
mercadolibreModel
- 1.3.0
+ 1.4.0
jar
org.example mercadolibreModel
diff --git a/readme.md b/readme.md
index 9167db9..7bd0773 100644
--- a/readme.md
+++ b/readme.md
@@ -22,7 +22,7 @@ Agregar la dependencia:
com.github.unq-ui
mercadolibre-model
- v1.3.0
+ v1.4.0
```
@@ -194,7 +194,7 @@ class MercadoLibreService {
* Completes a purchase for a user.
* @param idUser The user's ID.
* @param payment The payment information.
- * @throws BuyException if the cart is empty or items are out of stock.
+ * @throws PurchaseException if the cart is empty or items are out of stock.
* @throws UserException if the user is not found.
*/
fun purchase(idUser: String, payment: Payment)
@@ -257,7 +257,7 @@ class User(
val email: String,
var password: String,
val image: String,
- val buyHistory: MutableList,
+ val purchaseHistory: MutableList,
val products: MutableList,
val likedProducts: MutableList,
val salesHistory: MutableList
@@ -277,7 +277,7 @@ class SaleHistory(
val user: User,
)
-class BuyHistory(
+class PurchaseHistory(
val items: MutableList- ,
val payment: Payment,
val date: LocalDateTime,
diff --git a/src/main/kotlin/model/DataClasses.kt b/src/main/kotlin/model/DataClasses.kt
index 84b517c..94ea409 100644
--- a/src/main/kotlin/model/DataClasses.kt
+++ b/src/main/kotlin/model/DataClasses.kt
@@ -30,7 +30,7 @@ class SaleHistory(
val user: User,
)
-class BuyHistory(
+class PurchaseHistory(
val items: MutableList
- ,
val payment: Payment,
val date: LocalDateTime,
@@ -44,7 +44,7 @@ class User(
val email: String,
var password: String,
val image: String,
- val buyHistory: MutableList,
+ val purchaseHistory: MutableList,
val products: MutableList,
val likedProducts: MutableList,
val salesHistory: MutableList
diff --git a/src/main/kotlin/model/Exceptions.kt b/src/main/kotlin/model/Exceptions.kt
index cd1f083..029d9f8 100644
--- a/src/main/kotlin/model/Exceptions.kt
+++ b/src/main/kotlin/model/Exceptions.kt
@@ -6,7 +6,7 @@ class ProductException(msg: String): Exception(msg)
class PageException(msg: String): Exception(msg)
-class BuyException(msg: String): Exception(msg)
+class PurchaseException(msg: String): Exception(msg)
class CategoryException(msg: String): Exception(msg)
diff --git a/src/main/kotlin/service/MercadoLibreService.kt b/src/main/kotlin/service/MercadoLibreService.kt
index 0cdfbf7..4a6230e 100644
--- a/src/main/kotlin/service/MercadoLibreService.kt
+++ b/src/main/kotlin/service/MercadoLibreService.kt
@@ -273,13 +273,13 @@ class MercadoLibreService {
* Completes a purchase for a user.
* @param idUser The user's ID.
* @param payment The payment information.
- * @throws BuyException if the cart is empty or items are out of stock.
+ * @throws PurchaseException if the cart is empty or items are out of stock.
* @throws UserException if the user is not found.
*/
fun purchase(idUser: String, payment: Payment) {
val user = getUser(idUser)
val cart = getCart(idUser)
- if (cart.items.isEmpty()) throw BuyException("Cart is empty")
+ if (cart.items.isEmpty()) throw PurchaseException("Cart is empty")
if (cart.items.all { it.product.stock >= it.amount }) {
cart.items.forEach {
it.product.stock -= it.amount
@@ -287,10 +287,10 @@ class MercadoLibreService {
SaleHistory(it.product, it.amount, payment, LocalDateTime.now(), cart.user)
)
}
- user.buyHistory.add(BuyHistory(cart.items, payment, LocalDateTime.now()))
+ user.purchaseHistory.add(PurchaseHistory(cart.items, payment, LocalDateTime.now()))
carts.remove(cart)
} else {
- throw BuyException("Unable to complete the purchase because one or more items are out of stock.")
+ throw PurchaseException("Unable to complete the purchase because one or more items are out of stock.")
}
}
diff --git a/src/test/kotlin/service/MercadoLibreServiceTest.kt b/src/test/kotlin/service/MercadoLibreServiceTest.kt
index 82e6a5b..baeee4a 100644
--- a/src/test/kotlin/service/MercadoLibreServiceTest.kt
+++ b/src/test/kotlin/service/MercadoLibreServiceTest.kt
@@ -334,7 +334,7 @@ class MercadoLibreServiceTest {
mercadoLibreService.updateItemCart(buyer.id, p1.id, 1)
assertEquals(seller.salesHistory.size, 0)
- assertEquals(buyer.buyHistory.size, 0)
+ assertEquals(buyer.purchaseHistory.size, 0)
assertEquals(p1.stock, 10)
val payment = Payment("3333", LocalDateTime.now(), "333", "pepe")
@@ -346,8 +346,8 @@ class MercadoLibreServiceTest {
assertEquals(seller.salesHistory[0].product, p1)
assertEquals(seller.salesHistory[0].payment, payment)
- assertEquals(buyer.buyHistory.size, 1)
- assertEquals(buyer.buyHistory[0].items[0].product, p1)
+ assertEquals(buyer.purchaseHistory.size, 1)
+ assertEquals(buyer.purchaseHistory[0].items[0].product, p1)
assertEquals(p1.stock, 9)
}
@@ -356,7 +356,7 @@ class MercadoLibreServiceTest {
fun purchaseWithoutItemsTest() {
val mercadoLibreService = MercadoLibreService()
val buyer = mercadoLibreService.registerNewUser(getDraftNewUser("user"))
- assertFailsWith {
+ assertFailsWith {
mercadoLibreService.purchase(buyer.id, Payment("3333", LocalDateTime.now(), "333", "pepe"))
}
}
@@ -369,7 +369,7 @@ class MercadoLibreServiceTest {
val p1 = mercadoLibreService.addProduct(seller.id, getDraftProduct("product"))
mercadoLibreService.updateItemCart(buyer.id, p1.id, 100)
- assertFailsWith {
+ assertFailsWith {
mercadoLibreService.purchase(buyer.id, Payment("3333", LocalDateTime.now(), "333", "pepe"))
}
}