Skip to content
This repository has been archived by the owner on Feb 17, 2018. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:skylarsch/SSPostmark
Browse files Browse the repository at this point in the history
  • Loading branch information
Skylar Schipper committed Dec 22, 2012
2 parents 69ee790 + 6e3b3f0 commit 5e1a12f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 17 deletions.
7 changes: 0 additions & 7 deletions SSPostmark/SSPostmark.h
Expand Up @@ -59,13 +59,6 @@
*/
- (BOOL)sendMessage:(SSPostmarkMessage *)message;

/** <#Description#>
<#Discussion#>
*/
- (BOOL)sendMessage:(SSPostmarkMessage *)message completionHandler:(void (^)(void))completionHandler;

/** <#Description#>
<#Discussion#>
Expand Down
11 changes: 5 additions & 6 deletions SSPostmark/SSPostmark.m
Expand Up @@ -37,10 +37,7 @@ @implementation SSPostmark
#pragma mark -
#pragma mark - Sending Postmark Messages
- (BOOL)sendMessage:(SSPostmarkMessage *)message {
return [self ss_SendMessage:message completionHandler:nil];
}
- (BOOL)sendMessage:(SSPostmarkMessage *)message completionHandler:(void (^)(void))completionHandler {
return [self ss_SendMessage:message completionHandler:completionHandler];
return [self ss_SendMessage:message];
}


Expand Down Expand Up @@ -76,7 +73,7 @@ + (NSURL *)postmarkBatchAPIURL {

#pragma mark -
#pragma mark - Private helper methods
- (BOOL)ss_SendMessage:(SSPostmarkMessage *)message completionHandler:(void (^)(void))completionHandler {
- (BOOL)ss_SendMessage:(SSPostmarkMessage *)message {
if (![message isValid]) {
return NO;
}
Expand All @@ -99,7 +96,9 @@ - (BOOL)ss_SendMessage:(SSPostmarkMessage *)message completionHandler:(void (^)(
if (JSONError != nil) {
return;
}
NSLog(@"(%i) :: %@",response.statusCode,JSON);
if (message.completion) {
message.completion(message, response.statusCode, JSON);
}
}];
return YES;
}
Expand Down
18 changes: 17 additions & 1 deletion SSPostmark/SSPostmarkMessage.h
Expand Up @@ -40,7 +40,9 @@ NSString static const *kSSPostmarkHeaders = @"Headers";
NSString static const *kSSPostmarkAttachments = @"Attachments";


@class SSPostmarkAttachment;
@class SSPostmarkAttachment, SSPostmarkMessage;

typedef void (^SSPostmarkMessageCompletion)(SSPostmarkMessage *message, NSUInteger statusCode, NSDictionary *responseJSON);

/** <#Description#>
Expand Down Expand Up @@ -171,4 +173,18 @@ NSString static const *kSSPostmarkAttachments = @"Attachments";
*/
@property (nonatomic, readonly, getter = isValid) BOOL valid;

#pragma mark -

/** <#Description#>
<#Discussion#>
*/
@property (nonatomic, copy) SSPostmarkMessageCompletion completion;

/** <#Description#>
<#Discussion#>
*/
- (void)addCompletionBlock:(SSPostmarkMessageCompletion)completion;

@end
7 changes: 7 additions & 0 deletions SSPostmark/SSPostmarkMessage.m
Expand Up @@ -96,4 +96,11 @@ - (void)removeAttachments:(NSSet *)objects {
}
}


#pragma mark -
#pragma mark -
- (void)addCompletionBlock:(SSPostmarkMessageCompletion)completion {
_completion = completion;
}

@end
6 changes: 3 additions & 3 deletions SSPostmarkTestApp/SSTAAppDelegate.m
Expand Up @@ -19,16 +19,16 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];


NSLog(@"SSPostmark Version: '%@'",[SSPostmark version]);

SSPostmarkMessage *message = [SSPostmarkMessage new];
message.fromEmail = @"ss@schipp.co";
message.replyTo = @"ss@schipp.co";
message.to = @"ss@schipp.co";
message.textBody = @"Test Email";
message.subject = @"Just a test";
message.tag = @"sspm-test";
[message addCompletionBlock:^(SSPostmarkMessage *message, NSUInteger statusCode, NSDictionary *responseJSON) {
NSLog(@"(%i)\n%@",statusCode,responseJSON);
}];

SSPostmarkAttachment *att = [[SSPostmarkAttachment alloc] init];
att.content = UIImagePNGRepresentation([UIImage imageNamed:@"sunset.jpg"]);
Expand Down

0 comments on commit 5e1a12f

Please sign in to comment.