From 836a46b57f8b63c72486657275afe794324e104a Mon Sep 17 00:00:00 2001 From: Abdullahi Addow Date: Tue, 7 Nov 2023 18:54:23 +0300 Subject: [PATCH 1/3] Pass language code to iTunes search api to get localized release notes --- lib/src/itunes_search_api.dart | 12 ++++++++---- lib/src/upgrader.dart | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/src/itunes_search_api.dart b/lib/src/itunes_search_api.dart index 48881d37..498330d7 100644 --- a/lib/src/itunes_search_api.dart +++ b/lib/src/itunes_search_api.dart @@ -29,14 +29,16 @@ class ITunesSearchAPI { /// ```lookupURLByBundleId('com.google.Maps');``` /// ```lookupURLByBundleId('com.google.Maps', country: 'FR');``` Future lookupByBundleId(String bundleId, - {String? country = 'US', bool useCacheBuster = true}) async { + {String? country = 'US',String? language = 'en', bool useCacheBuster = + true}) async { assert(bundleId.isNotEmpty); if (bundleId.isEmpty) { return null; } final url = lookupURLByBundleId(bundleId, - country: country ??= '', useCacheBuster: useCacheBuster)!; + country: country ??= '', language: language ?? '', useCacheBuster: + useCacheBuster)!; if (debugLogging) { print('upgrader: download: $url'); } @@ -89,13 +91,15 @@ class ITunesSearchAPI { /// ```lookupURLByBundleId('com.google.Maps');``` /// ```lookupURLByBundleId('com.google.Maps', country: 'FR');``` String? lookupURLByBundleId(String bundleId, - {String country = 'US', bool useCacheBuster = true}) { + {String country = 'US', String language = 'en', bool useCacheBuster = + true}) { if (bundleId.isEmpty) { return null; } return lookupURLByQSP( - {'bundleId': bundleId, 'country': country.toUpperCase()}, + {'bundleId': bundleId, 'country': country.toUpperCase(), + 'lang': language}, useCacheBuster: useCacheBuster); } diff --git a/lib/src/upgrader.dart b/lib/src/upgrader.dart index 707be92a..7032219c 100644 --- a/lib/src/upgrader.dart +++ b/lib/src/upgrader.dart @@ -370,7 +370,8 @@ class Upgrader with WidgetsBindingObserver { iTunes.debugLogging = debugLogging; iTunes.client = client; final response = await (iTunes - .lookupByBundleId(_packageInfo!.packageName, country: country)); + .lookupByBundleId(_packageInfo!.packageName, language: language, + country:country)); if (response != null) { _appStoreVersion = iTunes.version(response); From 63a8a6500c906fe2488fc0c269f32c518208f46f Mon Sep 17 00:00:00 2001 From: Abdullahi Addow Date: Mon, 4 Dec 2023 13:13:20 +0300 Subject: [PATCH 2/3] Fix tests --- test/itunes_test.dart | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/itunes_test.dart b/test/itunes_test.dart index 625b966e..2b8cf0c5 100644 --- a/test/itunes_test.dart +++ b/test/itunes_test.dart @@ -20,7 +20,12 @@ void main() { expect( iTunes.lookupURLByBundleId('com.google.Maps', useCacheBuster: false), equals( - 'https://itunes.apple.com/lookup?bundleId=com.google.Maps&country=US')); + 'https://itunes.apple.com/lookup?bundleId=com.google.Maps&country=US&lang=en')); + expect( + iTunes.lookupURLByBundleId('com.google.Maps', + useCacheBuster: false, language: 'ar'), + equals( + 'https://itunes.apple.com/lookup?bundleId=com.google.Maps&country=US&lang=ar')); expect(iTunes.lookupURLById('585027354', useCacheBuster: false), equals('https://itunes.apple.com/lookup?id=585027354&country=US')); expect( @@ -30,7 +35,7 @@ void main() { // Test the URL using the cache buster and remove it from the URL const testUrl = - 'https://itunes.apple.com/lookup?bundleId=com.google.Maps&country=US&_cb='; + 'https://itunes.apple.com/lookup?bundleId=com.google.Maps&country=US&lang=en&_cb='; final url = iTunes .lookupURLByBundleId('com.google.Maps', useCacheBuster: true)! .substring(0, testUrl.length); From f81875d3cc12136b75cfbfa360750bbc0c3a2e6a Mon Sep 17 00:00:00 2001 From: Add00w Date: Tue, 3 Sep 2024 17:27:52 +0300 Subject: [PATCH 3/3] fix merge conflicts --- lib/src/itunes_search_api.dart | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/src/itunes_search_api.dart b/lib/src/itunes_search_api.dart index 3f2c015f..f07feff8 100644 --- a/lib/src/itunes_search_api.dart +++ b/lib/src/itunes_search_api.dart @@ -32,16 +32,18 @@ class ITunesSearchAPI { /// ```lookupURLByBundleId('com.google.Maps');``` /// ```lookupURLByBundleId('com.google.Maps', country: 'FR');``` Future lookupByBundleId(String bundleId, - {String? country = 'US',String? language = 'en', bool useCacheBuster = - true}) async { + {String? country = 'US', + String? language = 'en', + bool useCacheBuster = true}) async { assert(bundleId.isNotEmpty); if (bundleId.isEmpty) { return null; } final url = lookupURLByBundleId(bundleId, - country: country ??= '', language: language ?? '', useCacheBuster: - useCacheBuster)!; + country: country ?? '', + language: language ?? '', + useCacheBuster: useCacheBuster)!; if (debugLogging) { print('upgrader: download: $url'); } @@ -96,16 +98,18 @@ class ITunesSearchAPI { /// ```lookupURLByBundleId('com.google.Maps');``` /// ```lookupURLByBundleId('com.google.Maps', country: 'FR');``` String? lookupURLByBundleId(String bundleId, - {String country = 'US', String language = 'en', bool useCacheBuster = - true}) { + {String country = 'US', + String language = 'en', + bool useCacheBuster = true}) { if (bundleId.isEmpty) { return null; } - return lookupURLByQSP( - {'bundleId': bundleId, 'country': country.toUpperCase(), - 'lang': language}, - useCacheBuster: useCacheBuster); + return lookupURLByQSP({ + 'bundleId': bundleId, + 'country': country.toUpperCase(), + 'lang': language + }, useCacheBuster: useCacheBuster); } /// Look up URL by id.