Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve merge conflicts in (Pass the language code to iTunes search api to get localized release notes) PR #439

Merged
merged 7 commits into from
Sep 12, 2024
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:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ibraheemalayan There seems to be an extra character added to this existing code country: country ??= ''. The = was added. Was there a reason for thiat?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it is a mistake but it doesn't affect the code.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can merge this after that extra character is removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did the change

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
Loading