Introduction
The Skateboard Park API microservice provides endpoints for requesting and receiving data about skateboard parks.
Requesting Data
To request data from the Skateboard Park API microservice, follow these steps:
- Endpoint URL: http://localhost:8080/skateboard-park.
- HTTP Method: Use the HTTP GET method to request data from the microservice.
- Sending the Request: Send an HTTP GET request to the endpoint URL using your preferred HTTP client library or tool.
- Handling Response: Handle the response returned by the microservice (contains requested data in JSON format).
Example Request
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.web.client.RestTemplate;
public class SkateboardParkAPITest {
public static void main(String[] args) {
RestTemplate restTemplate = new RestTemplateBuilder().build();
// Define the URL of the endpoint to retrieve skateboard parks
String url = "http://localhost:8080/skateboard-park";
// Make a GET request to the microservice
String jsonResponse = restTemplate.getForObject(url, String.class);
// Handle the response (deserialize JSON, process data, etc.)
// Example handling shown in the accompanying code.
}
}
Receiving Data
The Skateboard Park API microservice responds to requests with data in JSON format. When receiving data from the microservice, follow these steps:
- Handling Response: Receive the JSON response from the microservice.
- Deserialization: Deserialize the JSON response into appropriate data objects in your programming language. This step may involve using JSON parsing libraries or frameworks.
- Processing Data: Process the received data as needed for your application logic.
Example Handling
import com.fasterxml.jackson.databind.ObjectMapper;
// Assuming SkateboardPark class is defined to represent skateboard park data
// Deserialize JSON response into SkateboardPark array
ObjectMapper mapper = new ObjectMapper();
try {
SkateboardPark[] skateboardParks = mapper.readValue(jsonResponse, SkateboardPark[].class);
// Process or utilize skateboardParks array
for (SkateboardPark park : skateboardParks) {
System.out.println("Skateboard Park: " + park.getName() + ", Location: " + park.getLocation());
}
} catch (IOException e) {
e.printStackTrace();
}
}
UML Sequence Diagram
![Screenshot 2024-02-24 at 3 57 20 PM](https://private-user-images.githubusercontent.com/93893043/307558818-0ed3d7c0-c25a-47bf-801b-a7e8ab8ef5cd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxODg1ODIsIm5iZiI6MTczOTE4ODI4MiwicGF0aCI6Ii85Mzg5MzA0My8zMDc1NTg4MTgtMGVkM2Q3YzAtYzI1YS00N2JmLTgwMWItYTdlOGFiOGVmNWNkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDExNTEyMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc1Y2VkZGE0MjIyNWRjZDBmNDMwMGMzNmRlMTAxMGFmMWMwMGEwMmFhYzQ2MzFkZWEwZDIxYzU4YThjMGUyYjImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.3CJGcn6m5TxdppMC4p1hylYCLk2ZicULcHtQkAGhv_s)