Skip to content

Commit

Permalink
Restore [STPCard brandFromString:] Method
Browse files Browse the repository at this point in the history
  • Loading branch information
joeydong-stripe committed Sep 21, 2017
1 parent 00d0547 commit e083349
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 11.x.x 2017-XX-XX

* Restores `[STPCard brandFromString:]` method which was marked as deprecated in a recent version [#801](https://github.com/stripe/stripe-ios/pull/801)

## 11.3.0 2017-09-13
* Adds support for creating `STPSourceParams` for P24 source [#779](https://github.com/stripe/stripe-ios/pull/779)
* Adds support for native app-to-app Alipay redirects [#783](https://github.com/stripe/stripe-ios/pull/783)
Expand Down
30 changes: 17 additions & 13 deletions Stripe/PublicHeaders/STPCard.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,23 @@ typedef NS_ENUM(NSInteger, STPCardFundingType) {
*/
+ (NSString *)stringFromBrand:(STPCardBrand)brand;

/**
This parses a string representing a card's brand into the appropriate
STPCardBrand enum value,
i.e. `[STPCard brandFromString:@"American Express"] == STPCardBrandAmex`.
The string values themselves are specific to Stripe as listed in the Stripe API
documentation.
@see https://stripe.com/docs/api#card_object-brand
@param string a string representing the card's brand as returned from
the Stripe API
@return an enum value mapped to that string. If the string is unrecognized,
returns STPCardBrandUnknown.
*/
+ (STPCardBrand)brandFromString:(NSString *)string;

#pragma mark - Deprecated methods

Expand Down Expand Up @@ -196,19 +213,6 @@ typedef NS_ENUM(NSInteger, STPCardFundingType) {
*/
+ (STPCardFundingType)fundingFromString:(NSString *)string DEPRECATED_ATTRIBUTE;

/**
This parses a string representing a card's brand into the appropriate
STPCardBrand enum value,
i.e. `[STPCard brandFromString:@"American Express"] == STPCardBrandAmex`
@param string a string representing the card's brand as returned from
the Stripe API
@return an enum value mapped to that string. If the string is unrecognized,
returns STPCardBrandUnknown.
*/
+ (STPCardBrand)brandFromString:(NSString *)string DEPRECATED_ATTRIBUTE;

@end

NS_ASSUME_NONNULL_END
1 change: 0 additions & 1 deletion Stripe/STPCard+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (STPCardFundingType)fundingFromString:(NSString *)string;
+ (nullable NSString *)stringFromFunding:(STPCardFundingType)funding;

+ (STPCardBrand)brandFromString:(NSString *)string;
+ (NSString *)stringFromBrand:(STPCardBrand)brand;

@end
Expand Down
5 changes: 2 additions & 3 deletions Stripe/STPCard.m
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,11 @@ + (nullable instancetype)decodedObjectFromAPIResponse:(nullable NSDictionary *)r
card.name = dict[@"name"];
card.last4 = dict[@"last4"];
card.dynamicLast4 = dict[@"dynamic_last4"];
card.brand = [self.class brandFromString:dict[@"brand"]];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
// These are only intended to be deprecated publicly.
// This is only intended to be deprecated publicly.
// When removed from public header, can remove these pragmas

card.brand = [self.class brandFromString:dict[@"brand"]];
card.funding = [self.class fundingFromString:dict[@"funding"]];
#pragma clang diagnostic pop

Expand Down
4 changes: 2 additions & 2 deletions Stripe/STPSourceCardDetails.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ - (instancetype)initWithDictionary:(NSDictionary *)dict {
self = [super init];
if (self) {
_last4 = dict[@"last4"];
_brand = [STPCard brandFromString:dict[@"brand"]];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
// These are only intended to be deprecated publicly.
// This is only intended to be deprecated publicly.
// When removed from public header, can remove these pragmas
_brand = [STPCard brandFromString:dict[@"brand"]];
_funding = [STPCard fundingFromString:dict[@"funding"]];
#pragma clang diagnostic pop
_country = dict[@"country"];
Expand Down
3 changes: 0 additions & 3 deletions Tests/Tests/STPCardTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ @implementation STPCardTest

#pragma mark - STPCardBrand Tests

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
// These are only intended to be deprecated publicly.
// When removed from public header, can remove these pragmas
- (void)testBrandFromString {
Expand Down Expand Up @@ -61,7 +59,6 @@ - (void)testBrandFromString {
XCTAssertEqual([STPCard brandFromString:@"garbage"], STPCardBrandUnknown);
XCTAssertEqual([STPCard brandFromString:@"GARBAGE"], STPCardBrandUnknown);
}
#pragma clang diagnostic pop

- (void)testStringFromBrand {
[self forEachBrand:^(STPCardBrand brand) {
Expand Down

0 comments on commit e083349

Please sign in to comment.