Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
13 changes: 7 additions & 6 deletions Source/ARTMessageAnnotations.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
@implementation ARTMessageAnnotations

- (instancetype)init {
return [self initWithSummary:nil];
}

- (instancetype)initWithSummary:(nullable ARTJsonObject *)summary {
self = [super init];
if (self) {
_summary = nil;
_summary = summary;
}
return self;
}

- (id)copyWithZone:(NSZone *)zone {
ARTMessageAnnotations *annotations = [[[self class] allocWithZone:zone] init];
annotations.summary = self.summary;
ARTMessageAnnotations *annotations = [[[self class] allocWithZone:zone] initWithSummary:self.summary];
return annotations;
}

Expand All @@ -24,9 +27,7 @@ - (void)writeToDictionary:(NSMutableDictionary<NSString *, id> *)dictionary {
}

+ (instancetype)createFromDictionary:(NSDictionary<NSString *, id> *)jsonObject {
ARTMessageAnnotations *annotations = [[ARTMessageAnnotations alloc] init];
annotations.summary = [jsonObject objectForKey:@"summary"];
return annotations;
return [[ARTMessageAnnotations alloc] initWithSummary:[jsonObject objectForKey:@"summary"]];
}

- (NSString *)description {
Expand Down
47 changes: 26 additions & 21 deletions Source/ARTMessageVersion.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,31 @@
@implementation ARTMessageVersion

- (instancetype)init {
return [self initWithSerial:nil timestamp:nil clientId:nil descriptionText:nil metadata:nil];
}

- (instancetype)initWithSerial:(nullable NSString *)serial
timestamp:(nullable NSDate *)timestamp
clientId:(nullable NSString *)clientId
descriptionText:(nullable NSString *)descriptionText
metadata:(nullable NSDictionary<NSString *, NSString *> *)metadata {
self = [super init];
if (self) {
_serial = nil;
_timestamp = nil;
_clientId = nil;
_descriptionText = nil;
_metadata = nil;
_serial = serial;
_timestamp = timestamp;
_clientId = clientId;
_descriptionText = descriptionText;
_metadata = metadata;
}
return self;
}

- (id)copyWithZone:(NSZone *)zone {
ARTMessageVersion *version = [[[self class] allocWithZone:zone] init];
version.serial = self.serial;
version.timestamp = self.timestamp;
version.clientId = self.clientId;
version.descriptionText = self.descriptionText;
version.metadata = self.metadata;
return version;
return [[self.class allocWithZone:zone] initWithSerial:self.serial
timestamp:self.timestamp
clientId:self.clientId
descriptionText:self.descriptionText
metadata:self.metadata];
}

- (void)writeToDictionary:(NSMutableDictionary<NSString *, id> *)dictionary {
Expand All @@ -46,18 +52,17 @@ - (void)writeToDictionary:(NSMutableDictionary<NSString *, id> *)dictionary {
}

+ (instancetype)createFromDictionary:(NSDictionary<NSString *, id> *)jsonObject {
ARTMessageVersion *version = [[ARTMessageVersion alloc] init];
version.serial = [jsonObject artString:@"serial"];
version.timestamp = [jsonObject artTimestamp:@"timestamp"];
version.clientId = [jsonObject artString:@"clientId"];
version.descriptionText = [jsonObject artString:@"description"];

id metadata = jsonObject[@"metadata"];
NSDictionary<NSString *, NSString *> *metadataDict = nil;
if (metadata && [metadata isKindOfClass:[NSDictionary class]]) {
version.metadata = metadata;
metadataDict = metadata;
}

return version;

return [[ARTMessageVersion alloc] initWithSerial:[jsonObject artString:@"serial"]
timestamp:[jsonObject artTimestamp:@"timestamp"]
clientId:[jsonObject artString:@"clientId"]
descriptionText:[jsonObject artString:@"description"]
metadata:metadataDict];
}

- (NSString *)description {
Expand Down
10 changes: 9 additions & 1 deletion Source/include/Ably/ARTMessageAnnotations.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Contains annotations summary for a message. The keys of the dict are annotation types, and the values are aggregated summaries for that annotation type.
*/
NS_SWIFT_SENDABLE
@interface ARTMessageAnnotations : NSObject

/// An annotations summary for the message. The keys of the dict are annotation types, and the values are aggregated summaries for that annotation type.
@property (nonatomic, copy, nullable) ARTJsonObject *summary;
@property (nonatomic, readonly, nullable) ARTJsonObject *summary;

/**
* Initializes an `ARTMessageAnnotations` with all properties.
*
* @param summary An annotations summary for the message. The keys of the dict are annotation types, and the values are aggregated summaries for that annotation type.
*/
- (instancetype)initWithSummary:(nullable ARTJsonObject *)summary;

@end

Expand Down
26 changes: 21 additions & 5 deletions Source/include/Ably/ARTMessageVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,38 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Contains version information for a message, including operation metadata.
*/
NS_SWIFT_SENDABLE
@interface ARTMessageVersion : NSObject

/// The serial of the message version.
@property (nullable, readwrite, nonatomic) NSString *serial;
@property (nullable, readonly, nonatomic) NSString *serial;

/// The timestamp of the message version.
@property (nullable, readwrite, nonatomic) NSDate *timestamp;
@property (nullable, readonly, nonatomic) NSDate *timestamp;

/// The client ID associated with this version.
@property (nullable, readwrite, nonatomic) NSString *clientId;
@property (nullable, readonly, nonatomic) NSString *clientId;

/// A description of the operation performed.
@property (nullable, readwrite, nonatomic) NSString *descriptionText;
@property (nullable, readonly, nonatomic) NSString *descriptionText;

/// Metadata associated with the operation.
@property (nullable, readwrite, nonatomic) NSDictionary<NSString *, NSString *> *metadata;
@property (nullable, readonly, nonatomic) NSDictionary<NSString *, NSString *> *metadata;

/**
* Initializes an `ARTMessageVersion` with all properties.
*
* @param serial The serial of the message version.
* @param timestamp The timestamp of the message version.
* @param clientId The client ID associated with this version.
* @param descriptionText A description of the operation performed.
* @param metadata Metadata associated with the operation.
*/
- (instancetype)initWithSerial:(nullable NSString *)serial
timestamp:(nullable NSDate *)timestamp
clientId:(nullable NSString *)clientId
descriptionText:(nullable NSString *)descriptionText
metadata:(nullable NSDictionary<NSString *, NSString *> *)metadata;

@end

Expand Down
Loading