Skip to content

Commit 40182cf

Browse files
committed
feat(geo): Incorporate API review updates into geo category API. (#1491)
1 parent 240e862 commit 40182cf

23 files changed

+1290
-889
lines changed

Amplify.xcodeproj/project.pbxproj

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 52;
6+
objectVersion = 51;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -202,7 +202,6 @@
202202
5C09CCBA26CEDE1200CDCA9F /* GeoCategoryPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C09CCAF26CEDE1200CDCA9F /* GeoCategoryPlugin.swift */; };
203203
5C09CCBB26CEDE1200CDCA9F /* GeoCategory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C09CCB026CEDE1200CDCA9F /* GeoCategory.swift */; };
204204
5C09CCBC26CEDE1200CDCA9F /* GeoCategory+ClientBehavior.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C09CCB126CEDE1200CDCA9F /* GeoCategory+ClientBehavior.swift */; };
205-
5C09CCBD26CEDE1200CDCA9F /* GeoError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C09CCB326CEDE1200CDCA9F /* GeoError.swift */; };
206205
5C09CCBE26CEDE1200CDCA9F /* GeoCategoryBehavior.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C09CCB426CEDE1200CDCA9F /* GeoCategoryBehavior.swift */; };
207206
5C09CCC226D0733700CDCA9F /* GeoCategoryClientAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C09CCC026D0733700CDCA9F /* GeoCategoryClientAPITests.swift */; };
208207
5C09CCC326D0733700CDCA9F /* GeoCategoryConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C09CCC126D0733700CDCA9F /* GeoCategoryConfigurationTests.swift */; };
@@ -216,6 +215,8 @@
216215
5C763DAA26F2CF66006650E7 /* Geo+Place.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C763DA926F2CF66006650E7 /* Geo+Place.swift */; };
217216
5C763DAC26F2CFC2006650E7 /* Geo+MapStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C763DAB26F2CFC2006650E7 /* Geo+MapStyle.swift */; };
218217
5C763DAE26F2D00F006650E7 /* Geo+ResultsHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C763DAD26F2D00F006650E7 /* Geo+ResultsHandler.swift */; };
218+
5CB5DD27271707780078CCA2 /* Geo+SearchOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CB5DD26271707780078CCA2 /* Geo+SearchOptions.swift */; };
219+
5CF43D092728C64100F636E1 /* Geo+Error.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CF43D082728C64100F636E1 /* Geo+Error.swift */; };
219220
6B33896823AAACC900561E5B /* ReachabilityUpdate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B33896723AAACC900561E5B /* ReachabilityUpdate.swift */; };
220221
6B452B8225A7D0F600A1A811 /* Array+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B452B8125A7D0F600A1A811 /* Array+Extensions.swift */; };
221222
6B5087BD2565E5AD000AB673 /* QueryPredicateEvaluateGeneratedDoubleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B5087BC2565E5AD000AB673 /* QueryPredicateEvaluateGeneratedDoubleTests.swift */; };
@@ -1053,7 +1054,6 @@
10531054
5C09CCAF26CEDE1200CDCA9F /* GeoCategoryPlugin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeoCategoryPlugin.swift; sourceTree = "<group>"; };
10541055
5C09CCB026CEDE1200CDCA9F /* GeoCategory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeoCategory.swift; sourceTree = "<group>"; };
10551056
5C09CCB126CEDE1200CDCA9F /* GeoCategory+ClientBehavior.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "GeoCategory+ClientBehavior.swift"; sourceTree = "<group>"; };
1056-
5C09CCB326CEDE1200CDCA9F /* GeoError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeoError.swift; sourceTree = "<group>"; };
10571057
5C09CCB426CEDE1200CDCA9F /* GeoCategoryBehavior.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeoCategoryBehavior.swift; sourceTree = "<group>"; };
10581058
5C09CCC026D0733700CDCA9F /* GeoCategoryClientAPITests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeoCategoryClientAPITests.swift; sourceTree = "<group>"; };
10591059
5C09CCC126D0733700CDCA9F /* GeoCategoryConfigurationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeoCategoryConfigurationTests.swift; sourceTree = "<group>"; };
@@ -1067,6 +1067,8 @@
10671067
5C763DA926F2CF66006650E7 /* Geo+Place.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Geo+Place.swift"; sourceTree = "<group>"; };
10681068
5C763DAB26F2CFC2006650E7 /* Geo+MapStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Geo+MapStyle.swift"; sourceTree = "<group>"; };
10691069
5C763DAD26F2D00F006650E7 /* Geo+ResultsHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Geo+ResultsHandler.swift"; sourceTree = "<group>"; };
1070+
5CB5DD26271707780078CCA2 /* Geo+SearchOptions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Geo+SearchOptions.swift"; sourceTree = "<group>"; };
1071+
5CF43D082728C64100F636E1 /* Geo+Error.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Geo+Error.swift"; sourceTree = "<group>"; };
10701072
614D1E66BBE236DDD4F8E2E0 /* Pods-Amplify-AWSPluginsCore-AWSPluginsTestConfigs-AWSPluginsCoreTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Amplify-AWSPluginsCore-AWSPluginsTestConfigs-AWSPluginsCoreTests.debug.xcconfig"; path = "Target Support Files/Pods-Amplify-AWSPluginsCore-AWSPluginsTestConfigs-AWSPluginsCoreTests/Pods-Amplify-AWSPluginsCore-AWSPluginsTestConfigs-AWSPluginsCoreTests.debug.xcconfig"; sourceTree = "<group>"; };
10711073
6B33896723AAACC900561E5B /* ReachabilityUpdate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReachabilityUpdate.swift; sourceTree = "<group>"; };
10721074
6B452B8125A7D0F600A1A811 /* Array+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Array+Extensions.swift"; sourceTree = "<group>"; };
@@ -2227,7 +2229,6 @@
22272229
5C09CCB426CEDE1200CDCA9F /* GeoCategoryBehavior.swift */,
22282230
5C09CCAE26CEDE1200CDCA9F /* GeoCategoryConfiguration.swift */,
22292231
5C09CCAF26CEDE1200CDCA9F /* GeoCategoryPlugin.swift */,
2230-
5C09CCB226CEDE1200CDCA9F /* Error */,
22312232
5C09CCAA26CEDE1200CDCA9F /* Internal */,
22322233
5C763D9E26F2CA9F006650E7 /* Types */,
22332234
);
@@ -2243,14 +2244,6 @@
22432244
path = Internal;
22442245
sourceTree = "<group>";
22452246
};
2246-
5C09CCB226CEDE1200CDCA9F /* Error */ = {
2247-
isa = PBXGroup;
2248-
children = (
2249-
5C09CCB326CEDE1200CDCA9F /* GeoError.swift */,
2250-
);
2251-
path = Error;
2252-
sourceTree = "<group>";
2253-
};
22542247
5C09CCBF26D0733700CDCA9F /* Geo */ = {
22552248
isa = PBXGroup;
22562249
children = (
@@ -2268,10 +2261,12 @@
22682261
5C763DA526F2CD95006650E7 /* Geo+BoundingBox.swift */,
22692262
5C763DA126F2CB6A006650E7 /* Geo+Coordinates.swift */,
22702263
5C2D791426F5172E00420798 /* Geo+Country.swift */,
2264+
5CF43D082728C64100F636E1 /* Geo+Error.swift */,
22712265
5C763DAB26F2CFC2006650E7 /* Geo+MapStyle.swift */,
22722266
5C763DA926F2CF66006650E7 /* Geo+Place.swift */,
22732267
5C763DAD26F2D00F006650E7 /* Geo+ResultsHandler.swift */,
22742268
5C763DA726F2CE28006650E7 /* Geo+SearchArea.swift */,
2269+
5CB5DD26271707780078CCA2 /* Geo+SearchOptions.swift */,
22752270
);
22762271
path = Types;
22772272
sourceTree = "<group>";
@@ -4839,6 +4834,7 @@
48394834
95DAAB2E237E63370028544F /* AgeRange.swift in Sources */,
48404835
B4F7F3E824621E6200544B04 /* AuthAttributeResendConfirmationCodeRequest.swift in Sources */,
48414836
B4D3853A236C97360014653D /* PredictionsInterpretRequest.swift in Sources */,
4837+
5CF43D092728C64100F636E1 /* Geo+Error.swift in Sources */,
48424838
2144226C234BDD9B009357F7 /* StorageUploadFileRequest.swift in Sources */,
48434839
FAA2E8CA23A02A2600E420EA /* DataStoreCategory+Resettable.swift in Sources */,
48444840
B9B50DC423D917BB0086F1E1 /* TemporalFormat+Date.swift in Sources */,
@@ -4901,6 +4897,7 @@
49014897
974FF18724B54E590050D01B /* DeviceInfoItem.swift in Sources */,
49024898
97CB860624ABA023000C65FB /* LongPressGestureRecognizer.swift in Sources */,
49034899
FA5704C7245F368200392C19 /* ProgressListener.swift in Sources */,
4900+
5CB5DD27271707780078CCA2 /* Geo+SearchOptions.swift in Sources */,
49044901
FA76A2D32342B47100B91ADB /* HubPayloadEventName.swift in Sources */,
49054902
FA5704C9245F3C6900392C19 /* AmplifyInProcessReportingOperation.swift in Sources */,
49064903
FA09B9332321A305000E064D /* HubCategory+CategoryConfigurable.swift in Sources */,
@@ -5096,7 +5093,6 @@
50965093
FAC235A3227A5ED000424678 /* HubChannel.swift in Sources */,
50975094
FAA2E8CE23A02A8100E420EA /* PredictionsCategory+Resettable.swift in Sources */,
50985095
FAC23516227A053D00424678 /* StorageCategoryBehavior.swift in Sources */,
5099-
5C09CCBD26CEDE1200CDCA9F /* GeoError.swift in Sources */,
51005096
FA4E730E232829F1003B8EEB /* Resettable.swift in Sources */,
51015097
FAC23518227A053D00424678 /* StorageCategoryPlugin.swift in Sources */,
51025098
B42B3D3B246AE178007211E0 /* AuthInvalidateCredentialBehavior.swift in Sources */,

Amplify/Categories/Geo/Error/GeoError.swift

Lines changed: 0 additions & 66 deletions
This file was deleted.

Amplify/Categories/Geo/GeoCategory+ClientBehavior.swift

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,55 +11,45 @@ extension GeoCategory: GeoCategoryBehavior {
1111
/// Search for places or points of interest.
1212
/// - Parameters:
1313
/// - text: The place name or address to be used in the search. (case insensitive)
14-
/// - area: The area (.near or .boundingBox) for the search. (optional)
15-
/// - countries: Limits the search to the given a list of countries/regions. (optional)
16-
/// - maxResults: The maximum number of results returned per request. (optional)
17-
/// - placeIndexName: The name of the Place Index to query. (optional)
14+
/// - options: Optional parameters when searching for text.
1815
/// - completionHandler: The completion handler receives a Response object. The
1916
/// success case provides a Place array.
2017
public func search(for text: String,
21-
area: Geo.SearchArea? = nil,
22-
countries: [Geo.Country]? = nil,
23-
maxResults: Int? = nil,
24-
placeIndexName: String? = nil,
18+
options: Geo.SearchForTextOptions? = nil,
2519
completionHandler: @escaping Geo.ResultsHandler<[Geo.Place]>) {
2620
plugin.search(for: text,
27-
area: area,
28-
countries: countries,
29-
maxResults: maxResults,
30-
placeIndexName: placeIndexName,
21+
options: options,
3122
completionHandler: completionHandler)
3223
}
3324

3425
/// Reverse geocodes a given pair of coordinates and returns a list of Places
3526
/// closest to the specified position.
3627
/// - Parameters:
3728
/// - coordinates: Specifies a coordinate for the query.
38-
/// - maxResults: The maximum number of results returned per request. (optional)
39-
/// - placeIndexName: The name of the Place Index to query. (optional)
29+
/// - options: Optional parameters when searching for coorinates.
4030
/// - completionHandler: The completion handler receives a Response object. The
4131
/// success case provides a Place array.
4232
public func search(for coordinates: Geo.Coordinates,
43-
maxResults: Int? = nil,
44-
placeIndexName: String? = nil,
33+
options: Geo.SearchForCoordinatesOptions? = nil,
4534
completionHandler: @escaping Geo.ResultsHandler<[Geo.Place]>) {
4635
plugin.search(for: coordinates,
47-
maxResults: maxResults,
48-
placeIndexName: placeIndexName,
36+
options: options,
4937
completionHandler: completionHandler)
5038
}
5139

5240
// MARK: - Maps
5341

5442
/// Retrieves metadata for available Map resources.
55-
/// - Returns: Metadata for all available map resources.
56-
public func getAvailableMaps() -> [Geo.MapStyle] {
57-
plugin.getAvailableMaps()
43+
/// - Parameter completionHandler: The completion handler receives a Response
44+
/// object. The success case provides an array of available Map resources.
45+
public func availableMaps(completionHandler: @escaping Geo.ResultsHandler<[Geo.MapStyle]>) {
46+
plugin.availableMaps(completionHandler: completionHandler)
5847
}
5948

6049
/// Retrieves the default Map resource.
61-
/// - Returns: Metadata for the default map resource.
62-
public func getDefaultMap() -> Geo.MapStyle? {
63-
plugin.getDefaultMap()
50+
/// - Parameter completionHandler: The completion handler receives a Response
51+
/// object. The success case provides the default Map resource.
52+
public func defaultMap(completionHandler: @escaping Geo.ResultsHandler<Geo.MapStyle>) {
53+
plugin.defaultMap(completionHandler: completionHandler)
6454
}
6555
}

Amplify/Categories/Geo/GeoCategory.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ final public class GeoCategory: Category {
5454
let key = plugin.key
5555
guard !key.isEmpty else {
5656
let pluginDescription = String(describing: plugin)
57-
let error = GeoError.configuration(
57+
let error = Geo.Error.invalidConfiguration(
5858
"Plugin \(pluginDescription) has an empty `key`.",
5959
"Set the `key` property for \(String(describing: plugin))")
6060
throw error
@@ -79,7 +79,7 @@ final public class GeoCategory: Category {
7979
public func getPlugin(for key: PluginKey) throws -> GeoCategoryPlugin {
8080
guard let plugin = plugins[key] else {
8181
let keys = plugins.keys.joined(separator: ", ")
82-
let error = GeoError.configuration(
82+
let error = Geo.Error.invalidConfiguration(
8383
"No plugin has been added for '\(key)'.",
8484
"Either add a plugin for '\(key)', or use one of the known keys: \(keys)")
8585
throw error

Amplify/Categories/Geo/GeoCategoryBehavior.swift

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,33 @@ public protocol GeoCategoryBehavior {
1515
/// Search for places or points of interest.
1616
/// - Parameters:
1717
/// - text: The place name or address to be used in the search. (case insensitive)
18-
/// - area: The area (.near or .boundingBox) for the search. (optional)
19-
/// - countries: Limits the search to the given a list of countries/regions. (optional)
20-
/// - maxResults: The maximum number of results returned per request. (optional)
21-
/// - placeIndexName: The name of the Place Index to query. (optional)
18+
/// - options: Optional parameters when searching for text.
2219
/// - completionHandler: The completion handler receives a Response object. The
2320
/// success case provides a Place array.
24-
func search(for text: String, // swiftlint:disable:this function_parameter_count
25-
area: Geo.SearchArea?,
26-
countries: [Geo.Country]?,
27-
maxResults: Int?,
28-
placeIndexName: String?,
21+
func search(for text: String,
22+
options: Geo.SearchForTextOptions?,
2923
completionHandler: @escaping Geo.ResultsHandler<[Geo.Place]>)
3024

3125
/// Reverse geocodes a given pair of coordinates and returns a list of Places
3226
/// closest to the specified position.
3327
/// - Parameters:
3428
/// - coordinates: Specifies a coordinate for the query.
35-
/// - maxResults: The maximum number of results returned per request. (optional)
36-
/// - placeIndexName: The name of the Place Index to query. (optional)
29+
/// - options: Optional parameters when searching for coordinates.
3730
/// - completionHandler: The completion handler receives a Response object. The
3831
/// success case provides a Place array.
3932
func search(for coordinates: Geo.Coordinates,
40-
maxResults: Int?,
41-
placeIndexName: String?,
33+
options: Geo.SearchForCoordinatesOptions?,
4234
completionHandler: @escaping Geo.ResultsHandler<[Geo.Place]>)
4335

4436
// MARK: - Maps
4537

4638
/// Retrieves metadata for available Map resources.
47-
/// - Returns: Metadata for all available map resources.
48-
func getAvailableMaps() -> [Geo.MapStyle]
49-
50-
/// Retrieves the default Map resource (first map in amplifyconfiguration.json).
51-
/// - Returns: Metadata for the default map resource.
52-
func getDefaultMap() -> Geo.MapStyle?
39+
/// - Parameter completionHandler: The completion handler receives a Response
40+
/// object. The success case provides an array of available Map resources.
41+
func availableMaps(completionHandler: @escaping Geo.ResultsHandler<[Geo.MapStyle]>)
42+
43+
/// Retrieves metadata for the default Map resource.
44+
/// - Parameter completionHandler: The completion handler receives a Response
45+
/// object. The success case provides the default Map resource.
46+
func defaultMap(completionHandler: @escaping Geo.ResultsHandler<Geo.MapStyle>)
5347
}

0 commit comments

Comments
 (0)