forked from kylebrowning/waterwheel.swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DIOSComment.m
52 lines (43 loc) · 2.61 KB
/
DIOSComment.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// DIOSComment.m
// dios
//
// Created by Kyle Browning on 9/5/14.
// Copyright (c) 2014 Kyle Browning. All rights reserved.
//
#import "DIOSComment.h"
#import "DIOSEntity.h"
#import "DIOSSession.h"
@implementation DIOSComment
+ (void) getCommentWithID:(NSString*)eid
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {
[DIOSEntity getEntityWithName:@"comment" andID:eid success:success failure:failure];
}
+ (void) createCommentWithParams:(NSDictionary*)params
relationID:(NSString*)relationID
type:(NSString*)type
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {
NSMutableDictionary *dict = [NSMutableDictionary new];
NSString *href = [NSString stringWithFormat:@"%@/rest/type/%@/%@", [[[DIOSSession sharedSession] baseURL] absoluteString], @"comment", type];
NSString *relationKey = [NSString stringWithFormat:@"%@/rest/relation/comment/comment/entity_id", [[[DIOSSession sharedSession] baseURL] absoluteString]];
NSString *relationValue = [NSString stringWithFormat:@"%@/node/%@",[[[DIOSSession sharedSession] baseURL] absoluteString],relationID];
NSDictionary *defaultDict = @{@"_links" : @{@"type" : @{@"href" : href}, relationKey:@[@{@"href" :relationValue}]}, @"entity_id":@[@{@"target_id":relationID,@"revision_id":@""}]};
[dict addEntriesFromDictionary:defaultDict];
[dict addEntriesFromDictionary:params];
NSString *path = [NSString stringWithFormat:@"entity/comment"];
[[DIOSSession sharedSession] sendRequestWithPath:path method:@"POST" params:dict success:success failure:failure];
}
+ (void) deleteCommentWithID:(NSString*)eid
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {
[DIOSEntity deleteEntityWithEntityName:@"comment" andID:eid success:success failure:failure];
}
+ (void) patchCommentWithID:(NSString*)eid
andParams:(NSDictionary *)params
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {
[DIOSEntity patchEntityWithEntityName:@"comment" type:@"comment" eid:eid andParams:params success:nil failure:nil];
}
@end