Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
alex-hofsteede
committed
May 8, 2014
1 parent
b11869a
commit 06ab609
Showing
7 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// MPABTestDesignerTweakRequestMessage.h | ||
// HelloMixpanel | ||
// | ||
// Created by Alex Hofsteede on 7/5/14. | ||
// Copyright (c) 2014 Mixpanel. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "MPAbstractABTestDesignerMessage.h" | ||
|
||
extern NSString *const MPABTestDesignerTweakRequestMessageType; | ||
|
||
@interface MPABTestDesignerTweakRequestMessage : MPAbstractABTestDesignerMessage | ||
@end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// MPABTestDesignerTweakRequestMessage.h | ||
// HelloMixpanel | ||
// | ||
// Created by Alex Hofsteede on 7/5/14. | ||
// Copyright (c) 2014 Mixpanel. All rights reserved. | ||
// | ||
|
||
#import "MPABTestDesignerTweakRequestMessage.h" | ||
#import "MPABTestDesignerConnection.h" | ||
#import "MPABTestDesignerTweakResponseMessage.h" | ||
|
||
// Facebook Tweaks | ||
#import "FBTweakStore.h" | ||
#import "FBTweakCollection.h" | ||
#import "FBTweakCategory.h" | ||
#import "FBTweak.h" | ||
|
||
NSString *const MPABTestDesignerTweakRequestMessageType = @"tweak_request"; | ||
|
||
@implementation MPABTestDesignerTweakRequestMessage | ||
|
||
+ (instancetype)message | ||
{ | ||
return [[self alloc] initWithType:@"tweak_request"]; | ||
} | ||
|
||
- (NSOperation *)responseCommandWithConnection:(MPABTestDesignerConnection *)connection | ||
{ | ||
__weak MPABTestDesignerConnection *weak_connection = connection; | ||
NSOperation *operation = [NSBlockOperation blockOperationWithBlock:^{ | ||
MPABTestDesignerConnection *conn = weak_connection; | ||
|
||
dispatch_sync(dispatch_get_main_queue(), ^{ | ||
NSArray *tweaks = [self payload][@"tweaks"]; | ||
for (NSDictionary *tweak in tweaks) { | ||
FBTweakStore *store = [FBTweakStore sharedInstance]; | ||
FBTweakCategory *category = [store tweakCategoryWithName:tweak[@"category"]]; | ||
FBTweakCollection *collection = [category tweakCollectionWithName:tweak[@"collection"]]; | ||
FBTweak *fbTweak = [collection tweakWithIdentifier:tweak[@"identifier"]]; | ||
|
||
NSLog(@"%@", tweak[@"value"]); | ||
fbTweak.currentValue = tweak[@"value"]; | ||
} | ||
|
||
}); | ||
|
||
MPABTestDesignerTweakResponseMessage *changeResponseMessage = [MPABTestDesignerTweakResponseMessage message]; | ||
changeResponseMessage.status = @"OK"; | ||
[conn sendMessage:changeResponseMessage]; | ||
}]; | ||
|
||
return operation; | ||
} | ||
|
||
@end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// MPABTestDesignerTweakResponseMessage.h | ||
// HelloMixpanel | ||
// | ||
// Created by Alex Hofsteede on 7/5/14. | ||
// Copyright (c) 2014 Mixpanel. All rights reserved. | ||
// | ||
|
||
#import "MPAbstractABTestDesignerMessage.h" | ||
|
||
@interface MPABTestDesignerTweakResponseMessage : MPAbstractABTestDesignerMessage | ||
|
||
+ (instancetype)message; | ||
|
||
@property (nonatomic, copy) NSString *status; | ||
|
||
@end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// MPABTestDesignerTweakResponseMessage.m | ||
// HelloMixpanel | ||
// | ||
// Created by Alex Hofsteede on 7/5/14. | ||
// Copyright (c) 2014 Mixpanel. All rights reserved. | ||
// | ||
|
||
#import "MPABTestDesignerTweakResponseMessage.h" | ||
|
||
@implementation MPABTestDesignerTweakResponseMessage | ||
|
||
+ (instancetype)message | ||
{ | ||
return [[self alloc] initWithType:@"tweak_response"]; | ||
} | ||
|
||
- (void)setStatus:(NSString *)status | ||
{ | ||
[self setPayloadObject:status forKey:@"status"]; | ||
} | ||
|
||
- (NSString *)status | ||
{ | ||
return [self payloadObjectForKey:@"status"]; | ||
} | ||
|
||
@end |