Skip to content

Commit cc52467

Browse files
committed
[nit] use jsonRepresentation for consistency
* All public objects that need a serialization method for wrapper SDKs have one * But some are named `toDictionary` while the majority are named `jsonRepresentation` * For consistency, name all these to `jsonRepresentation`
1 parent 3cbbd22 commit cc52467

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

iOS_SDK/OneSignalSDK/OneSignalNotifications/OSPermission.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ typedef NS_ENUM(NSInteger, OSNotificationPermission) {
5454
@property (readonly, nonatomic) BOOL provisional;
5555
@property (readonly, nonatomic) BOOL providesAppNotificationSettings;
5656
@property (readonly, nonatomic) OSNotificationPermission status;
57-
- (NSDictionary* _Nonnull)toDictionary;
57+
- (NSDictionary * _Nonnull)jsonRepresentation;
5858
- (instancetype _Nonnull )initWithStatus:(OSNotificationPermission)status reachable:(BOOL)reachable hasPrompted:(BOOL)hasPrompted provisional:(BOOL)provisional providesAppNotificationSettings:(BOOL)providesAppNotificationSettings;
5959
@end
6060

@@ -96,7 +96,7 @@ typedef OSObservable<NSObject<OSPermissionStateObserver>*, OSPermissionState*> O
9696

9797
@property (readonly, nonnull) OSPermissionState* to;
9898
@property (readonly, nonnull) OSPermissionState* from;
99-
- (NSDictionary* _Nonnull)toDictionary;
99+
- (NSDictionary * _Nonnull)jsonRepresentation;
100100
- (instancetype _Nonnull)initAsTo:(OSPermissionState * _Nonnull)to from:(OSPermissionState * _Nonnull)from;
101101
@end
102102

iOS_SDK/OneSignalSDK/OneSignalNotifications/OSPermission.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ - (NSString*)description {
211211
return [NSString stringWithFormat:format, self.hasPrompted, self.statusAsString, self.provisional];
212212
}
213213

214-
- (NSDictionary*)toDictionary {
214+
- (NSDictionary*)jsonRepresentation {
215215
return @{@"hasPrompted": @(self.hasPrompted),
216216
@"status": @(self.status),
217217
@"provisional" : @(self.provisional)};
@@ -250,8 +250,8 @@ - (NSString*)description {
250250
return [NSString stringWithFormat:format, _from, _to];
251251
}
252252

253-
- (NSDictionary*)toDictionary {
254-
return @{@"from": [_from toDictionary], @"to": [_to toDictionary]};
253+
- (NSDictionary*)jsonRepresentation {
254+
return @{@"from": [_from jsonRepresentation], @"to": [_to jsonRepresentation]};
255255
}
256256

257257
- (instancetype)initAsTo:(OSPermissionState *)to from:(OSPermissionState *)from {

iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSPropertiesModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct OSPropertiesDeltas {
3535
let amountSpent: NSNumber?
3636
let purchases: [[String: AnyObject]]?
3737

38-
func toDictionary() -> [String: Any] {
38+
func jsonRepresentation() -> [String: Any] {
3939
var deltas = [String: Any]()
4040
deltas["session_count"] = sessionCount
4141
deltas["session_time"] = sessionTime?.intValue // server expects an int

iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSPropertyOperationExecutor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ extension OSPropertyOperationExecutor {
144144

145145
let request = OSRequestUpdateProperties(
146146
properties: [:],
147-
deltas: propertiesDeltas.toDictionary(),
147+
deltas: propertiesDeltas.jsonRepresentation(),
148148
refreshDeviceMetadata: refreshDeviceMetadata,
149149
modelToUpdate: propertiesModel,
150150
identityModel: identityModel)

iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSSubscriptionModel.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class OSPushSubscriptionState: NSObject {
5252
self.optedIn = optedIn
5353
}
5454

55-
@objc public func toDictionary() -> NSDictionary {
55+
@objc public func jsonRepresentation() -> NSDictionary {
5656
let id = self.id ?? "nil"
5757
let token = self.token ?? "nil"
5858
return [
@@ -77,8 +77,8 @@ public class OSPushSubscriptionStateChanges: NSObject {
7777
self.from = from
7878
}
7979

80-
@objc public func toDictionary() -> NSDictionary {
81-
return ["from": from.toDictionary(), "to": to.toDictionary()]
80+
@objc public func jsonRepresentation() -> NSDictionary {
81+
return ["from": from.jsonRepresentation(), "to": to.jsonRepresentation()]
8282
}
8383
}
8484

@@ -353,7 +353,7 @@ extension OSSubscriptionModel {
353353
let stateChanges = OSPushSubscriptionStateChanges(to: newSubscriptionState, from: prevSubscriptionState)
354354

355355
// TODO: Don't fire observer until server is udated
356-
OneSignalLog.onesignalLog(.LL_VERBOSE, message: "firePushSubscriptionChanged from \(prevSubscriptionState.toDictionary()) to \(newSubscriptionState.toDictionary())")
356+
OneSignalLog.onesignalLog(.LL_VERBOSE, message: "firePushSubscriptionChanged from \(prevSubscriptionState.jsonRepresentation()) to \(newSubscriptionState.jsonRepresentation())")
357357
OneSignalUserManagerImpl.sharedInstance.pushSubscriptionStateChangesObserver.notifyChange(stateChanges)
358358
}
359359
}

0 commit comments

Comments
 (0)