Skip to content

Commit

Permalink
add wrapper agents to -first and -next of -request's return value
Browse files Browse the repository at this point in the history
TODO test
  • Loading branch information
lawrence-forooghian committed Jan 15, 2025
1 parent 132d0bc commit 8b94864
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Source/ARTHTTPPaginatedResponse.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ - (instancetype)initWithResponse:(NSHTTPURLResponse *)response
relCurrent:(NSMutableURLRequest *)relCurrent
relNext:(NSMutableURLRequest *)relNext
responseProcessor:(ARTPaginatedResultResponseProcessor)responseProcessor
wrapperSDKAgents:(nullable NSDictionary<NSString *,NSString *> *)wrapperSDKAgents
logger:(ARTInternalLog *)logger {
self = [super initWithItems:items rest:rest relFirst:relFirst relCurrent:relCurrent relNext:relNext responseProcessor:responseProcessor logger:logger];
if (self) {
_response = response;
_wrapperSDKAgents = [wrapperSDKAgents copy];
}
return self;
}
Expand Down Expand Up @@ -60,7 +62,7 @@ - (void)first:(ARTHTTPPaginatedCallback)callback {
};
}

[self.class executePaginated:self.rest withRequest:self.relFirst wrapperSDKAgents:nil logger:self.logger callback:callback];
[self.class executePaginated:self.rest withRequest:self.relFirst wrapperSDKAgents:self.wrapperSDKAgents logger:self.logger callback:callback];
}

- (void)next:(ARTHTTPPaginatedCallback)callback {
Expand All @@ -81,7 +83,7 @@ - (void)next:(ARTHTTPPaginatedCallback)callback {
return;
}

[self.class executePaginated:self.rest withRequest:self.relNext wrapperSDKAgents:nil logger:self.logger callback:callback];
[self.class executePaginated:self.rest withRequest:self.relNext wrapperSDKAgents:self.wrapperSDKAgents logger:self.logger callback:callback];
}

+ (void)executePaginated:(ARTRestInternal *)rest
Expand Down Expand Up @@ -119,7 +121,7 @@ + (void)executePaginated:(ARTRestInternal *)rest
NSMutableURLRequest *currentRel = [NSMutableURLRequest requestWithPath:links[@"current"] relativeTo:request];
NSMutableURLRequest *nextRel = [NSMutableURLRequest requestWithPath:links[@"next"] relativeTo:request];

ARTHTTPPaginatedResponse *result = [[ARTHTTPPaginatedResponse alloc] initWithResponse:response items:items rest:rest relFirst:firstRel relCurrent:currentRel relNext:nextRel responseProcessor:responseProcessor logger:logger];
ARTHTTPPaginatedResponse *result = [[ARTHTTPPaginatedResponse alloc] initWithResponse:response items:items rest:rest relFirst:firstRel relCurrent:currentRel relNext:nextRel responseProcessor:responseProcessor wrapperSDKAgents:wrapperSDKAgents logger:logger];

callback(result, nil);
}];
Expand Down
2 changes: 2 additions & 0 deletions Source/PrivateHeaders/Ably/ARTHTTPPaginatedResponse+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface ARTHTTPPaginatedResponse ()

@property (nonatomic) NSHTTPURLResponse *response;
@property (nullable, nonatomic, readonly) NSDictionary<NSString *, NSString *> *wrapperSDKAgents;

- (instancetype)initWithResponse:(NSHTTPURLResponse *)response
items:(NSArray *)items
Expand All @@ -17,6 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
relCurrent:(NSMutableURLRequest *)relCurrent
relNext:(NSMutableURLRequest *)relNext
responseProcessor:(ARTPaginatedResultResponseProcessor)responseProcessor
wrapperSDKAgents:(nullable NSDictionary<NSString *, NSString *> *)wrapperSDKAgents
logger:(ARTInternalLog *)logger;

+ (void)executePaginated:(ARTRestInternal *)rest
Expand Down

0 comments on commit 8b94864

Please sign in to comment.