Skip to content

Commit 6532011

Browse files
committed
MS Store Update
- fixed search not working by updating the search api - add highlighted products to the list on return
1 parent 422351a commit 6532011

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

lib/models/ms_store/search_response.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ part 'search_response.g.dart';
66
@freezed
77
class SearchResponse with _$SearchResponse {
88
const factory SearchResponse({
9+
List<ProductsList>? highlightedList,
910
List<ProductsList>? productsList,
1011
}) = _SearchResponse;
1112

@@ -21,7 +22,7 @@ class ProductsList with _$ProductsList {
2122
String? description,
2223
String? publisherName,
2324
// double? averageRating,
24-
String? ratingCount,
25+
// String? ratingCount,
2526
// int? price,
2627
String? displayPrice,
2728
String? strikethroughPrice,

lib/services/msstore_service.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class MSStoreService {
2020
static const _fe3Delivery =
2121
"https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx";
2222
static const _storeAPI = "https://storeedgefd.dsx.mp.microsoft.com/v9.0";
23-
static const _filteredSearchAPI =
24-
"https://apps.microsoft.com/store/api/Products/GetFilteredSearch";
23+
// static const _filteredSearchAPI = "https://apps.microsoft.com/store/api/Products/GetFilteredSearch";
24+
static const _searchAPI = "https://apps.microsoft.com/api/products/search";
2525
static final _optionsSoapXML = Options(
2626
headers: {
2727
"user-agent":
@@ -101,11 +101,17 @@ class MSStoreService {
101101
Future<List<ProductsList>> searchProducts(String query) async {
102102
//"$_filteredSearchAPI?&Query=$query&FilteredCategories=AllProducts&hl=en-us${systemLanguage.toLowerCase()}&
103103
final response = await _dio.get(
104-
"$_filteredSearchAPI?&Query=$query&FilteredCategories=AllProducts&hl=en-us&gl=us",
104+
"$_searchAPI?gl=US&hl=en-us&query=$query&mediaType=all&age=all&price=all&category=all&subscription=all",
105+
106+
// https://apps.microsoft.com/api/products/search?gl=GE&hl=en-us&query=xbox&cursor=
105107
options: _options);
106108

107109
if (response.statusCode == 200) {
108-
return SearchResponse.fromJson(response.data).productsList ?? [];
110+
final responseData = SearchResponse.fromJson(response.data);
111+
return [
112+
...(responseData.highlightedList ?? []),
113+
...(responseData.productsList ?? []),
114+
];
109115
}
110116
throw Exception('Failed to search products');
111117
}

0 commit comments

Comments
 (0)