From c407ff9a504d0c3439c1a38d2e8a5b12a904082e Mon Sep 17 00:00:00 2001 From: Ben DiFrancesco Date: Tue, 6 Jun 2017 13:00:53 -0700 Subject: [PATCH 1/3] Rip out all Payments related code and update tests --- ios/cloudmine-ios.xcodeproj/project.pbxproj | 36 ------ ios/ios/src/CloudMine.h | 3 - ios/ios/src/Users/CMUser.h | 33 ----- ios/ios/src/Users/CMUser.m | 95 +-------------- ios/ios/src/Web Services/CMCardPayment.h | 34 ------ ios/ios/src/Web Services/CMCardPayment.m | 42 ------- ios/ios/src/Web Services/CMPaymentResponse.h | 32 ----- ios/ios/src/Web Services/CMPaymentResponse.m | 18 --- ios/ios/src/Web Services/CMPaymentService.h | 52 -------- ios/ios/src/Web Services/CMPaymentService.m | 101 ---------------- ios/iosTests/CMPaymentServiceSpec.m | 121 ------------------- ios/iosTests/CMUserIntegrationSpec.m | 102 ++-------------- ios/iosTests/CMUserSpec.m | 52 -------- 13 files changed, 15 insertions(+), 706 deletions(-) delete mode 100644 ios/ios/src/Web Services/CMCardPayment.h delete mode 100644 ios/ios/src/Web Services/CMCardPayment.m delete mode 100644 ios/ios/src/Web Services/CMPaymentResponse.h delete mode 100644 ios/ios/src/Web Services/CMPaymentResponse.m delete mode 100644 ios/ios/src/Web Services/CMPaymentService.h delete mode 100644 ios/ios/src/Web Services/CMPaymentService.m delete mode 100644 ios/iosTests/CMPaymentServiceSpec.m diff --git a/ios/cloudmine-ios.xcodeproj/project.pbxproj b/ios/cloudmine-ios.xcodeproj/project.pbxproj index ba78d75f..97be2407 100644 --- a/ios/cloudmine-ios.xcodeproj/project.pbxproj +++ b/ios/cloudmine-ios.xcodeproj/project.pbxproj @@ -135,7 +135,6 @@ AA0351A01992AD6A00A3027E /* CMSocialAccountChooserSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = AA03519F1992AD6A00A3027E /* CMSocialAccountChooserSpec.m */; }; AA095166194B6C09008602DB /* CMAPICredentialsSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = AA095165194B6C09008602DB /* CMAPICredentialsSpec.m */; }; AA095168194B6CB4008602DB /* CMAppDelegateBaseSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = AA095167194B6CB4008602DB /* CMAppDelegateBaseSpec.m */; }; - AA09516D194B7AA7008602DB /* CMPaymentServiceSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = AA09516C194B7AA7008602DB /* CMPaymentServiceSpec.m */; }; AA104FE8196326D70043C141 /* TestUser.m in Sources */ = {isa = PBXBuildFile; fileRef = AA104FE7196326D70043C141 /* TestUser.m */; }; AA5693C31901790300C4A15A /* CMConstants.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = AA5693C21901790300C4A15A /* CMConstants.h */; }; AA5693C71902E90500C4A15A /* CMTestEncoder.m in Sources */ = {isa = PBXBuildFile; fileRef = AA5693C61902E90500C4A15A /* CMTestEncoder.m */; }; @@ -155,12 +154,6 @@ AA9528D4194B422800AEB90D /* CMNullStoreSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = AA9528D3194B422800AEB90D /* CMNullStoreSpec.m */; }; AA9927C0195C7DBF00C46F02 /* Accounts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AA9927BF195C7DBF00C46F02 /* Accounts.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; AA9927C2195C7DC700C46F02 /* Social.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AA9927C1195C7DC700C46F02 /* Social.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; - AAA05FB9183A756B009652C9 /* CMPaymentService.m in Sources */ = {isa = PBXBuildFile; fileRef = AAA05FB3183A756B009652C9 /* CMPaymentService.m */; }; - AAA05FBB183A756B009652C9 /* CMPaymentService.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = AAA05FB4183A756B009652C9 /* CMPaymentService.h */; }; - AAA05FBC183A756B009652C9 /* CMCardPayment.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = AAA05FB5183A756B009652C9 /* CMCardPayment.h */; }; - AAA05FBD183A756B009652C9 /* CMPaymentResponse.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = AAA05FB6183A756B009652C9 /* CMPaymentResponse.h */; }; - AAA05FBE183A756B009652C9 /* CMCardPayment.m in Sources */ = {isa = PBXBuildFile; fileRef = AAA05FB7183A756B009652C9 /* CMCardPayment.m */; }; - AAA05FC0183A756B009652C9 /* CMPaymentResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = AAA05FB8183A756B009652C9 /* CMPaymentResponse.m */; }; AAA102D519265AEC00A11BC4 /* CMObjectIntegrationSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = AAA102D419265AEC00A11BC4 /* CMObjectIntegrationSpec.m */; }; AAA850ED168271B600C18957 /* CMDeviceTokenResult.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = AAA850EC168271B500C18957 /* CMDeviceTokenResult.h */; }; AAA92FF3181966370064F773 /* NSDictionary+CMJSON.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = AAA92FF1181966370064F773 /* NSDictionary+CMJSON.h */; }; @@ -226,7 +219,6 @@ AAC1D8FA16DD5B34002A7DC0 /* CMChannelResponse.h in CopyFiles */, AAB2E0B4167BA05700D2C699 /* CMAppDelegateBase.h in CopyFiles */, 715217581653F5C4007FB0A9 /* CMSocialLoginViewController.h in CopyFiles */, - AAA05FBB183A756B009652C9 /* CMPaymentService.h in CopyFiles */, D03A4D5C15B48D2200A956BC /* CMACLFetchResponse.h in CopyFiles */, 7AF00BA215A8DC7C0070442A /* CMACL.h in CopyFiles */, AA5C4632190C19990086FBD6 /* CMCoding.h in CopyFiles */, @@ -270,9 +262,7 @@ 7A87315714BB0AD0000D6DEA /* CMWebService.h in CopyFiles */, 7A87315914BB0AD0000D6DEA /* CMAPICredentials.h in CopyFiles */, 7A87315A14BB0AD0000D6DEA /* CMServerFunction.h in CopyFiles */, - AAA05FBC183A756B009652C9 /* CMCardPayment.h in CopyFiles */, 7A87315B14BB0AD0000D6DEA /* CMSerializable.h in CopyFiles */, - AAA05FBD183A756B009652C9 /* CMPaymentResponse.h in CopyFiles */, AAA850ED168271B600C18957 /* CMDeviceTokenResult.h in CopyFiles */, AA5693C31901790300C4A15A /* CMConstants.h in CopyFiles */, AA00CED21886E1C700F9958C /* UIImageView+CloudMine.h in CopyFiles */, @@ -401,7 +391,6 @@ AA03519F1992AD6A00A3027E /* CMSocialAccountChooserSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CMSocialAccountChooserSpec.m; sourceTree = ""; }; AA095165194B6C09008602DB /* CMAPICredentialsSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CMAPICredentialsSpec.m; sourceTree = ""; }; AA095167194B6CB4008602DB /* CMAppDelegateBaseSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CMAppDelegateBaseSpec.m; sourceTree = ""; }; - AA09516C194B7AA7008602DB /* CMPaymentServiceSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CMPaymentServiceSpec.m; sourceTree = ""; }; AA104FE6196326D70043C141 /* TestUser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestUser.h; sourceTree = ""; }; AA104FE7196326D70043C141 /* TestUser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestUser.m; sourceTree = ""; }; AA4DE2BA1A6972A600888CB2 /* CMTestMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CMTestMacros.h; sourceTree = ""; }; @@ -425,12 +414,6 @@ AA9528D3194B422800AEB90D /* CMNullStoreSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CMNullStoreSpec.m; sourceTree = ""; }; AA9927BF195C7DBF00C46F02 /* Accounts.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accounts.framework; path = System/Library/Frameworks/Accounts.framework; sourceTree = SDKROOT; }; AA9927C1195C7DC700C46F02 /* Social.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Social.framework; path = System/Library/Frameworks/Social.framework; sourceTree = SDKROOT; }; - AAA05FB3183A756B009652C9 /* CMPaymentService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CMPaymentService.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; - AAA05FB4183A756B009652C9 /* CMPaymentService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = CMPaymentService.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; - AAA05FB5183A756B009652C9 /* CMCardPayment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CMCardPayment.h; sourceTree = ""; }; - AAA05FB6183A756B009652C9 /* CMPaymentResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CMPaymentResponse.h; sourceTree = ""; }; - AAA05FB7183A756B009652C9 /* CMCardPayment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CMCardPayment.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; - AAA05FB8183A756B009652C9 /* CMPaymentResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CMPaymentResponse.m; sourceTree = ""; }; AAA102D419265AEC00A11BC4 /* CMObjectIntegrationSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CMObjectIntegrationSpec.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; AAA850EC168271B500C18957 /* CMDeviceTokenResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CMDeviceTokenResult.h; sourceTree = ""; }; AAA92FF1181966370064F773 /* NSDictionary+CMJSON.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+CMJSON.h"; sourceTree = ""; }; @@ -756,7 +739,6 @@ 7AD36F7B146C64F300DD4734 /* Web Services */ = { isa = PBXGroup; children = ( - AAA05FB2183A7558009652C9 /* Payment */, AAB2E0A8167B935C00D2C699 /* Push Notifications */, 71E886B3165161050060C217 /* Social Login */, 7AABA2FA14818DCA00FD52A0 /* Decoding */, @@ -879,7 +861,6 @@ 7AD9221F14CF5B9B0032DDDE /* CMPagingDescriptorSpec.m */, 7AD9222514D06EB10032DDDE /* CMStoreOptionsSpec.m */, 7A766208156307DF009840EE /* CMSortDescriptorSpec.m */, - AA09516C194B7AA7008602DB /* CMPaymentServiceSpec.m */, AA03519F1992AD6A00A3027E /* CMSocialAccountChooserSpec.m */, AA5EB16C1A3FEB300081DAC1 /* Bugs */, ); @@ -909,19 +890,6 @@ name = Bugs; sourceTree = ""; }; - AAA05FB2183A7558009652C9 /* Payment */ = { - isa = PBXGroup; - children = ( - AAA05FB4183A756B009652C9 /* CMPaymentService.h */, - AAA05FB3183A756B009652C9 /* CMPaymentService.m */, - AAA05FB5183A756B009652C9 /* CMCardPayment.h */, - AAA05FB7183A756B009652C9 /* CMCardPayment.m */, - AAA05FB6183A756B009652C9 /* CMPaymentResponse.h */, - AAA05FB8183A756B009652C9 /* CMPaymentResponse.m */, - ); - name = Payment; - sourceTree = ""; - }; AAA92FEB181965F80064F773 /* JSON */ = { isa = PBXGroup; children = ( @@ -1215,7 +1183,6 @@ 7A7E31C914C88F8A0091F1E3 /* CMStore.m in Sources */, 7AD9221D14CF47360032DDDE /* CMPagingDescriptor.m in Sources */, 7AD9222414D06B9A0032DDDE /* CMStoreOptions.m in Sources */, - AAA05FC0183A756B009652C9 /* CMPaymentResponse.m in Sources */, B4AD7C581C80FF6D00D9F1D1 /* RTUnregisteredClass.m in Sources */, 7A58CC2214F1B544003E864B /* CMMimeType.m in Sources */, 7AE2848B1562C3C8003E8A8F /* CMSortDescriptor.m in Sources */, @@ -1240,12 +1207,10 @@ 7AFDFE46158E959B00388D6E /* CMObjectClassNameRegistry.m in Sources */, 7AFDFE47158E959B00388D6E /* CMUntypedObject.m in Sources */, 7A0D7CFC1581479000C7C476 /* CMNullStore.m in Sources */, - AAA05FBE183A756B009652C9 /* CMCardPayment.m in Sources */, 7AFDFE4A158E965400388D6E /* CMActiveUser.m in Sources */, 7AF00BA015A8DC650070442A /* CMACL.m in Sources */, B4C114D11DA2CF2B00414F35 /* CMLegacyCacheCleaner.m in Sources */, B4AD7C521C80FF6D00D9F1D1 /* MARTNSObject.m in Sources */, - AAA05FB9183A756B009652C9 /* CMPaymentService.m in Sources */, 7AF00BA115A8DC650070442A /* CMUser.m in Sources */, D042C2EB15AF41F100A88888 /* CMACLFetchResponse.m in Sources */, AAA92FFE181972DA0064F773 /* CMTools.m in Sources */, @@ -1282,7 +1247,6 @@ 7AD9222014CF5B9B0032DDDE /* CMPagingDescriptorSpec.m in Sources */, AAD4AD161908104B006B93F2 /* CMUserIntegrationSpec.m in Sources */, AA9528D4194B422800AEB90D /* CMNullStoreSpec.m in Sources */, - AA09516D194B7AA7008602DB /* CMPaymentServiceSpec.m in Sources */, AAE92211194B923D004DA1AC /* CMWebServiceIntegrationSpec.m in Sources */, 7AD9222614D06EB10032DDDE /* CMStoreOptionsSpec.m in Sources */, 7AD93BAF14D1CCFE00CC1CC9 /* CMFileSpec.m in Sources */, diff --git a/ios/ios/src/CloudMine.h b/ios/ios/src/CloudMine.h index 82f766b7..5f0faf73 100644 --- a/ios/ios/src/CloudMine.h +++ b/ios/ios/src/CloudMine.h @@ -78,8 +78,5 @@ #import "CMDeleteResponse.h" #import "CMChannelResponse.h" #import "CMUserResponse.h" -#import "CMPaymentService.h" -#import "CMPaymentResponse.h" -#import "CMCardPayment.h" #import "UIImageView+CloudMine.h" diff --git a/ios/ios/src/Users/CMUser.h b/ios/ios/src/Users/CMUser.h index be2dd5bc..20cfa234 100644 --- a/ios/ios/src/Users/CMUser.h +++ b/ios/ios/src/Users/CMUser.h @@ -11,7 +11,6 @@ #import "CMSerializable.h" #import "CMUserAccountResult.h" #import "CMSocialLoginViewController.h" -#import "CMPaymentResponse.h" @class CMCardPayment, CMUserResponse, ACAccount, CMObjectFetchResponse; @@ -645,36 +644,4 @@ typedef void (^CMUserFetchWithMetaCallback)(CMObjectFetchResponse *response); */ + (void)userWithIdentifier:(NSString *)identifier callback:(CMUserFetchCallback)callback; -/** - * Asynchronously adds a payment method (A credit card) to the user. The user should be logged in. - * - * @param paymentMethod The Credit Card you are adding. - * @param callback The block that will be called on completion of the operation. - */ -- (void)addPaymentMethod:(CMCardPayment *)paymentMethod callback:(CMPaymentServiceCallback)callback; - -/** - * Asynchronously adds payment methods (credit cards) to the user. The user should be logged in. - * - * @param paymentMethods The Credit Cards (CMPayment) you are adding. - * @param callback The block that will be called on completion of the operation. - */ -- (void)addPaymentMethods:(NSArray *)paymentMethods callback:(CMPaymentServiceCallback)callback; - -/** - * Asynchronously removes a payment (A credit card) from the user. The user should be logged in. The - * index is which credit card you want to remove. - * - * @param index The index for the Payment you are removing. - * @param callback The block that will be called on completion of the operation. - */ -- (void)removePaymentMethodAtIndex:(NSUInteger)index callback:(CMPaymentServiceCallback)callback; - -/** - * Asynchronously fetches the payment methods for the user. The user should be logged in. - * - * @param callback The block that will be called on completion of the operation. - */ -- (void)paymentMethods:(CMPaymentServiceCallback)callback; - @end diff --git a/ios/ios/src/Users/CMUser.m b/ios/ios/src/Users/CMUser.m index 6f7b01ca..569d9e83 100644 --- a/ios/ios/src/Users/CMUser.m +++ b/ios/ios/src/Users/CMUser.m @@ -11,10 +11,12 @@ #import "CMObjectSerialization.h" #import "CMObjectDecoder.h" #import "CMObjectEncoder.h" -#import "CMCardPayment.h" #import "NSDictionary+CMJSON.h" #import "CMUserResponse.h" - +#import "CMStoreOptions.h" +#import "CMObjectFetchResponse.h" +#import "CMResponseMetadata.h" +#import "CMSnippetResult.h" #import "MARTNSObject.h" #import "RTProperty.h" @@ -509,95 +511,6 @@ - (void)getProfile:(CMUserOperationCallback)callback; }]; } -#pragma mark - Payment Methods - -- (void)addPaymentMethod:(CMCardPayment *)paymentMethod callback:(CMPaymentServiceCallback)callback; -{ - [self addPaymentMethods:@[paymentMethod] callback:callback]; - } - -- (void)addPaymentMethods:(NSArray *)paymentMethods callback:(CMPaymentServiceCallback)callback; -{ - //serialize payment method - NSString *urlString = @"payments/account/methods/card"; - - NSURL *url = [_webService constructAppURLWithString:urlString andDescriptors:nil]; - NSMutableURLRequest *request = [_webService constructHTTPRequestWithVerb:@"POST" URL:url binaryData:NO user:self]; - - NSMutableArray *payments = [NSMutableArray array]; - NSDictionary *encoded = [CMObjectEncoder encodeObjects:paymentMethods]; - [encoded enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { - [payments addObject:obj]; - }]; - - NSDictionary *finalEncoding = @{@"payments": payments}; - - NSError *error = nil; - NSData *data = [NSJSONSerialization dataWithJSONObject:finalEncoding options:0 error:&error]; - if (error) { - NSLog(@"There was an error serializing the CMPayment Object! %@", error); - } - - [request setHTTPBody:data]; - - [_webService executeGenericRequest:request successHandler:^(id parsedBody, NSUInteger httpCode, NSDictionary *headers) { - CMPaymentResponse *response = [[CMPaymentResponse alloc] initWithResponseBody:parsedBody httpCode:httpCode headers:headers errors:nil]; - response.result = CMPaymentResultSuccessful; - if (callback) callback(response); - } errorHandler:^(id responseBody, NSUInteger httpCode, NSDictionary *headers, NSError *error, NSDictionary *errorInfo) { - CMPaymentResponse *response = [[CMPaymentResponse alloc] initWithResponseBody:responseBody httpCode:httpCode headers:headers errors:errorInfo]; - response.result = CMPaymentResultFailed; - if (callback) callback(response); - }]; -} - -- (void)removePaymentMethodAtIndex:(NSUInteger)index callback:(CMPaymentServiceCallback)callback; -{ - NSString *urlString = [NSString stringWithFormat:@"payments/account/methods/card/%lu", (unsigned long)index]; - - NSURL *url = [_webService constructAppURLWithString:urlString andDescriptors:nil]; - NSMutableURLRequest *request = [_webService constructHTTPRequestWithVerb:@"DELETE" URL:url binaryData:NO user:self]; - - [_webService executeGenericRequest:request successHandler:^(id parsedBody, NSUInteger httpCode, NSDictionary *headers) { - CMPaymentResponse *response = [[CMPaymentResponse alloc] initWithResponseBody:parsedBody httpCode:httpCode headers:headers errors:nil]; - response.result = CMPaymentResultSuccessful; - if (callback) callback(response); - } errorHandler:^(id responseBody, NSUInteger httpCode, NSDictionary *headers, NSError *error, NSDictionary *errorInfo) { - CMPaymentResponse *response = [[CMPaymentResponse alloc] initWithResponseBody:responseBody httpCode:httpCode headers:headers errors:errorInfo]; - response.result = CMPaymentResultFailed; - if (callback) callback(response); - }]; -} - -- (void)paymentMethods:(CMPaymentServiceCallback)callback; -{ - NSString *urlString = @"payments/account/methods"; - - NSURL *url = [_webService constructAppURLWithString:urlString andDescriptors:nil]; - NSMutableURLRequest *request = [_webService constructHTTPRequestWithVerb:@"GET" URL:url binaryData:NO user:self]; - - [_webService executeGenericRequest:request successHandler:^(id parsedBody, NSUInteger httpCode, NSDictionary *headers) { - - NSMutableArray *finishedObjects = [NSMutableArray array]; - for (NSDictionary *dictionary in parsedBody[@"card"]) { - CMObjectDecoder *decoder = [[CMObjectDecoder alloc] initWithSerializedObjectRepresentation:dictionary]; - CMCardPayment *newPayment = [[CMCardPayment alloc] initWithCoder:decoder]; - [finishedObjects addObject:newPayment]; - } - - CMPaymentResponse *response = [[CMPaymentResponse alloc] initWithResponseBody:finishedObjects httpCode:httpCode headers:headers errors:nil]; - response.result = CMPaymentResultSuccessful; - if (callback) callback(response); - } errorHandler:^(id responseBody, NSUInteger httpCode, NSDictionary *headers, NSError *error, NSDictionary *errorInfo) { - CMPaymentResponse *response = [[CMPaymentResponse alloc] initWithResponseBody:responseBody httpCode:httpCode headers:headers errors:errorInfo]; - response.result = CMPaymentResultFailed; - if (callback) callback(response); - }]; -} - - - - #pragma mark - Social Login // This code is very similar to login above, perhaps we can refactor. diff --git a/ios/ios/src/Web Services/CMCardPayment.h b/ios/ios/src/Web Services/CMCardPayment.h deleted file mode 100644 index 303e3447..00000000 --- a/ios/ios/src/Web Services/CMCardPayment.h +++ /dev/null @@ -1,34 +0,0 @@ -// -// CMPayment.h -// cloudmine-ios -// -// Created by Ethan Mick on 7/10/13. -// Copyright (c) 2016 CloudMine, Inc. All rights reserved. -// - -#import "CMObject.h" - -FOUNDATION_EXPORT NSString *const CMCardPaymentTypeVisa; -FOUNDATION_EXPORT NSString *const CMCardPaymentTypeMasterCard; -FOUNDATION_EXPORT NSString *const CMCardPaymentTypeAmericanExpress; -FOUNDATION_EXPORT NSString *const CMCardPaymentTypeDinersClub; -FOUNDATION_EXPORT NSString *const CMCardPaymentTypeDiscover; -FOUNDATION_EXPORT NSString *const CMCardPaymentTypeJCB; -FOUNDATION_EXPORT NSString *const CMCardPaymentTypeUnknown; - -/** - * This holds "Whatever information Derek needs to make the payment happen." - * Now, this will change for the different gateways... so either we can try to get everything in this - * one object... or make a generic CMPayment object and users can subclass it for their individual - * gateways. Perhaps we create a few nice default ones for the Gateways we support out of the box. - * - */ -@interface CMCardPayment : CMObject - -@property (nonatomic, copy) NSString *nameOnCard; -@property (nonatomic, copy) NSString *token; -@property (nonatomic, copy) NSString *expirationDate; //0914 -@property (nonatomic, copy) NSString *last4Digits; -@property (nonatomic, copy) NSString *type; - -@end diff --git a/ios/ios/src/Web Services/CMCardPayment.m b/ios/ios/src/Web Services/CMCardPayment.m deleted file mode 100644 index d31233a1..00000000 --- a/ios/ios/src/Web Services/CMCardPayment.m +++ /dev/null @@ -1,42 +0,0 @@ -// -// CMPayment.m -// cloudmine-ios -// -// Created by Ethan Mick on 7/10/13. -// Copyright (c) 2016 CloudMine, Inc. All rights reserved. -// - -#import "CMCardPayment.h" - -NSString *const CMCardPaymentTypeVisa = @"visa"; -NSString *const CMCardPaymentTypeMasterCard = @"mc"; -NSString *const CMCardPaymentTypeAmericanExpress = @"amex"; -NSString *const CMCardPaymentTypeDinersClub = @"othr"; -NSString *const CMCardPaymentTypeDiscover = @"disc"; -NSString *const CMCardPaymentTypeJCB = @"jcb"; -NSString *const CMCardPaymentTypeUnknown = @"othr"; - -@implementation CMCardPayment - -- (instancetype)initWithCoder:(NSCoder *)aDecoder { - - if ( (self = [super initWithCoder:aDecoder]) ) { - self.nameOnCard = [aDecoder decodeObjectForKey:@"nameOnCard"]; - self.token = [aDecoder decodeObjectForKey:@"token"]; - self.expirationDate = [aDecoder decodeObjectForKey:@"expirationDate"]; - self.last4Digits = [aDecoder decodeObjectForKey:@"last4Digits"]; - self.type = [aDecoder decodeObjectForKey:@"type"]; - } - return self; -} - -- (void)encodeWithCoder:(NSCoder *)aCoder { - [aCoder encodeObject:self.nameOnCard forKey:@"nameOnCard"]; - [aCoder encodeObject:self.token forKey:@"token"]; - [aCoder encodeObject:self.expirationDate forKey:@"expirationDate"]; - [aCoder encodeObject:self.last4Digits forKey:@"last4Digits"]; - [aCoder encodeObject:self.type forKey:@"type"]; -} - - -@end diff --git a/ios/ios/src/Web Services/CMPaymentResponse.h b/ios/ios/src/Web Services/CMPaymentResponse.h deleted file mode 100644 index e8198fa6..00000000 --- a/ios/ios/src/Web Services/CMPaymentResponse.h +++ /dev/null @@ -1,32 +0,0 @@ -// -// CMPaymentResponse.h -// cloudmine-ios -// -// Created by Ethan Mick on 7/10/13. -// Copyright (c) 2016 CloudMine, Inc. All rights reserved. -// - -#import "CMResponse.h" - -typedef NS_ENUM(NSInteger, CMPaymentResult) { - /** The payment request failed. We can add in more details here as we know. Why did it fail. */ - CMPaymentResultFailed = 0, - - /** The payment request was a success */ - CMPaymentResultSuccessful = 1, - -}; - -/** - * CMPaymentResponse - * Encapsualtes the response of creating a payment. - */ -@interface CMPaymentResponse : CMResponse - -@property (nonatomic) CMPaymentResult result; - -@end - -typedef void (^CMPaymentServiceCallback)(CMPaymentResponse *response); - - diff --git a/ios/ios/src/Web Services/CMPaymentResponse.m b/ios/ios/src/Web Services/CMPaymentResponse.m deleted file mode 100644 index 07239410..00000000 --- a/ios/ios/src/Web Services/CMPaymentResponse.m +++ /dev/null @@ -1,18 +0,0 @@ -// -// CMPaymentResponse.m -// cloudmine-ios -// -// Created by Ethan Mick on 7/10/13. -// Copyright (c) 2016 CloudMine, Inc. All rights reserved. -// - -#import "CMPaymentResponse.h" - -@implementation CMPaymentResponse - -- (CMPaymentResult)result; -{ - return [self wasSuccess] ? CMPaymentResultSuccessful : CMPaymentResultFailed; -} - -@end diff --git a/ios/ios/src/Web Services/CMPaymentService.h b/ios/ios/src/Web Services/CMPaymentService.h deleted file mode 100644 index 6689e383..00000000 --- a/ios/ios/src/Web Services/CMPaymentService.h +++ /dev/null @@ -1,52 +0,0 @@ -// -// CMPaymentService.h -// cloudmine-ios -// -// Created by Ethan Mick on 7/10/13. -// Copyright (c) 2016 CloudMine, Inc. All rights reserved. -// - -#import -#import "CMPaymentResponse.h" - -@class CMUser, CMCardPayment; - -@interface CMPaymentService : NSObject - -@property (nonatomic, strong) CMUser *user; - -/** - * Initialize the payment service. - */ -- (instancetype)init; - -/** - * Initialize the payment service with the given user. - * - * This is the designated constructor. - * - * @param aUser The user to initialize the service with. - */ -- (instancetype)initWithUser:(CMUser *)aUser; - -/** - * Start a transaction with the given cart and payment info. - * - * @param cart This object can be anything you want. It is serialized into JSON. - * - */ -- (void)initializeTransactionWithCart:(id)cart paymentInfo:(CMCardPayment *)paymentInfo descriptors:(NSArray *)descriptors callback:(CMPaymentServiceCallback)callback; - -/** - * Completes the transaction started after initializeTransaction has been called. - * - */ -- (void)fulfillTransactionWithID:(NSString *)transactionID descriptors:(NSArray *)descriptors callback:(CMPaymentServiceCallback)callback; - -/* - * Charges the card at the index and processes the cart. This checks out and fulfills the order. You will probably want to use this most of the time. - */ -- (void)chargeCardAtIndex:(NSUInteger)index cart:(id)cart callback:(CMPaymentServiceCallback)callback; - - -@end diff --git a/ios/ios/src/Web Services/CMPaymentService.m b/ios/ios/src/Web Services/CMPaymentService.m deleted file mode 100644 index 54c96610..00000000 --- a/ios/ios/src/Web Services/CMPaymentService.m +++ /dev/null @@ -1,101 +0,0 @@ -// -// CMPaymentService.m -// cloudmine-ios -// -// Created by Ethan Mick on 7/10/13. -// Copyright (c) 2016 CloudMine, Inc. All rights reserved. -// - -#import "CMPaymentService.h" -#import "CMUser.h" -#import "CMWebService.h" -#import "CMCardPayment.h" -#import "CMObjectEncoder.h" -#import "NSDictionary+CMJSON.h" - -@interface CMPaymentService () - -@property (nonatomic, strong) CMWebService *service; -@property (nonatomic, strong) void (^successCallback)(id, NSUInteger, NSDictionary*); -@property (nonatomic, strong) void (^failureCallback)(id, NSUInteger, NSDictionary*, NSError*, NSDictionary*); -@property (nonatomic, strong) CMPaymentServiceCallback callback; - -@end - -@implementation CMPaymentService - -- (instancetype)init; -{ - return [self initWithUser:nil]; -} - -- (instancetype)initWithUser:(CMUser *)aUser; -{ - - if ( (self = [super init]) ) { - self.user = aUser; - self.service = [CMWebService sharedWebService]; - - CMPaymentService *selff = self; - - self.successCallback = ^(id parsedBody, NSUInteger httpCode, NSDictionary *headers){ - CMPaymentResponse *response = [[CMPaymentResponse alloc] initWithResponseBody:parsedBody httpCode:httpCode headers:headers errors:nil]; - if (selff.callback) selff.callback(response); - }; - - self.failureCallback = ^(id responseBody, NSUInteger httpCode, NSDictionary *headers, NSError *error, NSDictionary *errorInfo) { - CMPaymentResponse *response = [[CMPaymentResponse alloc] initWithResponseBody:responseBody httpCode:httpCode headers:headers errors:errorInfo]; - if (selff.callback) selff.callback(response); - }; - } - - return self; -} - -- (void)initializeTransactionWithCart:(id)cart paymentInfo:(CMCardPayment *)paymentInfo descriptors:(NSArray *)descriptors callback:(CMPaymentServiceCallback)callback; -{ - self.callback = callback; - NSMutableURLRequest *request = [self chargeRequestWithEndpoint:@"init" cart:cart paymentInfo:paymentInfo descriptors:descriptors]; - [self.service executeGenericRequest:request successHandler:self.successCallback errorHandler:self.failureCallback]; -} - -- (void)fulfillTransactionWithID:(NSString *)transactionID descriptors:(NSArray *)descriptors callback:(CMPaymentServiceCallback)callback; -{ - self.callback = callback; - NSString *urlString = [NSString stringWithFormat:@"payments/transaction/%@/fulfill", transactionID]; - - NSURL *url = [self.service constructAppURLWithString:urlString andDescriptors:descriptors]; - NSMutableURLRequest *request = [self.service constructHTTPRequestWithVerb:@"GET" URL:url binaryData:NO user:_user]; - - [self.service executeGenericRequest:request successHandler:self.successCallback errorHandler:self.failureCallback]; -} - -- (void)chargeCardAtIndex:(NSUInteger)index cart:(id)cart callback:(CMPaymentServiceCallback)callback; -{ - self.callback = callback; - - NSURL *url = [self.service constructAppURLWithString:@"payments/transaction/charge" andDescriptors:nil]; - NSMutableURLRequest *request = [self.service constructHTTPRequestWithVerb:@"POST" URL:url binaryData:NO user:_user]; - [request setHTTPBody:[@{@"cart" : cart, @"paymentInfo" : @{@"index": @(index), @"type": @"card"}} jsonData]]; - [self.service executeGenericRequest:request successHandler:self.successCallback errorHandler:self.failureCallback]; -} - -- (NSMutableURLRequest *)chargeRequestWithEndpoint:(NSString *)endpoint cart:(id)cart paymentInfo:(CMCardPayment *)paymentInfo descriptors:(NSArray *)descriptors; -{ - NSDictionary *paymentSerialized = [CMObjectEncoder encodeObjects:@[paymentInfo]]; - - __block NSDictionary *actualPayment = nil; - - [paymentSerialized enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { - actualPayment = @{@"token": obj[@"token"], @"expiration" : obj[@"expirationDate"]}; - }]; - - NSURL *url = [self.service constructAppURLWithString:[NSString stringWithFormat:@"payments/transaction/%@", endpoint] andDescriptors:descriptors]; - NSMutableURLRequest *request = [self.service constructHTTPRequestWithVerb:@"POST" URL:url binaryData:NO user:_user]; - [request setHTTPBody:[@{@"cart" : cart, @"paymentInfo" : actualPayment} jsonData]]; - return request; -} - - - -@end diff --git a/ios/iosTests/CMPaymentServiceSpec.m b/ios/iosTests/CMPaymentServiceSpec.m deleted file mode 100644 index 45fcd21f..00000000 --- a/ios/iosTests/CMPaymentServiceSpec.m +++ /dev/null @@ -1,121 +0,0 @@ -// -// CMPaymentServiceSpec.m -// cloudmine-ios -// -// Created by Ethan Mick on 6/13/14. -// Copyright (c) 2016 CloudMine, Inc. All rights reserved. -// - -#import "Kiwi.h" -#import "CMPaymentService.h" -#import "CMUser.h" -#import "CMCardPayment.h" -#import "CMWebService.h" - -SPEC_BEGIN(CMPaymentServiceSpec) - -describe(@"CMPaymentService", ^{ - - context(@"without a user", ^{ - - __block CMPaymentService *paymentService = nil; - beforeEach(^{ - paymentService = [[CMPaymentService alloc] init]; - }); - - it(@"should initialize a transaction", ^{ - - CMCardPayment *card = [[CMCardPayment alloc] init]; - card.nameOnCard = @"Ethan Smith"; - card.token = @"3243249390328409"; - card.expirationDate = @"0919"; - card.last4Digits = @"1111"; - card.type = CMCardPaymentTypeVisa; - - KWCaptureSpy *callbackBlockSpy = [[paymentService valueForKey:@"service"] - captureArgument:@selector(executeGenericRequest:successHandler:errorHandler:) atIndex:1]; - [[[paymentService valueForKey:@"service"] should] receive:@selector(executeGenericRequest:successHandler:errorHandler:) withCount:1]; - - [paymentService initializeTransactionWithCart:@{@"something": @"okay"} - paymentInfo:card - descriptors:nil - callback:^(CMPaymentResponse *response) { - [[theValue([response wasSuccess]) should] beTrue]; - [[theValue(response.result) should] equal:@(CMPaymentResultSuccessful)]; - }]; - - CMWebServiceGenericRequestCallback callback = callbackBlockSpy.argument; - callback(@{@"result":@"success"}, 200, @{}); - }); - - it(@"should return the proper error when the web service fails", ^{ - - KWCaptureSpy *callbackBlockSpy = [[paymentService valueForKey:@"service"] - captureArgument:@selector(executeGenericRequest:successHandler:errorHandler:) atIndex:2]; - [[[paymentService valueForKey:@"service"] should] receive:@selector(executeGenericRequest:successHandler:errorHandler:) withCount:1]; - - CMCardPayment *card = [[CMCardPayment alloc] init]; - card.nameOnCard = @"Ethan Smith"; - card.token = @"3243249390328409"; - card.expirationDate = @"0919"; - card.last4Digits = @"1111"; - card.type = CMCardPaymentTypeVisa; - - // This first call should trigger the web service call. - [paymentService initializeTransactionWithCart:@{@"something": @"okay"} - paymentInfo:card - descriptors:nil - callback:^(CMPaymentResponse *response) { - [[theValue([response wasSuccess]) should] beFalse]; - [[theValue(response.result) should] equal:@(CMPaymentResultFailed)]; - }]; - - CMWebServiceErorCallack callback = callbackBlockSpy.argument; - callback(@{@"Error": @"error message"}, 400, @{}, [NSError new], @{}); - }); - - it(@"should fulfill a transcaction", ^{ - KWCaptureSpy *callbackBlockSpy = [[paymentService valueForKey:@"service"] - captureArgument:@selector(executeGenericRequest:successHandler:errorHandler:) atIndex:1]; - [[[paymentService valueForKey:@"service"] should] receive:@selector(executeGenericRequest:successHandler:errorHandler:) withCount:1]; - - [paymentService fulfillTransactionWithID:@"transaction_id" - descriptors:nil - callback:^(CMPaymentResponse *response) { - [[theValue([response wasSuccess]) should] beTrue]; - [[theValue(response.result) should] equal:@(CMPaymentResultSuccessful)]; - }]; - - CMWebServiceGenericRequestCallback callback = callbackBlockSpy.argument; - callback(@{@"fulfilled":@"yes"}, 200, @{}); - }); - - it(@"charge the card at the index", ^{ - KWCaptureSpy *callbackBlockSpy = [[paymentService valueForKey:@"service"] - captureArgument:@selector(executeGenericRequest:successHandler:errorHandler:) atIndex:1]; - [[[paymentService valueForKey:@"service"] should] receive:@selector(executeGenericRequest:successHandler:errorHandler:) withCount:1]; - - [paymentService chargeCardAtIndex:0 cart:@{@"something": @"inmycart"} callback:^(CMPaymentResponse *response) { - [[theValue([response wasSuccess]) should] beTrue]; - [[theValue(response.result) should] equal:@(CMPaymentResultSuccessful)]; - }]; - - CMWebServiceGenericRequestCallback callback = callbackBlockSpy.argument; - callback(@{@"done":@"yes"}, 200, @{}); - }); - }); - - - context(@"with a user", ^{ - - __block CMPaymentService *paymentService = nil; - beforeEach(^{ - CMUser *user = [[CMUser alloc] initWithEmail:@"test_payment_service@cloudmine.me" andPassword:@"testing"]; - paymentService = [[CMPaymentService alloc] initWithUser:user]; - }); - }); - -}); - -SPEC_END - diff --git a/ios/iosTests/CMUserIntegrationSpec.m b/ios/iosTests/CMUserIntegrationSpec.m index 269c3b80..a6ade6cf 100644 --- a/ios/iosTests/CMUserIntegrationSpec.m +++ b/ios/iosTests/CMUserIntegrationSpec.m @@ -9,11 +9,13 @@ #import "Kiwi.h" #import "CMAPICredentials.h" #import "CMUser.h" -#import "CMCardPayment.h" #import "CMWebService.h" #import "CMConstants.h" #import "TestUser.h" #import "CMUserResponse.h" +#import "CMObjectFetchResponse.h" +#import "CMPagingDescriptor.h" +#import "CMStoreOptions.h" #import "CMTestMacros.h" SPEC_BEGIN(CMUserIntegrationSpec) @@ -397,88 +399,6 @@ [[expectFutureValue(mes) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveLengthOf:1]; }); }); - - context(@"given some payment info", ^{ - - __block CMUser *cardUser = nil; - __block CMCardPayment *card = nil; - __block NSString *cardId = nil; - beforeAll(^{ - card = [[CMCardPayment alloc] init]; - card.nameOnCard = @"Ethan Smith"; - card.token = @"3243249390328409"; - card.expirationDate = @"0916"; - card.last4Digits = @"1111"; - card.type = CMCardPaymentTypeVisa; - cardId = card.objectId; - - __block CMUserAccountResult code = NSNotFound; - __block NSArray *mes = nil; - - CMUser *user = [[CMUser alloc] initWithEmail:@"testcard@cloudmine.me" andPassword:@"testing"]; - - [user createAccountAndLoginWithCallback:^(CMUserAccountResult resultCode, NSArray *messages) { - code = resultCode; - mes = messages; - cardUser = user; - }]; - - [[expectFutureValue(theValue(code)) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:theValue(CMUserAccountLoginSucceeded)]; - [[expectFutureValue(mes) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beEmpty]; - }); - - it(@"should add a card", ^{ - __block CMPaymentResponse *res = nil; - [cardUser addPaymentMethod:card callback:^(CMPaymentResponse *response) { - res = response; - }]; - - [[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil]; - [[expectFutureValue(@(res.result)) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@(CMPaymentResultSuccessful)]; - [[expectFutureValue(@(res.httpResponseCode)) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@(200)]; - [[expectFutureValue(res.errors) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beEmpty]; - [[expectFutureValue(res.body[@"added"]) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@(0)]; - }); - - it(@"should fetch the payment methods", ^{ - __block CMPaymentResponse *res = nil; - [cardUser paymentMethods:^(CMPaymentResponse *response) { - res = response; - }]; - [[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil]; - [[expectFutureValue(@(res.result)) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@(CMPaymentResultSuccessful)]; - [[expectFutureValue(@(res.httpResponseCode)) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@(200)]; - [[expectFutureValue(res.errors) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beEmpty]; - [[expectFutureValue(res.body) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:1]; - - [[expectFutureValue(((CMCardPayment *)res.body[0]).token) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@"3243249390328409"]; - }); - - it(@"should let you remove a payment method", ^{ - __block CMPaymentResponse *res = nil; - [cardUser removePaymentMethodAtIndex:0 callback:^(CMPaymentResponse *response) { - res = response; - }]; - [[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil]; - [[expectFutureValue(@(res.result)) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@(CMPaymentResultSuccessful)]; - [[expectFutureValue(@([res wasSuccess])) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@(YES)]; - [[expectFutureValue(res.errors) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beEmpty]; - [[expectFutureValue(res.body) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:1]; - }); - - it(@"fetching payment methods again should return nothing", ^{ - __block CMPaymentResponse *res = nil; - [cardUser paymentMethods:^(CMPaymentResponse *response) { - res = response; - }]; - [[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil]; - [[expectFutureValue(@(res.result)) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@(CMPaymentResultSuccessful)]; - [[expectFutureValue(@(res.httpResponseCode)) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@(200)]; - [[expectFutureValue(res.errors) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beEmpty]; - [[expectFutureValue(res.body) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:0]; - }); - - }); }); context(@"searching for users", ^{ @@ -499,7 +419,7 @@ }]; [[expectFutureValue(all) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil]; - [[expectFutureValue(all) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:10]; + [[expectFutureValue(all) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:9]; [[expectFutureValue(error) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beEmpty]; }); @@ -514,7 +434,7 @@ }]; [[expectFutureValue(all) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil]; - [[expectFutureValue(all) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:10]; + [[expectFutureValue(all) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:9]; [[expectFutureValue(error) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNil]; }); @@ -528,7 +448,7 @@ [CMUser allUserWithOptions:options callback:^(CMObjectFetchResponse *response) { all = response.objects; error = response.error; - [[theValue(response.count) should] equal:theValue(10)]; + [[theValue(response.count) should] equal:theValue(9)]; }]; [[expectFutureValue(all) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil]; @@ -541,7 +461,7 @@ __block NSArray *all = nil; __block NSDictionary *error = nil; - [CMUser searchUsers:@"[email=\"testcard@cloudmine.me\"]" callback:^(NSArray *users, NSDictionary *errors) { + [CMUser searchUsers:@"[email=\"testsubclassuser@cloudmine.me\"]" callback:^(NSArray *users, NSDictionary *errors) { all = users; error = errors; [[all should] haveCountOf:1]; @@ -554,7 +474,7 @@ [[expectFutureValue(all) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil]; [[expectFutureValue(all) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:1]; [[expectFutureValue(error) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beEmpty]; - [[expectFutureValue(((CMUser *)all[0]).email) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@"testcard@cloudmine.me"]; + [[expectFutureValue(((CMUser *)all[0]).email) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@"testsubclassuser@cloudmine.me"]; }); identifier = nil; @@ -562,7 +482,7 @@ __block NSArray *all = nil; __block NSError *error = nil; - [CMUser searchUsers:@"[email=\"testcard@cloudmine.me\"]" options:nil callback:^(CMObjectFetchResponse *response) { + [CMUser searchUsers:@"[email=\"testsubclassuser@cloudmine.me\"]" options:nil callback:^(CMObjectFetchResponse *response) { all = response.objects; error = response.error; [[all should] haveCountOf:1]; @@ -575,7 +495,7 @@ [[expectFutureValue(all) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil]; [[expectFutureValue(all) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:1]; [[expectFutureValue(error) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNil]; - [[expectFutureValue(((CMUser *)all[0]).email) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@"testcard@cloudmine.me"]; + [[expectFutureValue(((CMUser *)all[0]).email) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@"testsubclassuser@cloudmine.me"]; }); @@ -590,7 +510,7 @@ error = errors; if (all.count > 0) { CMUser *found = all[0]; - [[found.email should] equal:@"testcard@cloudmine.me"]; + [[found.email should] equal:@"testsubclassuser@cloudmine.me"]; } else { fail(@"Fail!"); } diff --git a/ios/iosTests/CMUserSpec.m b/ios/iosTests/CMUserSpec.m index 75f799d1..190b5c66 100644 --- a/ios/iosTests/CMUserSpec.m +++ b/ios/iosTests/CMUserSpec.m @@ -12,7 +12,6 @@ #import "CMAPICredentials.h" #import "CMObjectEncoder.h" #import "CMObjectDecoder.h" -#import "CMCardPayment.h" #import "CMUserAccountResult.h" #import "CMUserResponse.h" @@ -321,57 +320,6 @@ -(id) initWithCoder:(NSCoder *)aDecoder { callback(@{@"Error": @"error message"}, 400, @{}, [NSError new], @{}); }); - it(@"should return the correct failure when getting payment fails", ^{ - - KWCaptureSpy *callbackBlockSpy = [[user valueForKey:@"webService"] - captureArgument:@selector(executeGenericRequest:successHandler:errorHandler:) atIndex:2]; - [[[user valueForKey:@"webService"] should] receive:@selector(executeGenericRequest:successHandler:errorHandler:) withCount:1]; - - // This first call should trigger the web service call. - - [user paymentMethods:^(CMPaymentResponse *response) { - [[@([response wasSuccess]) should] equal:@NO]; - [[@(response.result) should] equal:@(CMPaymentResultFailed)]; - }]; - - CMWebServiceErorCallack callback = callbackBlockSpy.argument; - callback(@{@"Error": @"error message"}, 400, @{}, [NSError new], @{}); - }); - - it(@"should return the correct failure when removing payment fails", ^{ - - KWCaptureSpy *callbackBlockSpy = [[user valueForKey:@"webService"] - captureArgument:@selector(executeGenericRequest:successHandler:errorHandler:) atIndex:2]; - [[[user valueForKey:@"webService"] should] receive:@selector(executeGenericRequest:successHandler:errorHandler:) withCount:1]; - - // This first call should trigger the web service call. - - [user removePaymentMethodAtIndex:0 callback:^(CMPaymentResponse *response) { - [[@([response wasSuccess]) should] equal:@NO]; - [[@(response.result) should] equal:@(CMPaymentResultFailed)]; - }]; - - CMWebServiceErorCallack callback = callbackBlockSpy.argument; - callback(@{@"Error": @"error message"}, 400, @{}, [NSError new], @{}); - }); - - it(@"should return the correct failure when adding payment fails", ^{ - - KWCaptureSpy *callbackBlockSpy = [[user valueForKey:@"webService"] - captureArgument:@selector(executeGenericRequest:successHandler:errorHandler:) atIndex:2]; - [[[user valueForKey:@"webService"] should] receive:@selector(executeGenericRequest:successHandler:errorHandler:) withCount:1]; - - // This first call should trigger the web service call. - - [user addPaymentMethod:[CMCardPayment new] callback:^(CMPaymentResponse *response) { - [[@([response wasSuccess]) should] equal:@NO]; - [[@(response.result) should] equal:@(CMPaymentResultFailed)]; - }]; - - CMWebServiceErorCallack callback = callbackBlockSpy.argument; - callback(@{@"Error": @"error message"}, 400, @{}, [NSError new], @{}); - }); - context(@"when accessing other users of the app", ^{ beforeEach(^{ [user setValue:@"abc123" forKey:@"objectId"]; From ebe39935bfdeaaf219a5e403714c9662d98d8df3 Mon Sep 17 00:00:00 2001 From: Ben DiFrancesco Date: Tue, 6 Jun 2017 13:08:59 -0700 Subject: [PATCH 2/3] Prevent the decode from (interally) raising errors when it encounters nested non-CMObject types --- ios/ios/src/Web Services/Decoding/CMObjectDecoder.m | 6 ++---- ios/iosTests/CMObjectDecoderSpec.m | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/ios/ios/src/Web Services/Decoding/CMObjectDecoder.m b/ios/ios/src/Web Services/Decoding/CMObjectDecoder.m index ae3199f9..db44d353 100644 --- a/ios/ios/src/Web Services/Decoding/CMObjectDecoder.m +++ b/ios/ios/src/Web Services/Decoding/CMObjectDecoder.m @@ -66,11 +66,9 @@ + (NSArray *)decodeObjects:(NSDictionary *)serializedObjects { decodedObject = [[klass alloc] initWithCoder:decoder]; } - if (decodedObject) { + if (nil != decodedObject) { if(![decodedObject isKindOfClass:[CMObject class]] && ![decodedObject isKindOfClass:[CMUser class]]) { - [[NSException exceptionWithName:@"CMInternalInconsistencyException" reason:[NSString stringWithFormat:@"Can only deserialize top-level objects that inherit from CMObject. Got %@.", NSStringFromClass([decodedObject class])] userInfo:nil] raise]; - - return nil; + return @[]; } // Add it to the final array of inflated objects. diff --git a/ios/iosTests/CMObjectDecoderSpec.m b/ios/iosTests/CMObjectDecoderSpec.m index 725dc32b..07bfb8f7 100644 --- a/ios/iosTests/CMObjectDecoderSpec.m +++ b/ios/iosTests/CMObjectDecoderSpec.m @@ -273,9 +273,9 @@ it(@"should NOT be able to deserialize a dictionary when it's at the top-level", ^{ NSDictionary *dictionary = @{@"1234": @{@"__id__": @"1234", @"__class__" : @"map", @"name": @"foo"}}; - [[theBlock(^{ - [CMObjectDecoder decodeObjects:dictionary]; - }) should] raiseWithName:@"CMInternalInconsistencyException"]; + + NSArray *decodedObjects = [CMObjectDecoder decodeObjects:dictionary]; + [[[decodedObjects should] have:0] items]; }); it(@"should decode multiple objects properly when some of them don't have __id__ fields but do have __class__ fields", ^{ From 4425edb181328d632b5419615f5184f58876f47e Mon Sep 17 00:00:00 2001 From: Ben DiFrancesco Date: Tue, 6 Jun 2017 13:16:48 -0700 Subject: [PATCH 3/3] Prep for 1.7.17 Release * Bump Pod version to 1.7.17 * Update CHANGELOG to reflect changes made --- CHANGELOG.md | 6 ++++++ ios/cloudmine-ios.xcodeproj/project.pbxproj | 6 +++--- ios/ios/src/CMConstants.h | 2 +- ios/iosTests/cloudmine-iosTests-Info.plist | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ae287e7..00b96145 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +1.7.17 (August 31, 2017) +===================== + * Removes the legacy payments API, which was recently removed from the CloudMine platform + * Prevents the SDK from throwing-then-catching internal errors when decoding non-CMObject + nested types. This should make breakpoint debugging easier for developers using the SDK. + 1.7.16 (July 20, 2017) ===================== Adds CMFileMetadata class, a first-class object for interacting with metadata diff --git a/ios/cloudmine-ios.xcodeproj/project.pbxproj b/ios/cloudmine-ios.xcodeproj/project.pbxproj index 97be2407..8b1d2ffa 100644 --- a/ios/cloudmine-ios.xcodeproj/project.pbxproj +++ b/ios/cloudmine-ios.xcodeproj/project.pbxproj @@ -1398,7 +1398,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = EE1B44A5F6B4AA8E61850EFA /* Pods-cloudmine-ios.debug.xcconfig */; buildSettings = { - CURRENT_PROJECT_VERSION = 1.7.16; + CURRENT_PROJECT_VERSION = 1.7.17; DSTROOT = /tmp/ios.dst; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_GENERATE_TEST_COVERAGE_FILES = YES; @@ -1426,7 +1426,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = B2A33E73BEDE10A94973E9FE /* Pods-cloudmine-ios.release.xcconfig */; buildSettings = { - CURRENT_PROJECT_VERSION = 1.7.16; + CURRENT_PROJECT_VERSION = 1.7.17; DSTROOT = /tmp/ios.dst; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO; @@ -1552,7 +1552,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = C3444874F77B35F0544725D1 /* Pods-cloudmine-ios.test.xcconfig */; buildSettings = { - CURRENT_PROJECT_VERSION = 1.7.16; + CURRENT_PROJECT_VERSION = 1.7.17; DSTROOT = /tmp/ios.dst; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_GENERATE_TEST_COVERAGE_FILES = YES; diff --git a/ios/ios/src/CMConstants.h b/ios/ios/src/CMConstants.h index 59e62ab1..74874dd3 100644 --- a/ios/ios/src/CMConstants.h +++ b/ios/ios/src/CMConstants.h @@ -16,6 +16,6 @@ #define CM_DEFAULT_API_VERSION @"v1" -#define CM_VERSION @"1.7.16" +#define CM_VERSION @"1.7.17" #endif diff --git a/ios/iosTests/cloudmine-iosTests-Info.plist b/ios/iosTests/cloudmine-iosTests-Info.plist index 32c11c2d..b74945bb 100644 --- a/ios/iosTests/cloudmine-iosTests-Info.plist +++ b/ios/iosTests/cloudmine-iosTests-Info.plist @@ -17,6 +17,6 @@ CFBundleSignature ???? CFBundleVersion - 1.7.16 + 1.7.17