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

FENCE-2186 add countryCodes as param for search places #430

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Example/Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIWindowSceneDelegate, UN
chainMetadata: ["orderActive": "true"],
categories: nil,
groups: nil,
countryCodes: ["US"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to have this tested with multiple countries.

limit: 10
) { (status, location, places) in
print("Search places: status = \(Radar.stringForStatus(status)); places = \(String(describing: places))")
Expand Down
2 changes: 1 addition & 1 deletion RadarSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'RadarSDK'
s.version = '3.20.1'
s.version = '3.21.0'
s.summary = 'iOS SDK for Radar, the leading geofencing and location tracking platform'
s.homepage = 'https://radar.com'
s.author = { 'Radar Labs, Inc.' => '[email protected]' }
Expand Down
4 changes: 2 additions & 2 deletions RadarSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 3.20.1;
MARKETING_VERSION = 3.21.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -1120,7 +1120,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 3.20.1;
MARKETING_VERSION = 3.21.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
OTHER_CFLAGS = "-fembed-bitcode";
Expand Down
16 changes: 12 additions & 4 deletions RadarSDK/Include/Radar.h
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ typedef void (^_Nullable RadarLogConversionCompletionHandler)(RadarStatus status
@param categories An array of categories to filter. See https://radar.com/documentation/places/categories
@param groups An array of groups to filter. See https://radar.com/documentation/places/groups
@param limit The max number of places to return. A number between 1 and 100.
@param countryCodes An array of country codes to filter. See https://radar.com/documentation/regions/countries
@param completionHandler A completion handler.

@see https://radar.com/documentation/api#search-places
Expand All @@ -830,8 +831,9 @@ typedef void (^_Nullable RadarLogConversionCompletionHandler)(RadarStatus status
chains:(NSArray<NSString *> *_Nullable)chains
categories:(NSArray<NSString *> *_Nullable)categories
groups:(NSArray<NSString *> *_Nullable)groups
countryCodes:(NSArray<NSString *> *_Nullable)countryCodes
limit:(int)limit
completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler NS_SWIFT_NAME(searchPlaces(radius:chains:categories:groups:limit:completionHandler:));
completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler NS_SWIFT_NAME(searchPlaces(radius:chains:categories:groups:countryCodes:limit:completionHandler:));

/**
Gets the device's current location, then searches for places near that location, sorted by distance.
Expand All @@ -843,6 +845,7 @@ typedef void (^_Nullable RadarLogConversionCompletionHandler)(RadarStatus status
@param chainMetadata Optional chain metadata filters. Keys and values must be strings. See https://radar.com/documentation/places#metadata.
@param categories An array of categories to filter. See https://radar.com/documentation/places/categories
@param groups An array of groups to filter. See https://radar.com/documentation/places/groups
@param countryCodes An array of country codes to filter. See https://radar.com/documentation/regions/countries
@param limit The max number of places to return. A number between 1 and 100.
@param completionHandler A completion handler.

Expand All @@ -853,8 +856,9 @@ typedef void (^_Nullable RadarLogConversionCompletionHandler)(RadarStatus status
chainMetadata:(NSDictionary<NSString *, NSString *> *_Nullable)chainMetadata
categories:(NSArray<NSString *> *_Nullable)categories
groups:(NSArray<NSString *> *_Nullable)groups
countryCodes:(NSArray<NSString *> *_Nullable)countryCodes
limit:(int)limit
completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler NS_SWIFT_NAME(searchPlaces(radius:chains:chainMetadata:categories:groups:limit:completionHandler:));
completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler NS_SWIFT_NAME(searchPlaces(radius:chains:chainMetadata:categories:groups:countryCodes:limit:completionHandler:));

/**
Searches for places near a location, sorted by distance.
Expand All @@ -866,6 +870,7 @@ typedef void (^_Nullable RadarLogConversionCompletionHandler)(RadarStatus status
@param chains An array of chain slugs to filter. See https://radar.com/documentation/places/chains
@param categories An array of categories to filter. See https://radar.com/documentation/places/categories
@param groups An array of groups to filter. See https://radar.com/documentation/places/groups
@param countryCodes An array of country codes to filter. See https://radar.com/documentation/regions/countries
@param limit The max number of places to return. A number between 1 and 100.
@param completionHandler A completion handler.

Expand All @@ -876,8 +881,9 @@ typedef void (^_Nullable RadarLogConversionCompletionHandler)(RadarStatus status
chains:(NSArray<NSString *> *_Nullable)chains
categories:(NSArray<NSString *> *_Nullable)categories
groups:(NSArray<NSString *> *_Nullable)groups
countryCodes:(NSArray<NSString *> *_Nullable)countryCodes
limit:(int)limit
completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler NS_SWIFT_NAME(searchPlaces(near:radius:chains:categories:groups:limit:completionHandler:));
completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler NS_SWIFT_NAME(searchPlaces(near:radius:chains:categories:groups:countryCodes:limit:completionHandler:));

/**
Searches for places near a location, sorted by distance.
Expand All @@ -890,6 +896,7 @@ typedef void (^_Nullable RadarLogConversionCompletionHandler)(RadarStatus status
@param chainMetadata Optional chain metadata filters. Keys and values must be strings. See https://radar.com/documentation/places#metadata.
@param categories An array of categories to filter. See https://radar.com/documentation/places/categories
@param groups An array of groups to filter. See https://radar.com/documentation/places/groups
@param countryCodes An array of country codes to filter. See https://radar.com/documentation/regions/countries
@param limit The max number of places to return. A number between 1 and 100.
@param completionHandler A completion handler.

Expand All @@ -901,8 +908,9 @@ typedef void (^_Nullable RadarLogConversionCompletionHandler)(RadarStatus status
chainMetadata:(NSDictionary<NSString *, NSString *> *_Nullable)chainMetadata
categories:(NSArray<NSString *> *_Nullable)categories
groups:(NSArray<NSString *> *_Nullable)groups
countryCodes:(NSArray<NSString *> *_Nullable)countryCodes
limit:(int)limit
completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler NS_SWIFT_NAME(searchPlaces(near:radius:chains:chainMetadata:categories:groups:limit:completionHandler:));
completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler NS_SWIFT_NAME(searchPlaces(near:radius:chains:chainMetadata:categories:groups:countryCodes:limit:completionHandler:));

/**
Gets the device's current location, then searches for geofences near that location, sorted by distance.
Expand Down
10 changes: 8 additions & 2 deletions RadarSDK/Radar.m
Original file line number Diff line number Diff line change
Expand Up @@ -731,16 +731,18 @@ + (void)searchPlacesWithRadius:(int)radius
chains:(NSArray *_Nullable)chains
categories:(NSArray *_Nullable)categories
groups:(NSArray *_Nullable)groups
countryCodes:(NSArray *_Nullable)countryCodes
limit:(int)limit
completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler {
[Radar searchPlacesWithRadius:radius chains:chains chainMetadata:nil categories:categories groups:groups limit:limit completionHandler:completionHandler];
[Radar searchPlacesWithRadius:radius chains:chains chainMetadata:nil categories:categories groups:groups countryCodes:countryCodes limit:limit completionHandler:completionHandler];
}

+ (void)searchPlacesWithRadius:(int)radius
chains:(NSArray *_Nullable)chains
chainMetadata:(NSDictionary<NSString *, NSString *> *_Nullable)chainMetadata
categories:(NSArray *_Nullable)categories
groups:(NSArray *_Nullable)groups
countryCodes:(NSArray *_Nullable)countryCodes
limit:(int)limit
completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler {
[[RadarLogger sharedInstance] logWithLevel:RadarLogLevelInfo type:RadarLogTypeSDKCall message:@"searchPlaces()"];
Expand All @@ -761,6 +763,7 @@ + (void)searchPlacesWithRadius:(int)radius
chainMetadata:chainMetadata
categories:categories
groups:groups
countryCodes:countryCodes
limit:limit
completionHandler:^(RadarStatus status, NSDictionary *_Nullable res, NSArray<RadarPlace *> *_Nullable places) {
if (completionHandler) {
Expand All @@ -777,9 +780,10 @@ + (void)searchPlacesNear:(CLLocation *_Nonnull)near
chains:(NSArray *_Nullable)chains
categories:(NSArray *_Nullable)categories
groups:(NSArray *_Nullable)groups
countryCodes:(NSArray *_Nullable)countryCodes
limit:(int)limit
completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler {
[Radar searchPlacesNear:near radius:radius chains:chains chainMetadata:nil categories:categories groups:groups limit:limit completionHandler:completionHandler];
[Radar searchPlacesNear:near radius:radius chains:chains chainMetadata:nil categories:categories groups:groups countryCodes:countryCodes limit:limit completionHandler:completionHandler];
}

+ (void)searchPlacesNear:(CLLocation *_Nonnull)near
Expand All @@ -788,6 +792,7 @@ + (void)searchPlacesNear:(CLLocation *_Nonnull)near
chainMetadata:(NSDictionary<NSString *, NSString *> *_Nullable)chainMetadata
categories:(NSArray *_Nullable)categories
groups:(NSArray *_Nullable)groups
countryCodes:(NSArray *_Nullable)countryCodes
limit:(int)limit
completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler {
[[RadarLogger sharedInstance] logWithLevel:RadarLogLevelInfo type:RadarLogTypeSDKCall message:@"searchPlaces()"];
Expand All @@ -797,6 +802,7 @@ + (void)searchPlacesNear:(CLLocation *_Nonnull)near
chainMetadata:chainMetadata
categories:categories
groups:groups
countryCodes:countryCodes
limit:limit
completionHandler:^(RadarStatus status, NSDictionary *_Nullable res, NSArray<RadarPlace *> *_Nullable places) {
[RadarUtils runOnMainThread:^{
Expand Down
1 change: 1 addition & 0 deletions RadarSDK/RadarAPIClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ typedef void (^_Nonnull RadarSyncLogsAPICompletionHandler)(RadarStatus status);
chainMetadata:(NSDictionary<NSString *, NSString *> *_Nullable)chainMetadata
categories:(NSArray *_Nullable)categories
groups:(NSArray *_Nullable)groups
countryCodes:(NSArray *_Nullable)countryCodes
limit:(int)limit
completionHandler:(RadarSearchPlacesAPICompletionHandler _Nonnull)completionHandler;

Expand Down
5 changes: 5 additions & 0 deletions RadarSDK/RadarAPIClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ - (void)searchPlacesNear:(CLLocation *_Nonnull)near
chainMetadata:(NSDictionary<NSString *, NSString *> *_Nullable)chainMetadata
categories:(NSArray *_Nullable)categories
groups:(NSArray *_Nullable)groups
countryCodes:(NSArray *_Nullable)countryCodes
limit:(int)limit
completionHandler:(RadarSearchPlacesAPICompletionHandler)completionHandler {
NSString *publishableKey = [RadarSettings publishableKey];
Expand All @@ -802,6 +803,10 @@ - (void)searchPlacesNear:(CLLocation *_Nonnull)near
[queryString appendFormat:@"&groups=%@", [groups componentsJoinedByString:@","]];
}

if (countryCodes && [countryCodes count] > 0) {
[queryString appendFormat:@"&country=%@", [countryCodes componentsJoinedByString:@","]];
}

[chainMetadata enumerateKeysAndObjectsUsingBlock:^(NSString *_Nonnull key, NSString *_Nonnull value, BOOL *_Nonnull stop) {
[queryString appendFormat:@"&chainMetadata[%@]=\"%@\"", key, value];
}];
Expand Down
2 changes: 1 addition & 1 deletion RadarSDK/RadarUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ + (NSNumber *)timeZoneOffset {
}

+ (NSString *)sdkVersion {
return @"3.20.1";
return @"3.21.0";
}

+ (NSString *)deviceId {
Expand Down
2 changes: 1 addition & 1 deletion RadarSDKMotion.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'RadarSDKMotion'
s.version = '3.20.1'
s.version = '3.21.0'
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to bump this

s.summary = 'Motion detection plugin for RadarSDK, the leading geofencing and location tracking platform'
s.homepage = 'https://radar.com'
s.author = { 'Radar Labs, Inc.' => '[email protected]' }
Expand Down
4 changes: 2 additions & 2 deletions RadarSDKMotion/RadarSDKMotion.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MARKETING_VERSION = 3.20.1;
MARKETING_VERSION = 3.21.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -348,7 +348,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MARKETING_VERSION = 3.20.1;
MARKETING_VERSION = 3.21.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand Down
5 changes: 5 additions & 0 deletions RadarSDKTests/RadarSDKTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,7 @@ - (void)test_Radar_searchPlaces_errorPermissions {
chains:@[@"walmart"]
categories:nil
groups:nil
countryCodes:nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to have this with multiple countries.

limit:100
completionHandler:^(RadarStatus status, CLLocation *_Nullable location, NSArray<RadarPlace *> *_Nullable places) {
XCTAssertEqual(status, RadarStatusErrorPermissions);
Expand All @@ -923,6 +924,7 @@ - (void)test_Radar_searchPlaces_errorLocation {
chains:@[@"walmart"]
categories:nil
groups:nil
countryCodes:nil
limit:100
completionHandler:^(RadarStatus status, CLLocation *_Nullable location, NSArray<RadarPlace *> *_Nullable places) {
XCTAssertEqual(status, RadarStatusErrorLocation);
Expand Down Expand Up @@ -954,6 +956,7 @@ - (void)test_Radar_searchPlaces_chains_success {
chains:@[@"walmart"]
categories:nil
groups:nil
countryCodes:nil
limit:100
completionHandler:^(RadarStatus status, CLLocation *_Nullable location, NSArray<RadarPlace *> *_Nullable places) {
XCTAssertEqual(status, RadarStatusSuccess);
Expand Down Expand Up @@ -988,6 +991,7 @@ - (void)test_Radar_searchPlaces_chainsAndMetadata_success {
chainMetadata:@{@"orderActive": @"true"}
categories:nil
groups:nil
countryCodes:nil
limit:100
completionHandler:^(RadarStatus status, CLLocation *_Nullable location, NSArray<RadarPlace *> *_Nullable places) {
XCTAssertEqual(status, RadarStatusSuccess);
Expand Down Expand Up @@ -1025,6 +1029,7 @@ - (void)test_Radar_searchPlacesNear_categories_success {
chains:nil
categories:@[@"restaurant"]
groups:nil
countryCodes:nil
limit:100
completionHandler:^(RadarStatus status, CLLocation *_Nullable location, NSArray<RadarPlace *> *_Nullable places) {
XCTAssertEqual(status, RadarStatusSuccess);
Expand Down