diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..00e077c --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/** +!**/src/test/** + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ + +### VS Code ### +.vscode/ +/mvnw.cmd +/mvnw diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..e3ff34c --- /dev/null +++ b/pom.xml @@ -0,0 +1,68 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.8.RELEASE + + + com.orange.springup + movie-retriever + 0.0.1-SNAPSHOT + movie-retriever + Simple microservice for movie metadata retrieval + + + 1.8 + Greenwich.SR3 + + + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-data-mongodb + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/src/main/java/com/orange/springup/movieretriever/MovieRetrieverApplication.java b/src/main/java/com/orange/springup/movieretriever/MovieRetrieverApplication.java new file mode 100644 index 0000000..444fd17 --- /dev/null +++ b/src/main/java/com/orange/springup/movieretriever/MovieRetrieverApplication.java @@ -0,0 +1,15 @@ +package com.orange.springup.movieretriever; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.openfeign.EnableFeignClients; + +@EnableFeignClients +@SpringBootApplication +public class MovieRetrieverApplication { + + public static void main(String[] args) { + SpringApplication.run(MovieRetrieverApplication.class, args); + } + +} diff --git a/src/main/java/com/orange/springup/movieretriever/dtos/MovieDto.java b/src/main/java/com/orange/springup/movieretriever/dtos/MovieDto.java new file mode 100644 index 0000000..d0f4ec0 --- /dev/null +++ b/src/main/java/com/orange/springup/movieretriever/dtos/MovieDto.java @@ -0,0 +1,61 @@ + +package com.orange.springup.movieretriever.dtos; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class MovieDto { + + @JsonProperty("Title") + public String title; + @JsonProperty("Year") + public String year; + @JsonProperty("Rated") + public String rated; + @JsonProperty("Released") + public String released; + @JsonProperty("Runtime") + public String runtime; + @JsonProperty("Genre") + public String genre; + @JsonProperty("Director") + public String director; + @JsonProperty("Writer") + public String writer; + @JsonProperty("Actors") + public String actors; + @JsonProperty("Plot") + public String plot; + @JsonProperty("Language") + public String language; + @JsonProperty("Country") + public String country; + @JsonProperty("Awards") + public String awards; + @JsonProperty("Poster") + public String poster; + @JsonProperty("Ratings") + public List ratingDtos = null; + @JsonProperty("Metascore") + public String metascore; + @JsonProperty("imdbRating") + public String imdbRating; + @JsonProperty("imdbVotes") + public String imdbVotes; + @JsonProperty("imdbID") + public String imdbID; + @JsonProperty("Type") + public String type; + @JsonProperty("DVD") + public String dVD; + @JsonProperty("BoxOffice") + public String boxOffice; + @JsonProperty("Production") + public String production; + @JsonProperty("Website") + public String website; + @JsonProperty("Response") + public String response; +} diff --git a/src/main/java/com/orange/springup/movieretriever/dtos/RatingDto.java b/src/main/java/com/orange/springup/movieretriever/dtos/RatingDto.java new file mode 100644 index 0000000..3ed01b8 --- /dev/null +++ b/src/main/java/com/orange/springup/movieretriever/dtos/RatingDto.java @@ -0,0 +1,15 @@ + +package com.orange.springup.movieretriever.dtos; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class RatingDto { + + @JsonProperty("Source") + public String source; + @JsonProperty("Value") + public String value; +} diff --git a/src/main/java/com/orange/springup/movieretriever/feign/client/OMDBClient.java b/src/main/java/com/orange/springup/movieretriever/feign/client/OMDBClient.java new file mode 100644 index 0000000..c17b516 --- /dev/null +++ b/src/main/java/com/orange/springup/movieretriever/feign/client/OMDBClient.java @@ -0,0 +1,13 @@ +package com.orange.springup.movieretriever.feign.client; + +import com.orange.springup.movieretriever.dtos.MovieDto; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; + +@FeignClient(name = "omdb-client", url = "http://www.omdbapi.com") +public interface OMDBClient { + + @GetMapping("/?apiKey={key}&t={title}") + MovieDto searchByTitle(@PathVariable("title") String title, @PathVariable("key") String key); +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1 @@ +