-
-
Save frontendloader/fb7673e6723c900f6de3a81162861f38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef CustomSyncUpTarget_h | |
#define CustomSyncUpTarget_h | |
#import "SFSyncUpTarget.h" | |
@interface CustomSyncUpTarget : SFSyncUpTarget | |
@end | |
#endif /* CustomSyncUpTarget_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import "SFSyncUpTarget.h" | |
#import "CustomSyncUpTarget.h" | |
#import "SFSmartSyncConstants.h" | |
#import "SFSmartSyncObjectUtils.h" | |
#import "SFSmartSyncSoqlBuilder.h" | |
#import "SFSmartSyncNetworkUtils.h" | |
#import "SFSmartSyncSyncManager.h" | |
#import <SalesforceRestAPI/SFRestAPI+Blocks.h> | |
#import <SalesforceRestAPI/SFRestRequest.h> | |
#import <SalesforceSDKCore/SFJsonUtils.h> | |
#import <SmartStore/SFSmartStore.h> | |
#import "SFLogger.h" | |
NSString * const kOpportunityLineItem = @"OpportunityLineItem"; | |
NSString * const kOpportunityMDField = @"OpportunityId"; | |
@implementation CustomSyncUpTarget : SFSyncUpTarget | |
- (instancetype)initWithDict:(NSDictionary *)dict { | |
self = [super initWithDict:dict]; | |
if (self) { | |
self.targetType = SFSyncUpTargetTypeCustom; | |
} | |
return self; | |
} | |
- (instancetype)init { | |
self = [super init]; | |
if (self) { | |
self.targetType = SFSyncUpTargetTypeCustom; | |
} | |
return self; | |
} | |
- (void)updateOnServer:(NSString*)objectType | |
objectId:(NSString*)objectId | |
fields:(NSDictionary*)fields | |
completionBlock:(SFSyncUpTargetCompleteBlock)completionBlock | |
failBlock:(SFSyncUpTargetErrorBlock)failBlock | |
{ | |
NSMutableDictionary *fields2 = [fields mutableCopy]; | |
if([objectType isEqualToString:kOpportunityLineItem]) { | |
[fields2 removeObjectForKey:OpportunityMDField]; //master/detail field, no updatin! | |
} | |
[super updateOnServer:objectType objectId:objectId fields:fields2 | |
completionBlock:completionBlock failBlock:failBlock]; | |
} | |
- (NSMutableDictionary *)asDict { | |
NSMutableDictionary *dict = [super asDict]; | |
dict[kSFSyncTargetiOSImplKey] = @"CustomSyncUpTarget"; | |
dict[kSFSyncTargetTypeKey] = [[self class] targetTypeToString:self.targetType]; | |
return dict; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment