Skip to content

Commit

Permalink
Reformat to more closely match android impl
Browse files Browse the repository at this point in the history
  • Loading branch information
lmeier committed Dec 5, 2024
1 parent ad35612 commit 8c60f12
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions RadarSDK/RadarAPIHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@ - (void)requestWithMethod:(NSString *)method
}

if (params) {
if (!params[@"updatedAtMsDiff"] && !params[@"replays"]) {
[req setHTTPBody:[NSJSONSerialization dataWithJSONObject:params options:0 error:NULL]];
} else {
NSNumber *prevUpdatedAtMsDiff = params[@"updatedAtMsDiff"];
NSArray *replays = params[@"replays"];
if (prevUpdatedAtMsDiff || replays) {
NSMutableDictionary *requestParams = [params mutableCopy];
NSNumber *locationMs = params[@"locationMs"];
NSNumber *prevUpdatedAtMsDiff = params[@"updatedAtMsDiff"];
long nowMs = (long)([NSDate date].timeIntervalSince1970 * 1000);

if (locationMs && prevUpdatedAtMsDiff) {
long updatedAtMsDiff = nowMs - [locationMs longValue];
requestParams[@"updatedAtMsDiff"] = @(updatedAtMsDiff);
Expand All @@ -95,6 +96,8 @@ - (void)requestWithMethod:(NSString *)method
}

[req setHTTPBody:[NSJSONSerialization dataWithJSONObject:requestParams options:0 error:NULL]];
} else {
[req setHTTPBody:[NSJSONSerialization dataWithJSONObject:params options:0 error:NULL]];
}
}

Expand Down

0 comments on commit 8c60f12

Please sign in to comment.