Search in sources :

Example 1 with Order

use of com.baeldung.petstore.client.model.Order in project tutorials by eugenp.

the class StoreApi method getOrderById.

/**
 * Find purchase order by ID
 * For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions
 * <p><b>200</b> - successful operation
 * <p><b>400</b> - Invalid ID supplied
 * <p><b>404</b> - Order not found
 * @param orderId ID of pet that needs to be fetched
 * @return Order
 * @throws RestClientException if an error occurs while attempting to invoke the API
 */
public Order getOrderById(Long orderId) throws RestClientException {
    Object postBody = null;
    // verify the required parameter 'orderId' is set
    if (orderId == null) {
        throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'orderId' when calling getOrderById");
    }
    // create path and map variables
    final Map<String, Object> uriVariables = new HashMap<String, Object>();
    uriVariables.put("orderId", orderId);
    String path = UriComponentsBuilder.fromPath("/store/order/{orderId}").buildAndExpand(uriVariables).toUriString();
    final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
    final HttpHeaders headerParams = new HttpHeaders();
    final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();
    final String[] accepts = { "application/xml", "application/json" };
    final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
    final String[] contentTypes = {};
    final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
    String[] authNames = new String[] {};
    ParameterizedTypeReference<Order> returnType = new ParameterizedTypeReference<Order>() {
    };
    return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
Also used : Order(com.baeldung.petstore.client.model.Order) HttpHeaders(org.springframework.http.HttpHeaders) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) HashMap(java.util.HashMap) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) ParameterizedTypeReference(org.springframework.core.ParameterizedTypeReference) MediaType(org.springframework.http.MediaType)

Example 2 with Order

use of com.baeldung.petstore.client.model.Order in project tutorials by eugenp.

the class StoreApi method placeOrder.

/**
 * Place an order for a pet
 *
 * <p><b>200</b> - successful operation
 * <p><b>400</b> - Invalid Order
 * @param body order placed for purchasing the pet
 * @return Order
 * @throws RestClientException if an error occurs while attempting to invoke the API
 */
public Order placeOrder(Order body) throws RestClientException {
    Object postBody = body;
    // verify the required parameter 'body' is set
    if (body == null) {
        throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling placeOrder");
    }
    String path = UriComponentsBuilder.fromPath("/store/order").build().toUriString();
    final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
    final HttpHeaders headerParams = new HttpHeaders();
    final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();
    final String[] accepts = { "application/xml", "application/json" };
    final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
    final String[] contentTypes = {};
    final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
    String[] authNames = new String[] {};
    ParameterizedTypeReference<Order> returnType = new ParameterizedTypeReference<Order>() {
    };
    return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
Also used : Order(com.baeldung.petstore.client.model.Order) HttpHeaders(org.springframework.http.HttpHeaders) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) ParameterizedTypeReference(org.springframework.core.ParameterizedTypeReference) MediaType(org.springframework.http.MediaType)

Example 3 with Order

use of com.baeldung.petstore.client.model.Order in project tutorials by eugenp.

the class StoreApiTest method getOrderByIdTest.

/**
 * Find purchase order by ID
 *
 * For valid response try integer IDs with value &gt;&#x3D; 1 and &lt;&#x3D; 10. Other values will generated exceptions
 *
 * @throws ApiException
 *          if the Api call fails
 */
@Test
public void getOrderByIdTest() {
    Long orderId = null;
    Order response = api.getOrderById(orderId);
// TODO: test validations
}
Also used : Order(com.baeldung.petstore.client.model.Order) Test(org.junit.Test)

Example 4 with Order

use of com.baeldung.petstore.client.model.Order in project tutorials by eugenp.

the class StoreApiTest method placeOrderTest.

/**
 * Place an order for a pet
 *
 * @throws ApiException
 *          if the Api call fails
 */
@Test
public void placeOrderTest() {
    Order body = null;
    Order response = api.placeOrder(body);
// TODO: test validations
}
Also used : Order(com.baeldung.petstore.client.model.Order) Test(org.junit.Test)

Aggregations

Order (com.baeldung.petstore.client.model.Order)4 Test (org.junit.Test)2 ParameterizedTypeReference (org.springframework.core.ParameterizedTypeReference)2 HttpHeaders (org.springframework.http.HttpHeaders)2 MediaType (org.springframework.http.MediaType)2 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)2 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)2 HashMap (java.util.HashMap)1