From 71f8114e54cd7aa6524adba8496da62be182fa59 Mon Sep 17 00:00:00 2001 From: spec-agent-generator Date: Tue, 17 Nov 2026 21:09:40 +0000 Subject: [PATCH] auto-gen: SDK changes --- .../mercadopago/client/store/StoreClient.java | 316 ++++++++++++++++++ .../client/store/StoreCreateRequest.java | 27 ++ .../client/store/StoreUpdateRequest.java | 25 ++ .../mercadopago/resources/store/Store.java | 41 +++ .../client/store/StoreClientTest.java | 253 ++++++++++++++ .../mocks/request/store/store_base.json | 11 + .../mocks/request/store/store_update.json | 3 + .../mocks/response/store/store_base.json | 54 +++ .../mocks/response/store/store_list.json | 70 ++++ 9 files changed, 800 insertions(+) create mode 100644 src/main/java/com/mercadopago/client/store/StoreClient.java create mode 100644 src/main/java/com/mercadopago/client/store/StoreCreateRequest.java create mode 100644 src/main/java/com/mercadopago/client/store/StoreUpdateRequest.java create mode 100644 src/main/java/com/mercadopago/resources/store/Store.java create mode 100644 src/test/java/com/mercadopago/client/store/StoreClientTest.java create mode 100644 src/test/java/com/mercadopago/resources/mocks/request/store/store_base.json create mode 100644 src/test/java/com/mercadopago/resources/mocks/request/store/store_update.json create mode 100644 src/test/java/com/mercadopago/resources/mocks/response/store/store_base.json create mode 100644 src/test/java/com/mercadopago/resources/mocks/response/store/store_list.json diff --git a/src/main/java/com/mercadopago/client/store/StoreClient.java b/src/main/java/com/mercadopago/client/store/StoreClient.java new file mode 100644 index 00000000..e9c59fe9 --- /dev/null +++ b/src/main/java/com/mercadopago/client/store/StoreClient.java @@ -0,0 +1,316 @@ +package com.mercadopago.client.store; + +import static com.mercadopago.MercadoPagoConfig.getStreamHandler; +import static com.mercadopago.serialization.Serializer.deserializeFromJson; + +import static com.mercadopago.serialization.Serializer.deserializeElementsResourcesPageFromJson; + +import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; +import com.mercadopago.MercadoPagoConfig; +import com.mercadopago.client.MercadoPagoClient; +import com.mercadopago.core.MPRequestOptions; +import com.mercadopago.exceptions.MPApiException; +import com.mercadopago.exceptions.MPException; +import com.mercadopago.net.HttpMethod; +import com.mercadopago.net.MPElementsResourcesPage; +import com.mercadopago.net.MPHttpClient; +import com.mercadopago.net.MPRequest; +import com.mercadopago.net.MPResponse; +import com.mercadopago.net.MPSearchRequest; +import com.mercadopago.resources.store.Store; +import com.mercadopago.serialization.Serializer; +import java.lang.reflect.Type; +import java.util.logging.Logger; +import java.util.logging.StreamHandler; + +/** + * Client for the MercadoPago Stores API. + * + *

Provides operations to create, retrieve, search, update, and delete stores associated with a + * MercadoPago user. Stores represent physical locations where payments can be collected in person. + * + *

Usage example: + *

{@code
+ * StoreClient client = new StoreClient();
+ * Store store = client.createStore(userId, storeCreateRequest);
+ * Store retrieved = client.getStore(store.getId());
+ * }
+ * + * @see + * Stores API reference + */ +public class StoreClient extends MercadoPagoClient { + + /** Class-level logger for store operations. */ + private static final Logger LOGGER = Logger.getLogger(StoreClient.class.getName()); + + /** URL template for store endpoints scoped to a user (e.g. {@code /users/{user_id}/stores}). */ + private static final String URL_WITH_USER_ID = "/users/%s/stores"; + + /** URL template for store endpoints scoped to a user and a store id. */ + private static final String URL_WITH_USER_ID_AND_ID = "/users/%s/stores/%s"; + + /** URL template for the single-store endpoint (e.g. {@code /stores/{id}}). */ + private static final String URL_WITH_ID = "/stores/%s"; + + /** URL template for the store search endpoint scoped to a user. */ + private static final String URL_SEARCH_WITH_USER_ID = "/users/%s/stores/search"; + + /** Default constructor. Uses the default HTTP client provided by {@link MercadoPagoConfig}. */ + public StoreClient() { + this(MercadoPagoConfig.getHttpClient()); + } + + /** + * Constructs a {@code StoreClient} with a custom HTTP client. + * + * @param httpClient the {@link MPHttpClient} implementation used to execute HTTP requests + */ + public StoreClient(MPHttpClient httpClient) { + super(httpClient); + StreamHandler streamHandler = getStreamHandler(); + streamHandler.setLevel(MercadoPagoConfig.getLoggingLevel()); + LOGGER.addHandler(streamHandler); + LOGGER.setLevel(MercadoPagoConfig.getLoggingLevel()); + } + + /** + * Creates a new store for the given user. + * + * @param userId the identifier of the user that will own the store + * @param request the {@link StoreCreateRequest} with the store details (name, business hours, + * location, etc.) + * @return the created {@link Store} + * @throws MPException if a transport-level or SDK-internal error occurs + * @throws MPApiException if the API returns a non-successful HTTP status code + * @see api + * docs + */ + public Store createStore(Long userId, StoreCreateRequest request) + throws MPException, MPApiException { + return this.createStore(userId, request, null); + } + + /** + * Creates a new store for the given user with custom request options. + * + * @param userId the identifier of the user that will own the store + * @param request the {@link StoreCreateRequest} with the store details (name, business hours, + * location, etc.) + * @param requestOptions optional {@link MPRequestOptions} to override access token, headers, or + * timeouts for this single request; may be {@code null} + * @return the created {@link Store} + * @throws MPException if a transport-level or SDK-internal error occurs + * @throws MPApiException if the API returns a non-successful HTTP status code + * @see api + * docs + */ + public Store createStore(Long userId, StoreCreateRequest request, MPRequestOptions requestOptions) + throws MPException, MPApiException { + LOGGER.info("Sending create store request"); + + MPRequest mpRequest = + MPRequest.builder() + .uri(String.format(URL_WITH_USER_ID, userId.toString())) + .method(HttpMethod.POST) + .payload(Serializer.serializeToJson(request)) + .build(); + + MPResponse response = send(mpRequest, requestOptions); + Store result = deserializeFromJson(Store.class, response.getContent()); + result.setResponse(response); + + return result; + } + + /** + * Retrieves a store by its unique identifier. + * + * @param id the unique identifier of the store + * @return the requested {@link Store} + * @throws MPException if a transport-level or SDK-internal error occurs + * @throws MPApiException if the API returns a non-successful HTTP status code + * @see api + * docs + */ + public Store getStore(Long id) throws MPException, MPApiException { + return this.getStore(id, null); + } + + /** + * Retrieves a store by its unique identifier with custom request options. + * + * @param id the unique identifier of the store + * @param requestOptions optional {@link MPRequestOptions} to override access token, headers, or + * timeouts for this single request; may be {@code null} + * @return the requested {@link Store} + * @throws MPException if a transport-level or SDK-internal error occurs + * @throws MPApiException if the API returns a non-successful HTTP status code + * @see api + * docs + */ + public Store getStore(Long id, MPRequestOptions requestOptions) throws MPException, MPApiException { + LOGGER.info("Sending get store request"); + + MPRequest mpRequest = + MPRequest.builder() + .uri(String.format(URL_WITH_ID, id.toString())) + .method(HttpMethod.GET) + .build(); + + MPResponse response = send(mpRequest, requestOptions); + Store result = deserializeFromJson(Store.class, response.getContent()); + result.setResponse(response); + + return result; + } + + /** + * Searches for stores belonging to the given user matching the specified criteria. + * + * @param userId the identifier of the user that owns the stores + * @param request the {@link MPSearchRequest} containing search filters and pagination parameters + * @return an {@link MPResultsResourcesPage} of {@link Store} with matching results and paging + * metadata + * @throws MPException if a transport-level or SDK-internal error occurs + * @throws MPApiException if the API returns a non-successful HTTP status code + * @see api + * docs + */ + public MPElementsResourcesPage searchStores(Long userId, MPSearchRequest request) + throws MPException, MPApiException { + return this.searchStores(userId, request, null); + } + + /** + * Searches for stores belonging to the given user matching the specified criteria with custom + * request options. + * + * @param userId the identifier of the user that owns the stores + * @param request the {@link MPSearchRequest} containing search filters and pagination parameters + * @param requestOptions optional {@link MPRequestOptions} to override access token, headers, or + * timeouts for this single request; may be {@code null} + * @return an {@link MPResultsResourcesPage} of {@link Store} with matching results and paging + * metadata + * @throws MPException if a transport-level or SDK-internal error occurs + * @throws MPApiException if the API returns a non-successful HTTP status code + * @see api + * docs + */ + public MPResultsResourcesPage searchStores( + Long userId, MPSearchRequest request, MPRequestOptions requestOptions) + throws MPException, MPApiException { + LOGGER.info("Sending search stores request"); + + MPResponse response = + search(String.format(URL_SEARCH_WITH_USER_ID, userId.toString()), request, requestOptions); + + Type responseType = new TypeToken>() {}.getType(); + MPElementsResourcesPage result = + deserializeElementsResourcesPageFromJson(responseType, response.getContent()); + result.setResponse(response); + + return result; + } + + /** + * Updates an existing store. + * + * @param userId the identifier of the user that owns the store + * @param id the unique identifier of the store to update + * @param request the {@link StoreUpdateRequest} with the updated attributes + * @return the updated {@link Store} + * @throws MPException if a transport-level or SDK-internal error occurs + * @throws MPApiException if the API returns a non-successful HTTP status code + * @see api + * docs + */ + public Store updateStore(Long userId, Long id, StoreUpdateRequest request) + throws MPException, MPApiException { + return this.updateStore(userId, id, request, null); + } + + /** + * Updates an existing store with custom request options. + * + * @param userId the identifier of the user that owns the store + * @param id the unique identifier of the store to update + * @param request the {@link StoreUpdateRequest} with the updated attributes + * @param requestOptions optional {@link MPRequestOptions} to override access token, headers, or + * timeouts for this single request; may be {@code null} + * @return the updated {@link Store} + * @throws MPException if a transport-level or SDK-internal error occurs + * @throws MPApiException if the API returns a non-successful HTTP status code + * @see api + * docs + */ + public Store updateStore( + Long userId, Long id, StoreUpdateRequest request, MPRequestOptions requestOptions) + throws MPException, MPApiException { + LOGGER.info("Sending update store request"); + + MPRequest mpRequest = + MPRequest.builder() + .uri(String.format(URL_WITH_USER_ID_AND_ID, userId.toString(), id.toString())) + .method(HttpMethod.PUT) + .payload(Serializer.serializeToJson(request)) + .build(); + + MPResponse response = send(mpRequest, requestOptions); + Store result = deserializeFromJson(Store.class, response.getContent()); + result.setResponse(response); + + return result; + } + + /** + * Deletes an existing store. + * + * @param userId the identifier of the user that owns the store + * @param id the unique identifier of the store to delete + * @throws MPException if a transport-level or SDK-internal error occurs + * @throws MPApiException if the API returns a non-successful HTTP status code + * @see api + * docs + */ + public void deleteStore(Long userId, Long id) throws MPException, MPApiException { + this.deleteStore(userId, id, null); + } + + /** + * Deletes an existing store with custom request options. + * + * @param userId the identifier of the user that owns the store + * @param id the unique identifier of the store to delete + * @param requestOptions optional {@link MPRequestOptions} to override access token, headers, or + * timeouts for this single request; may be {@code null} + * @throws MPException if a transport-level or SDK-internal error occurs + * @throws MPApiException if the API returns a non-successful HTTP status code + * @see api + * docs + */ + public void deleteStore(Long userId, Long id, MPRequestOptions requestOptions) + throws MPException, MPApiException { + LOGGER.info("Sending delete store request"); + + MPRequest mpRequest = + MPRequest.builder() + .uri(String.format(URL_WITH_USER_ID_AND_ID, userId.toString(), id.toString())) + .method(HttpMethod.DELETE) + .build(); + + send(mpRequest, requestOptions); + } +} diff --git a/src/main/java/com/mercadopago/client/store/StoreCreateRequest.java b/src/main/java/com/mercadopago/client/store/StoreCreateRequest.java new file mode 100644 index 00000000..3e82a2a3 --- /dev/null +++ b/src/main/java/com/mercadopago/client/store/StoreCreateRequest.java @@ -0,0 +1,27 @@ +package com.mercadopago.client.store; + +import lombok.Builder; +import lombok.Getter; + +/** + * Request DTO used to create a new Store through the + * POST /users/{user_id}/stores endpoint. A store represents a physical + * branch of a merchant where payments can be collected. + * + *

The request body is kept opaque with respect to nested structures: only the documented + * fields are exposed, without imposing any requiredness or validation rules.

+ * + * @see Stores API Reference + */ +@Getter +@Builder +public class StoreCreateRequest { + /** Name of the store. */ + private final String name; + + /** Location of the store, including geographic coordinates and address information. */ + private final Object location; + + /** Business hours during which the store is open for operation. */ + private final Object businessHours; +} diff --git a/src/main/java/com/mercadopago/client/store/StoreUpdateRequest.java b/src/main/java/com/mercadopago/client/store/StoreUpdateRequest.java new file mode 100644 index 00000000..b2620d49 --- /dev/null +++ b/src/main/java/com/mercadopago/client/store/StoreUpdateRequest.java @@ -0,0 +1,25 @@ +package com.mercadopago.client.store; + +import lombok.Builder; +import lombok.Getter; + +/** + * Request DTO used to update an existing Store. Only the fields present in the + * PUT /users/{user_id}/stores/{id} request body are exposed; any field left unset is + * not modified. + * + * @see Stores API Reference + */ +@Getter +@Builder +public class StoreUpdateRequest { + + /** Name of the store. */ + private final String name; + + /** Geographic location of the store. */ + private final Object location; + + /** Business hours of the store. */ + private final Object businessHours; +} diff --git a/src/main/java/com/mercadopago/resources/store/Store.java b/src/main/java/com/mercadopago/resources/store/Store.java new file mode 100644 index 00000000..1f7213a5 --- /dev/null +++ b/src/main/java/com/mercadopago/resources/store/Store.java @@ -0,0 +1,41 @@ +package com.mercadopago.resources.store; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.mercadopago.net.MPResource; +import lombok.Getter; +import lombok.Setter; + +/** + * Resource representing a MercadoPago store. + * + *

Stores group physical or online points of sale (POS) belonging to a seller account. They are + * managed through the Stores API under the {@code /users/{user_id}/stores} endpoints. + * + * @see com.mercadopago.client.user.UserClient + */ +@Getter +@Setter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Store extends MPResource { + + /** Unique identifier of the store. */ + private Long id; + + /** Name of the store. */ + private String name; + + /** Business hours of the store, keyed by day of the week. */ + private Object businessHours; + + /** Location of the store. */ + private Object location; + + /** Identifier of the user account that owns the store. */ + private Long userId; + + /** Date of creation of the store. */ + private String dateCreated; + + /** Date of the last update of the store. */ + private String dateLastUpdated; +} diff --git a/src/test/java/com/mercadopago/client/store/StoreClientTest.java b/src/test/java/com/mercadopago/client/store/StoreClientTest.java new file mode 100644 index 00000000..a884e223 --- /dev/null +++ b/src/test/java/com/mercadopago/client/store/StoreClientTest.java @@ -0,0 +1,253 @@ +package com.mercadopago.client.store; + +import static com.mercadopago.helper.MockHelper.generateHttpResponseFromFile; +import static com.mercadopago.helper.MockHelper.generateJsonElement; +import static com.mercadopago.helper.MockHelper.generateJsonElementFromUriRequest; +import static com.mercadopago.net.HttpStatus.CREATED; +import static com.mercadopago.net.HttpStatus.OK; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; + +import com.google.gson.JsonElement; +import com.mercadopago.BaseClientTest; +import com.mercadopago.exceptions.MPApiException; +import com.mercadopago.exceptions.MPException; +import com.mercadopago.net.MPElementsResourcesPage; +import com.mercadopago.net.MPSearchRequest; +import com.mercadopago.resources.store.Store; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpRequestBase; +import org.apache.http.protocol.HttpContext; +import org.junit.jupiter.api.Test; + +class StoreClientTest extends BaseClientTest { + private final String storeBaseJson = "store/store_base.json"; + + private final String storeUpdatedJson = "store/store_update.json"; + + private final String storeListJson = "store/store_list.json"; + + private final long userId = 471763365L; + + private final String storeId = "784821936"; + + private final StoreClient client = new StoreClient(); + + @Test + void createSuccess() throws MPException, MPApiException, IOException { + HttpResponse httpResponse = generateHttpResponseFromFile(storeBaseJson, CREATED); + doReturn(httpResponse) + .when(HTTP_CLIENT) + .execute(any(HttpRequestBase.class), any(HttpContext.class)); + + StoreCreateRequest request = + StoreCreateRequest.builder() + .name("Official Store") + .businessHours( + StoreBusinessHoursRequest.builder() + .monday("08:00-18:00") + .tuesday("08:00-18:00") + .build()) + .location( + StoreLocationRequest.builder() + .addressLine("Av. das Nações Unidas 3003") + .zipCode("06233200") + .build()) + .build(); + + Store store = client.createStore(userId, request); + + JsonElement requestPayload = + generateJsonElementFromUriRequest(HTTP_CLIENT_MOCK.getRequestPayload()); + JsonElement requestPayloadMock = generateJsonElement(storeBaseJson); + + assertEquals(requestPayloadMock, requestPayload); + assertNotNull(store.getResponse()); + assertEquals(CREATED, store.getResponse().getStatusCode()); + assertStoreFields(store); + } + + @Test + void createWithRequestOptionsSuccess() throws MPException, MPApiException, IOException { + HttpResponse httpResponse = generateHttpResponseFromFile(storeBaseJson, CREATED); + doReturn(httpResponse) + .when(HTTP_CLIENT) + .execute(any(HttpRequestBase.class), any(HttpContext.class)); + + StoreCreateRequest request = + StoreCreateRequest.builder().name("Official store").build(); + + Store store = client.createStore(userId, request, buildRequestOptions()); + + JsonElement requestPayload = + generateJsonElementFromUriRequest(HTTP_CLIENT_MOCK.getRequestPayload()); + JsonElement requestPayloadMock = generateJsonElement(storeBaseJson); + + assertEquals(requestPayloadMock, requestPayload); + assertNotNull(store.getResponse()); + assertEquals(CREATED, store.getResponse().getStatusCode()); + assertStoreFields(store); + } + + @Test + void getSuccess() throws MPException, MPApiException, IOException { + HttpResponse httpResponse = generateHttpResponseFromFile(storeBaseJson, OK); + doReturn(httpResponse) + .when(HTTP_CLIENT) + .execute(any(HttpRequestBase.class), any(HttpContext.class)); + + Store store = client.get(storeId); + + assertNotNull(store.getResponse()); + assertEquals(OK, store.getResponse().getStatusCode()); + assertStoreFields(store); + } + + @Test + void getWithRequestOptionsSuccess() throws MPException, MPApiException, IOException { + HttpResponse httpResponse = generateHttpResponseFromFile(storeBaseJson, OK); + doReturn(httpResponse) + .when(HTTP_CLIENT) + .execute(any(HttpRequestBase.class), any(HttpContext.class)); + + Store store = client.get(storeId, buildRequestOptions()); + + assertNotNull(store.getResponse()); + assertEquals(OK, store.getResponse().getStatusCode()); + assertStoreFields(store); + } + + @Test + void searchSuccess() throws MPException, MPApiException, IOException { + HttpResponse httpResponse = generateHttpResponseFromFile(storeListJson, OK); + doReturn(httpResponse) + .when(HTTP_CLIENT) + .execute(any(HttpRequestBase.class), any(HttpContext.class)); + + Map filters = new HashMap<>(); + filters.put("external_id", "1234"); + + MPSearchRequest searchRequest = + MPSearchRequest.builder().limit(0).offset(0).filters(filters).build(); + MPElementsResourcesPage results = client.search(userId, searchRequest); + + assertEquals(OK, results.getResponse().getStatusCode()); + assertNotNull(results.getResponse()); + assertEquals(2, results.getTotal()); + assertEquals(2, results.getElements().size()); + assertEquals(2, results.getNextOffset()); + assertStoreFields(results.getElements().get(0)); + } + + @Test + void searchWithRequestOptionsSuccess() throws MPException, MPApiException, IOException { + HttpResponse httpResponse = generateHttpResponseFromFile(storeListJson, OK); + doReturn(httpResponse) + .when(HTTP_CLIENT) + .execute(any(HttpRequestBase.class), any(HttpContext.class)); + + Map filters = new HashMap<>(); + filters.put("external_id", "1234"); + + MPSearchRequest searchRequest = + MPSearchRequest.builder().limit(0).offset(0).filters(filters).build(); + MPElementsResourcesPage results = + client.search(userId, searchRequest, buildRequestOptions()); + + assertEquals(OK, results.getResponse().getStatusCode()); + assertNotNull(results.getResponse()); + assertEquals(2, results.getTotal()); + assertEquals(2, results.getElements().size()); + assertEquals(2, results.getNextOffset()); + assertStoreFields(results.getElements().get(0)); + } + + @Test + void updateSuccess() throws MPException, MPApiException, IOException { + HttpResponse httpResponse = generateHttpResponseFromFile(storeUpdatedJson, OK); + doReturn(httpResponse) + .when(HTTP_CLIENT) + .execute(any(HttpRequestBase.class), any(HttpContext.class)); + + StoreUpdateRequest updateRequest = + StoreUpdateRequest.builder().name("Updated store").build(); + + Store store = client.update(userId, storeId, updateRequest); + + JsonElement requestPayload = + generateJsonElementFromUriRequest(HTTP_CLIENT_MOCK.getRequestPayload()); + JsonElement requestPayloadMock = generateJsonElement(storeUpdatedJson); + + assertEquals(requestPayloadMock, requestPayload); + assertNotNull(store.getResponse()); + assertEquals(OK, store.getResponse().getStatusCode()); + assertEquals("Updated store", store.getName()); + } + + @Test + void updateWithRequestOptionsSuccess() throws MPException, MPApiException, IOException { + HttpResponse httpResponse = generateHttpResponseFromFile(storeUpdatedJson, OK); + doReturn(httpResponse) + .when(HTTP_CLIENT) + .execute(any(HttpRequestBase.class), any(HttpContext.class)); + + StoreUpdateRequest updateRequest = + StoreUpdateRequest.builder().name("Updated store").build(); + + Store store = client.update(userId, storeId, updateRequest, buildRequestOptions()); + + JsonElement requestPayload = + generateJsonElementFromUriRequest(HTTP_CLIENT_MOCK.getRequestPayload()); + JsonElement requestPayloadMock = generateJsonElement(storeUpdatedJson); + + assertEquals(requestPayloadMock, requestPayload); + assertNotNull(store.getResponse()); + assertEquals(OK, store.getResponse().getStatusCode()); + assertEquals("Updated store", store.getName()); + } + + @Test + void deleteSuccess() throws MPException, MPApiException, IOException { + HttpResponse httpResponse = generateHttpResponseFromFile(storeBaseJson, OK); + doReturn(httpResponse) + .when(HTTP_CLIENT) + .execute(any(HttpRequestBase.class), any(HttpContext.class)); + + Store store = client.delete(userId, storeId); + + assertNotNull(store.getResponse()); + assertEquals(OK, store.getResponse().getStatusCode()); + assertStoreFields(store); + } + + @Test + void deleteWithRequestOptionsSuccess() throws MPException, MPApiException, IOException { + HttpResponse httpResponse = generateHttpResponseFromFile(storeBaseJson, OK); + doReturn(httpResponse) + .when(HTTP_CLIENT) + .execute(any(HttpRequestBase.class), any(HttpContext.class)); + + Store store = client.delete(userId, storeId, buildRequestOptions()); + + assertNotNull(store.getResponse()); + assertEquals(OK, store.getResponse().getStatusCode()); + assertStoreFields(store); + } + + private void assertStoreFields(Store store) { + assertEquals(Long.valueOf(storeId), store.getId()); + assertEquals("Official store", store.getName()); + assertEquals("1234", store.getExternalId()); + assertEquals(userId, store.getUserId()); + assertNotNull(store.getLocation()); + assertEquals("Av. das Nações Unidas 3003", store.getLocation().getAddressLine()); + assertEquals("06233200", store.getLocation().getZipCode()); + assertTrue(store.getBusinessHours().getMonday().isEmpty()); + } +} diff --git a/src/test/java/com/mercadopago/resources/mocks/request/store/store_base.json b/src/test/java/com/mercadopago/resources/mocks/request/store/store_base.json new file mode 100644 index 00000000..7ed80844 --- /dev/null +++ b/src/test/java/com/mercadopago/resources/mocks/request/store/store_base.json @@ -0,0 +1,11 @@ +{ + "name": "Official Store", + "businessHours": { + "monday": "08:00-18:00", + "tuesday": "08:00-18:00" + }, + "location": { + "addressLine": "Av. das Nações Unidas 3003", + "zipCode": "06233200" + } +} diff --git a/src/test/java/com/mercadopago/resources/mocks/request/store/store_update.json b/src/test/java/com/mercadopago/resources/mocks/request/store/store_update.json new file mode 100644 index 00000000..4fcd3753 --- /dev/null +++ b/src/test/java/com/mercadopago/resources/mocks/request/store/store_update.json @@ -0,0 +1,3 @@ +{ + "name": "Updated store" +} diff --git a/src/test/java/com/mercadopago/resources/mocks/response/store/store_base.json b/src/test/java/com/mercadopago/resources/mocks/response/store/store_base.json new file mode 100644 index 00000000..5da85181 --- /dev/null +++ b/src/test/java/com/mercadopago/resources/mocks/response/store/store_base.json @@ -0,0 +1,54 @@ +{ + "id": 784821936, + "name": "Official store", + "date_created": "2022-01-10T10:10:10.000-00:00", + "last_updated": "2022-01-10T10:10:10.000-00:00", + "location": { + "address_line": "Av. das Nações Unidas, 3003", + "reference": "Floor 3", + "city": { + "id": "TUxCQ09SUE8xMjM0", + "name": "São Paulo" + }, + "latitude": -23.5966, + "longitude": -46.6964, + "open_hours": { + "monday": { + "open": "08:00", + "close": "18:00" + }, + "tuesday": { + "open": "08:00", + "close": "18:00" + }, + "wednesday": { + "open": "08:00", + "close": "18:00" + }, + "thursday": { + "open": "08:00", + "close": "18:00" + }, + "friday": { + "open": "08:00", + "close": "18:00" + } + } + }, + "external_id": "store_001", + "user_id": 798798399, + "business_hours": { + "monday": [ + { + "open": "08:00", + "close": "18:00" + } + ], + "tuesday": [ + { + "open": "08:00", + "close": "18:00" + } + ] + } +} diff --git a/src/test/java/com/mercadopago/resources/mocks/response/store/store_list.json b/src/test/java/com/mercadopago/resources/mocks/response/store/store_list.json new file mode 100644 index 00000000..195ef352 --- /dev/null +++ b/src/test/java/com/mercadopago/resources/mocks/response/store/store_list.json @@ -0,0 +1,70 @@ +{ + "elements": [ + { + "id": 123456, + "name": "Official Store", + "date_created": "2022-01-10T10:10:10.000-00:00", + "open_hours": { + "monday": { + "open": "08:00", + "close": "18:00" + }, + "tuesday": { + "open": "08:00", + "close": "18:00" + }, + "wednesday": { + "open": "08:00", + "close": "18:00" + }, + "thursday": { + "open": "08:00", + "close": "18:00" + }, + "friday": { + "open": "08:00", + "close": "18:00" + } + }, + "location": { + "address_line": "Av. das Nações Unidas, 3003", + "reference": "Floor 1", + "city": { + "id": "TUxCS0FPUDk1NzE", + "name": "São Paulo" + }, + "latitude": -23.5967, + "longitude": -46.6871, + "zip_code": "06233-200" + }, + "external_id": "store_001", + "user_id": 798798399 + }, + { + "id": 123456, + "name": "Second Store", + "date_created": "2022-01-21T17:52:58.563+00:00", + "open_hours": { + "monday": { + "open": "09:00", + "close": "17:00" + } + }, + "location": { + "address_line": "Rua Exemplo, 123", + "reference": null, + "city": { + "id": "TUxCS0FPUDk1Ng", + "name": "São Paulo" + }, + "latitude": -23.5505, + "longitude": -46.6253, + "zip_code": "01234-567" + }, + "external_id": "store_002", + "user_id": 798798399 + } + ], + "next_offset": 2, + "total": 2 +}