From d4ab8d606d6ddb823f685d81e8bfe526a20bf8e2 Mon Sep 17 00:00:00 2001 From: honky-bear Date: Sat, 1 Dec 2018 11:30:14 +0000 Subject: [PATCH 1/2] Added Country functionality to Lookup --- src/main/java/be/ceau/itunesapi/Lookup.java | 25 +++++++++++++++++++ .../java/be/ceau/itunesapi/LookupTest.java | 12 +++++++++ 2 files changed, 37 insertions(+) diff --git a/src/main/java/be/ceau/itunesapi/Lookup.java b/src/main/java/be/ceau/itunesapi/Lookup.java index 0d9f98c..f5ab79a 100755 --- a/src/main/java/be/ceau/itunesapi/Lookup.java +++ b/src/main/java/be/ceau/itunesapi/Lookup.java @@ -27,6 +27,7 @@ import java.util.Map.Entry; import java.util.Set; +import be.ceau.itunesapi.request.Country; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,6 +61,7 @@ public class Lookup implements Serializable { private Entity entity; private int limit; private Sort sort; + private Country country; /** * No-arg constructor. @@ -383,6 +385,23 @@ public Lookup setSort(Sort sort) { return this; } + /** + * @return {@link Country} instance, or {@code null} + */ + public Country getCountry() { + return country; + } + + /** + * @param country + * {@link Country}, can be {@code null} + * @return {@code this} instance for method chaining + */ + public Lookup setCountry(Country country) { + this.country = country; + return this; + } + /** * Create the request url for this {@link Lookup} * @@ -421,6 +440,12 @@ public String build() { } sb.append("sort").append("=").append(sort.toString()); } + if (country != null) { + if (sb.length() > 0) { + sb.append("&"); + } + sb.append("country").append("=").append(country.getIso()); + } return API_ENDPOINT + sb.toString(); } diff --git a/src/test/java/be/ceau/itunesapi/LookupTest.java b/src/test/java/be/ceau/itunesapi/LookupTest.java index fa21181..0bea075 100755 --- a/src/test/java/be/ceau/itunesapi/LookupTest.java +++ b/src/test/java/be/ceau/itunesapi/LookupTest.java @@ -15,6 +15,7 @@ */ package be.ceau.itunesapi; +import be.ceau.itunesapi.request.Country; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -45,4 +46,15 @@ public void albums() { Assert.assertEquals(response.getResults().size(), response.getResultCount()); } + @Test + public void albumsFromUSStore() { + Response response = new Lookup() + .addId("178834") + .setEntity(Entity.ALBUM) + .setCountry(Country.UNITED_STATES) + .execute(); + Assert.assertTrue(response.getResultCount() > 0); + Assert.assertEquals(response.getResults().size(), response.getResultCount()); + } + } From 042b5059bfe02751e89212b67b87fc4e3b36e81b Mon Sep 17 00:00:00 2001 From: honky-bear Date: Sat, 1 Dec 2018 11:30:35 +0000 Subject: [PATCH 2/2] Added Country functionality to Lookup --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bbb7e0d..10246f7 100755 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 be.ceau itunes-api - 4.1 + 4.1.1-SNAPSHOT jar iTunes API Java client for the Apple iTunes APIs