From 836a46b57f8b63c72486657275afe794324e104a Mon Sep 17 00:00:00 2001 From: Abdullahi Addow Date: Tue, 7 Nov 2023 18:54:23 +0300 Subject: [PATCH 1/4] 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/4] 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 fe0e7daedafcde3593d2d0efbbaf885ee609ed9b Mon Sep 17 00:00:00 2001 From: Ibraheem Alyan <35265448+ibraheemalayan@users.noreply.github.com> Date: Sat, 24 Aug 2024 12:17:05 +0300 Subject: [PATCH 3/4] pass language to iTunesSearchAPI in UpgraderAppStore --- lib/src/upgrade_store_controller.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/upgrade_store_controller.dart b/lib/src/upgrade_store_controller.dart index 8795bb7a..6708372a 100644 --- a/lib/src/upgrade_store_controller.dart +++ b/lib/src/upgrade_store_controller.dart @@ -39,7 +39,7 @@ class UpgraderAppStore extends UpgraderStore { iTunes.client = state.client; iTunes.clientHeaders = state.clientHeaders; final response = await (iTunes - .lookupByBundleId(state.packageInfo!.packageName, country: country)); + .lookupByBundleId(state.packageInfo!.packageName, country: country, language: language)); if (response != null) { final version = iTunes.version(response); From 72cf1caa632a90794527f4f0651ed7439c177198 Mon Sep 17 00:00:00 2001 From: Ibraheem Alyan <35265448+ibraheemalayan@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:13:55 +0300 Subject: [PATCH 4/4] fix: remove unnecessary assignment operator --- lib/src/itunes_search_api.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/itunes_search_api.dart b/lib/src/itunes_search_api.dart index 3f2c015f..447cd46d 100644 --- a/lib/src/itunes_search_api.dart +++ b/lib/src/itunes_search_api.dart @@ -40,7 +40,7 @@ class ITunesSearchAPI { } final url = lookupURLByBundleId(bundleId, - country: country ??= '', language: language ?? '', useCacheBuster: + country: country ?? '', language: language ?? '', useCacheBuster: useCacheBuster)!; if (debugLogging) { print('upgrader: download: $url');