mirror of
https://github.com/bbasaran/kessel-run.git
synced 2024-09-25 21:35:21 -04:00
added intial functionality to call starwars apis
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package org.misoenergy.hackday.kessel_run.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
@Configuration
|
||||
public class StarWarsApiConfig {
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate() {
|
||||
return new RestTemplate();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public WebClient.Builder webClient() {
|
||||
return WebClient.builder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.misoenergy.hackday.kessel_run.controller;
|
||||
|
||||
import org.misoenergy.hackday.kessel_run.service.StarWarsApiService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class StarWarsApiController {
|
||||
|
||||
@Autowired
|
||||
StarWarsApiService starWarsApiService;
|
||||
|
||||
@GetMapping("/class-data")
|
||||
public String fetchClassData(){
|
||||
|
||||
starWarsApiService.getClassData();
|
||||
return "This is test";
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.misoenergy.hackday.kessel_run.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@Getter
|
||||
@Setter
|
||||
public class FlavorText {
|
||||
|
||||
private String value;
|
||||
private String type;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.misoenergy.hackday.kessel_run.service;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.misoenergy.hackday.kessel_run.model.FlavorText;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class StarWarsApiService {
|
||||
|
||||
@Autowired
|
||||
RestTemplate restTemplate;
|
||||
|
||||
public FlavorText getClassData () {
|
||||
|
||||
String url = "https://sw5eapi.azurewebsites.net/api/class";
|
||||
String response = restTemplate.getForObject(url, String.class);
|
||||
log.info("response is:" + response);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user