-
Notifications
You must be signed in to change notification settings - Fork 20
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
[SSDK-399] Add Discover.Options(country, proximity, origin) #167
Merged
aokj4ck
merged 13 commits into
main
from
SSDK-399-add-country-proximity-origin-to-discover-options
Feb 15, 2024
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
949a0d8
Add nullable Country.default, add Discover.Options(country, proximity…
aokj4ck bab5844
Add test to ensure Discover with Search-along-route works correctly -…
aokj4ck 5c53f23
Merge branch 'main' of github.com:mapbox/mapbox-search-ios into SSDK-…
aokj4ck f397eea
Merge branch 'main' of github.com:mapbox/mapbox-search-ios into SSDK-…
aokj4ck 44907d7
Fix category tests (until more advanced test fixes in other PRs can b…
aokj4ck 0fa0268
Merge branch 'main' of github.com:mapbox/mapbox-search-ios into SSDK-…
aokj4ck e64f38b
Merge branch 'main' into SSDK-399-add-country-proximity-origin-to-dis…
aokj4ck ebfe723
Merge branch 'main' into SSDK-399-add-country-proximity-origin-to-dis…
aokj4ck 807ac1b
Merge branch 'main' of github.com:mapbox/mapbox-search-ios into SSDK-…
aokj4ck 90f8abb
Remove Discover.Options.country nil to .default assignment - SSDK-399
aokj4ck 757a6b1
Fix propagation of Discover.Options.proximity to SearchOptions.proxim…
aokj4ck 4f17c4c
Update Sources/MapboxSearch/PublicAPI/Use Cases/Discover API/Discover…
aokj4ck 597d946
Fix build issue
aokj4ck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
Tests/MapboxSearchIntegrationTests/DiscoverIntegrationTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import CoreLocation | ||
@testable import MapboxSearch | ||
import XCTest | ||
|
||
class DiscoverIntegrationTests: MockServerIntegrationTestCase { | ||
lazy var searchEngine = Discover(locationProvider: DefaultLocationProvider()) | ||
|
||
func testCategorySearchAlongRouteWithCountryProximityOrigin() throws { | ||
try server.setResponse(.categoryHotelSearchAlongRoute_JP) | ||
let expectation = XCTestExpectation(description: "Expecting results") | ||
|
||
let coordinate1 = CLLocationCoordinate2D(latitude: 35.655614, longitude: 139.7081684) | ||
let coordinate2 = CLLocationCoordinate2D(latitude: 35.6881616, longitude: 139.6994339) | ||
let coordinates = [coordinate1, coordinate2] | ||
|
||
let mapboxSearchRoute = MapboxSearch.Route(coordinates: coordinates) | ||
let rOptions: MapboxSearch.RouteOptions = RouteOptions(route: mapboxSearchRoute, time: 1000) | ||
|
||
let discoverOptions = Discover.Options( | ||
limit: 10, | ||
language: nil, | ||
country: Country(countryCode: "jp"), | ||
proximity: CLLocationCoordinate2D( | ||
latitude: 35.6634363, | ||
longitude: 139.7394536 | ||
), | ||
origin: CLLocationCoordinate2D(latitude: 35.66580, longitude: 139.74609) | ||
) | ||
|
||
searchEngine.search( | ||
for: Discover.Query.Category.canonicalName("hotel"), | ||
route: rOptions, | ||
options: discoverOptions | ||
) { result in | ||
switch result { | ||
case .success(let searchResults): | ||
XCTAssertFalse(searchResults.isEmpty) | ||
expectation.fulfill() | ||
case .failure: | ||
XCTFail("Error not expected") | ||
} | ||
expectation.fulfill() | ||
} | ||
wait(for: [expectation], timeout: 10) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @aokj4ck is
countryIdenitifier
only the last component inregionComponents
or it is just the second item all the time?just smal nitpick from my side: is it possible to use
regionComponents?.last
orregionComponents?.first
to leave all these checks on compiler shoulders? Instead to access item via index in arrayThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question, it is the second item all the time and there may be more items.
For example if you:
You will find that there are scenarios where the locale has more components such as Language = Chinese (Hong Kong) and Region = Hong Kong will return the locale
"en_HK_HK"
. There are various other examples and accessing the second items in the regionComponents is safest to cover all scenarios.