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

Fixes completion block type definition #1526

Merged
merged 1 commit into from
Mar 24, 2020
Merged
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
2 changes: 1 addition & 1 deletion Stripe/STPAPIClient+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ NS_ASSUME_NONNULL_BEGIN

- (NSURLSessionDataTask *)retrieveSourceWithId:(NSString *)identifier
clientSecret:(NSString *)secret
responseCompletion:(STPAPIResponseBlock)completion;
responseCompletion:(void (^)(STPSource * _Nullable, NSHTTPURLResponse * _Nullable, NSError * _Nullable))completion;

Choose a reason for hiding this comment

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

If you're sure about this breaking change, you should at least define this new type so that it can be reused by name rather than requiring a full signature match.

Consider: https://github.com/stripe/stripe-ios/blob/7152797d123b20fd3bee8e29ab84b9bf3e9227a2/Stripe/PublicHeaders/STPBlocks.h


@end

Expand Down
4 changes: 3 additions & 1 deletion Stripe/STPAPIClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,9 @@ - (void)retrieveSourceWithId:(NSString *)identifier clientSecret:(NSString *)sec
}];
}

- (NSURLSessionDataTask *)retrieveSourceWithId:(NSString *)identifier clientSecret:(NSString *)secret responseCompletion:(STPAPIResponseBlock)completion {
- (NSURLSessionDataTask *)retrieveSourceWithId:(NSString *)identifier
clientSecret:(NSString *)secret
responseCompletion:(void (^)(STPSource * _Nullable, NSHTTPURLResponse * _Nullable, NSError * _Nullable))completion {

Choose a reason for hiding this comment

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

This completion block is passed straight through into getWithAPIClient, whose signature is expecting a different block structure.

See:

completion:(STPAPIResponseBlock)completion;

NSString *endpoint = [NSString stringWithFormat:@"%@/%@", APIEndpointSources, identifier];
NSDictionary *parameters = @{@"client_secret": secret};
return [STPAPIRequest<STPSource *> getWithAPIClient:self
Expand Down