fix postman and clients #325

Merged
RecentRunner merged 2 commits from fix/postman-and-clients into main 2026-04-18 16:19:22 -06:00
12 changed files with 580 additions and 25 deletions

View File

@@ -6,9 +6,12 @@ import com.example.petstoremobile.dtos.PageResponse;
import java.util.List;
import retrofit2.Call;
import com.example.petstoremobile.dtos.BulkDeleteRequest;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.HTTP;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
@@ -39,6 +42,6 @@ public interface CouponApi {
@DELETE("api/v1/coupons/{id}")
Call<Void> deleteCoupon(@Path("id") Long id);
@DELETE("api/v1/coupons")
Call<Void> bulkDeleteCoupons(@Query("ids") List<Long> ids);
@HTTP(method = "DELETE", path = "api/v1/coupons", hasBody = true)
Call<Void> bulkDeleteCoupons(@Body BulkDeleteRequest request);
}

View File

@@ -3,20 +3,20 @@ package com.example.petstoremobile.dtos;
import java.util.List;
public class BulkDeleteRequest {
private List<String> ids;
private List<Long> ids;
public BulkDeleteRequest() {
}
public BulkDeleteRequest(List<String> ids) {
public BulkDeleteRequest(List<Long> ids) {
this.ids = ids;
}
public List<String> getIds() {
public List<Long> getIds() {
return ids;
}
public void setIds(List<String> ids) {
public void setIds(List<Long> ids) {
this.ids = ids;
}
}

View File

@@ -3,6 +3,7 @@ package com.example.petstoremobile.repositories;
import androidx.lifecycle.LiveData;
import com.example.petstoremobile.api.CouponApi;
import com.example.petstoremobile.dtos.BulkDeleteRequest;
import com.example.petstoremobile.dtos.CouponDTO;
import com.example.petstoremobile.dtos.PageResponse;
import com.example.petstoremobile.utils.Resource;
@@ -47,6 +48,6 @@ public class CouponRepository extends BaseRepository {
}
public LiveData<Resource<Void>> bulkDeleteCoupons(List<Long> ids) {
return executeCall(couponApi.bulkDeleteCoupons(ids));
return executeCall(couponApi.bulkDeleteCoupons(new BulkDeleteRequest(ids)));
}
}

View File

@@ -94,6 +94,7 @@ public class AdoptionListViewModel extends ViewModel {
}
public LiveData<Resource<Void>> bulkDeleteAdoptions(List<String> ids) {
return adoptionRepository.bulkDeleteAdoptions(new BulkDeleteRequest(ids));
List<Long> longIds = ids.stream().map(Long::valueOf).collect(java.util.stream.Collectors.toList());
return adoptionRepository.bulkDeleteAdoptions(new BulkDeleteRequest(longIds));
}
}

View File

@@ -92,6 +92,7 @@ public class AppointmentListViewModel extends ViewModel {
}
public LiveData<Resource<Void>> bulkDeleteAppointments(List<String> ids) {
return appointmentRepository.bulkDeleteAppointments(new BulkDeleteRequest(ids));
List<Long> longIds = ids.stream().map(Long::valueOf).collect(java.util.stream.Collectors.toList());
return appointmentRepository.bulkDeleteAppointments(new BulkDeleteRequest(longIds));
}
}

View File

@@ -90,6 +90,7 @@ public class InventoryListViewModel extends ViewModel {
}
public LiveData<Resource<Void>> bulkDeleteInventory(List<String> ids) {
return inventoryRepository.bulkDeleteInventory(new BulkDeleteRequest(ids));
List<Long> longIds = ids.stream().map(Long::valueOf).collect(java.util.stream.Collectors.toList());
return inventoryRepository.bulkDeleteInventory(new BulkDeleteRequest(longIds));
}
}

View File

@@ -113,6 +113,7 @@ public class PetListViewModel extends ViewModel {
}
public LiveData<Resource<Void>> bulkDeletePets(List<String> ids) {
return petRepository.bulkDeletePets(new BulkDeleteRequest(ids));
List<Long> longIds = ids.stream().map(Long::valueOf).collect(java.util.stream.Collectors.toList());
return petRepository.bulkDeletePets(new BulkDeleteRequest(longIds));
}
}

View File

@@ -104,6 +104,7 @@ public class ProductSupplierListViewModel extends ViewModel {
}
public LiveData<Resource<Void>> bulkDeleteProductSuppliers(List<String> ids) {
return psRepository.bulkDeleteProductSuppliers(new BulkDeleteRequest(ids));
List<Long> longIds = ids.stream().map(Long::valueOf).collect(java.util.stream.Collectors.toList());
return psRepository.bulkDeleteProductSuppliers(new BulkDeleteRequest(longIds));
}
}

View File

@@ -77,6 +77,7 @@ public class ServiceListViewModel extends ViewModel {
}
public LiveData<Resource<Void>> bulkDeleteServices(List<String> ids) {
return repository.bulkDeleteServices(new BulkDeleteRequest(ids));
List<Long> longIds = ids.stream().map(Long::valueOf).collect(java.util.stream.Collectors.toList());
return repository.bulkDeleteServices(new BulkDeleteRequest(longIds));
}
}

View File

@@ -78,6 +78,7 @@ public class SupplierListViewModel extends ViewModel {
}
public LiveData<Resource<Void>> bulkDeleteSuppliers(List<String> ids) {
return repository.bulkDeleteSuppliers(new BulkDeleteRequest(ids));
List<Long> longIds = ids.stream().map(Long::valueOf).collect(java.util.stream.Collectors.toList());
return repository.bulkDeleteSuppliers(new BulkDeleteRequest(longIds));
}
}

View File

@@ -203,7 +203,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"username\": \"newcustomer{{$timestamp}}\",\n \"password\": \"password123\",\n \"email\": \"new{{$timestamp}}@example.com\",\n \"phone\": \"+1-555-01{{$randomInt}}\",\n \"fullName\": \"New Customer\"\n}"
"raw": "{\n \"username\": \"newcustomer{{$timestamp}}\",\n \"password\": \"password123\",\n \"email\": \"new{{$timestamp}}@example.com\",\n \"phone\": \"+1-555-01{{$randomInt}}\",\n \"firstName\": \"New\",\n \"lastName\": \"Customer\"\n}"
}
},
"event": [
@@ -248,8 +248,6 @@
" pm.response.to.have.status(200);",
"});",
"var jsonData = pm.response.json();",
"if (jsonData.id !== undefined) pm.collectionVariables.set('userId', jsonData.id);",
"if (jsonData.id !== undefined) pm.collectionVariables.set('customerId', jsonData.id);",
"if (jsonData.token) pm.collectionVariables.set('customerToken', jsonData.token);"
]
}
@@ -583,6 +581,132 @@
}
}
]
},
{
"name": "Forgot Password",
"request": {
"method": "POST",
"url": "{{baseUrl}}/api/v1/auth/forgot-password",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"usernameOrEmail\": \"admin\"\n}"
}
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
]
},
{
"name": "Reset Password",
"request": {
"method": "POST",
"url": "{{baseUrl}}/api/v1/auth/reset-password",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"token\": \"{{resetToken}}\",\n \"newPassword\": \"newpassword123\"\n}"
}
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
]
},
{
"name": "Admin Upload User Avatar",
"request": {
"method": "POST",
"url": "{{baseUrl}}/api/v1/users/{{userId}}/avatar",
"header": [
{
"key": "Authorization",
"value": "Bearer {{adminToken}}"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "avatar",
"type": "file",
"src": "{{avatarFile}}"
}
]
}
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
]
},
{
"name": "Admin Delete User Avatar",
"request": {
"method": "DELETE",
"url": "{{baseUrl}}/api/v1/users/{{userId}}/avatar",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{adminToken}}"
}
]
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
]
}
]
},
@@ -1117,13 +1241,35 @@
" pm.response.to.have.status(200);",
"});",
"var jsonData = pm.response.json();",
"var items = jsonData.items || [];",
"var productId = Number(pm.collectionVariables.get('productId'));",
"var cartItem = items.find(function (item) { return item.prodId === productId; }) || items[0];",
"pm.test('cart item is returned', function () {",
" pm.expect(cartItem).to.exist;",
"});",
"if (cartItem && cartItem.cartItemId !== undefined) pm.collectionVariables.set('cartItemId', cartItem.cartItemId);"
"pm.test('pet response returned', function () {",
" pm.expect(jsonData.petId).to.exist;",
"});"
]
}
}
]
},
{
"name": "Dropdown: Pet Breeds",
"request": {
"method": "GET",
"url": "{{baseUrl}}/api/v1/dropdowns/pet-breeds?species=Dog",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
]
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
@@ -1756,6 +1902,36 @@
}
}
]
},
{
"name": "Get My Orders",
"request": {
"method": "GET",
"url": "{{baseUrl}}/api/v1/sales/my?page=0&size=10",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{customerToken}}"
}
]
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
]
}
]
},
@@ -2119,6 +2295,96 @@
}
}
]
},
{
"name": "Apply Loyalty Points",
"request": {
"method": "POST",
"url": "{{baseUrl}}/api/v1/cart/apply-points?storeId={{storeId}}&useLoyaltyPoints=true",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{customerToken}}"
}
]
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
]
},
{
"name": "Remove Coupon",
"request": {
"method": "DELETE",
"url": "{{baseUrl}}/api/v1/cart/coupon?storeId={{storeId}}",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{customerToken}}"
}
]
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
]
},
{
"name": "Cancel Checkout",
"request": {
"method": "POST",
"url": "{{baseUrl}}/api/v1/cart/checkout/cancel?storeId={{storeId}}",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{customerToken}}"
}
]
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 204', function () {",
" pm.response.to.have.status(204);",
"});"
]
}
}
]
}
]
},
@@ -3305,6 +3571,66 @@
}
}
]
},
{
"name": "Cancel Appointment",
"request": {
"method": "PATCH",
"url": "{{baseUrl}}/api/v1/appointments/{{appointmentId}}/cancel",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{customerToken}}"
}
]
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
]
},
{
"name": "Get Customer Pets Dropdown",
"request": {
"method": "GET",
"url": "{{baseUrl}}/api/v1/dropdowns/customers/{{customerId}}/pets",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{adminToken}}"
}
]
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
]
}
]
},
@@ -3553,6 +3879,70 @@
}
}
]
},
{
"name": "Request Adoption",
"request": {
"method": "POST",
"url": "{{baseUrl}}/api/v1/adoptions/request",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{customerToken}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"petId\": 1,\n \"adoptionDate\": \"2026-05-01\"\n}"
}
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 201', function () {",
" pm.response.to.have.status(201);",
"});"
]
}
}
]
},
{
"name": "Cancel Adoption",
"request": {
"method": "PATCH",
"url": "{{baseUrl}}/api/v1/adoptions/{{adoptionId}}/cancel",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{customerToken}}"
}
]
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
]
}
]
},
@@ -4733,6 +5123,40 @@
}
}
]
},
{
"name": "Bulk Delete Customers",
"request": {
"method": "POST",
"url": "{{baseUrl}}/api/v1/customers/bulk-delete",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{adminToken}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"ids\": [\n 0\n ]\n}"
}
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 204', function () {",
" pm.response.to.have.status(204);",
"});"
]
}
}
]
}
]
},
@@ -6770,6 +7194,119 @@
]
}
]
},
{
"name": "Activity Logs",
"item": [
{
"name": "Get Activity Logs",
"request": {
"method": "GET",
"url": "{{baseUrl}}/api/v1/activity-logs?limit=50",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{adminToken}}"
}
]
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
]
}
]
},
{
"name": "Contact",
"item": [
{
"name": "Send Contact Message",
"request": {
"method": "POST",
"url": "{{baseUrl}}/api/v1/contact",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{customerToken}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"subject\": \"Question about adoption\",\n \"body\": \"I would like to know more about the adoption process.\"\n}"
}
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
]
}
]
},
{
"name": "AI Chat",
"item": [
{
"name": "Send AI Chat Message",
"request": {
"method": "POST",
"url": "{{baseUrl}}/api/v1/ai-chat/message",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{customerToken}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"message\": \"What services do you offer?\",\n \"history\": []\n}"
}
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
]
}
]
}
]
}
}

View File

@@ -41,4 +41,11 @@ public class AuthApi {
body.put("usernameOrEmail", usernameOrEmail);
apiClient.post("/api/v1/auth/forgot-password", body, Object.class);
}
public void resetPassword(String token, String newPassword) throws Exception {
Map<String, String> body = new HashMap<>();
body.put("token", token);
body.put("newPassword", newPassword);
apiClient.post("/api/v1/auth/reset-password", body, Object.class);
}
}