Skip to content

Commit

Permalink
Merge pull request #439 from ibraheemalayan/master
Browse files Browse the repository at this point in the history
Resolve merge conflicts in (Pass the language code to iTunes search api to get localized release notes) PR
  • Loading branch information
larryaasen authored Sep 12, 2024
2 parents a087be1 + 72cf1ca commit 999a6ae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
12 changes: 8 additions & 4 deletions lib/src/itunes_search_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ class ITunesSearchAPI {
/// ```lookupURLByBundleId('com.google.Maps');```
/// ```lookupURLByBundleId('com.google.Maps', country: 'FR');```
Future<Map?> 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');
}
Expand Down Expand Up @@ -94,13 +96,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);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/upgrade_store_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 7 additions & 2 deletions test/itunes_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
Expand Down

0 comments on commit 999a6ae

Please sign in to comment.