Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

同城活动 Model #4

Merged
merged 1 commit into from

1 participant

@lincode
Owner

No description provided.

@lincode lincode merged commit e442440 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 16, 2012
  1. @lincode

    添加同城活动 Model

    lincode authored
This page is out of date. Refresh to see the latest.
Showing with 694 additions and 74 deletions.
  1. +52 −8 DoubanAPIEngine/DoubanAPIEngine.xcodeproj/project.pbxproj
  2. +1 −2  DoubanAPIEngine/DoubanAPIEngine/Sources/DOUAPIConfig.m
  3. +5 −1 DoubanAPIEngine/DoubanAPIEngine/Sources/Model/GDataDoubanWrapper/Elements/DoubanLocation.h
  4. +11 −2 DoubanAPIEngine/DoubanAPIEngine/Sources/Model/GDataDoubanWrapper/Elements/DoubanLocation.m
  5. +2 −2 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Community/DOUComment.h
  6. +4 −4 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Community/DOUComment.m
  7. +2 −2 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Community/DOUOnline.h
  8. +4 −4 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Community/DOUOnline.m
  9. +6 −2 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Community/{DOUPeople.h → DOUUser.h}
  10. +22 −3 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Community/{DOUPeople.m → DOUUser.m}
  11. +1 −1  DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/DOUObject+Utils.m
  12. +34 −8 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/DOUObject.m
  13. +56 −0 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Event/DOUEvent.h
  14. +282 −0 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Event/DOUEvent.m
  15. +13 −0 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Event/DOUEventArray.h
  16. +22 −0 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Event/DOUEventArray.m
  17. +19 −0 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Event/DOULoc.h
  18. +85 −0 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Event/DOULoc.m
  19. +13 −0 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Event/DOULocArray.h
  20. +22 −0 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Event/DOULocArray.m
  21. +2 −2 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Photo/DOUAlbum.h
  22. +3 −3 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Photo/DOUAlbum.m
  23. +2 −2 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Photo/DOUPhoto.h
  24. +4 −4 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Photo/DOUPhoto.m
  25. +1 −1  DoubanAPIEngine/DoubanAPIEngine/Sources/Network/DOUHttpRequest.m
  26. +0 −1  DoubanAPIEngine/DoubanAPIEngine/Sources/Network/DOUService.h
  27. +19 −8 DoubanAPIEngine/DoubanAPIEngine/Sources/Network/DOUService.m
  28. +3 −11 DoubanAPIEngine/DoubanAPIEngineTests/DoubanAPIEngineTests.m
  29. +1 −0  DoubanAPIEngine/DoubanAPIEngineTests/Model/DoubanPeopleTests.m
  30. +1 −1  DoubanAPIEngine/DoubanAPIEngineTests/Model2/DOUOnlineTests.m
  31. +1 −1  DoubanAPIEngine/DoubanAPIEngineTests/Model2/DOUPhotoTests.m
  32. +1 −1  DoubanAPIEngine/DoubanAPIEngineTests/Resources/Model/DoubanEntryEvent.xml
View
60 DoubanAPIEngine/DoubanAPIEngine.xcodeproj/project.pbxproj
@@ -280,8 +280,6 @@
D87D4C7E15C3F14E0006FAFE /* DOUComment.m in Sources */ = {isa = PBXBuildFile; fileRef = D87D4C7815C3F14E0006FAFE /* DOUComment.m */; };
D87D4C7F15C3F14E0006FAFE /* DOUCommentArray.h in Headers */ = {isa = PBXBuildFile; fileRef = D87D4C7915C3F14E0006FAFE /* DOUCommentArray.h */; };
D87D4C8015C3F14E0006FAFE /* DOUCommentArray.m in Sources */ = {isa = PBXBuildFile; fileRef = D87D4C7A15C3F14E0006FAFE /* DOUCommentArray.m */; };
- D87D4C8115C3F14E0006FAFE /* DOUPeople.h in Headers */ = {isa = PBXBuildFile; fileRef = D87D4C7B15C3F14E0006FAFE /* DOUPeople.h */; };
- D87D4C8215C3F14E0006FAFE /* DOUPeople.m in Sources */ = {isa = PBXBuildFile; fileRef = D87D4C7C15C3F14E0006FAFE /* DOUPeople.m */; };
D87D4C8D15C3F2A70006FAFE /* DoubanCityTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D87D4C8515C3F2A70006FAFE /* DoubanCityTests.m */; };
D87D4C8E15C3F2A70006FAFE /* DoubanCommentTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D87D4C8615C3F2A70006FAFE /* DoubanCommentTests.m */; };
D87D4C8F15C3F2A70006FAFE /* DoubanEventCategoryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D87D4C8715C3F2A70006FAFE /* DoubanEventCategoryTests.m */; };
@@ -324,6 +322,17 @@
D88EAEFD14691D0800A4DE43 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D88EAEFC14691D0800A4DE43 /* CoreGraphics.framework */; };
D88EAEFE14691D2F00A4DE43 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D800D71F14690D32009F64FD /* Security.framework */; };
D88EAEFF14691D5B00A4DE43 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D88EAEFC14691D0800A4DE43 /* CoreGraphics.framework */; };
+ D89A2A5615ECA3360027C0B0 /* Event.json in Resources */ = {isa = PBXBuildFile; fileRef = D89A2A5515ECA3360027C0B0 /* Event.json */; };
+ D89A6A96162D37EE00954BC4 /* DOUUser.h in Headers */ = {isa = PBXBuildFile; fileRef = D89A6A94162D37EE00954BC4 /* DOUUser.h */; };
+ D89A6A97162D37EE00954BC4 /* DOUUser.m in Sources */ = {isa = PBXBuildFile; fileRef = D89A6A95162D37EE00954BC4 /* DOUUser.m */; };
+ D89A6AA1162D384100954BC4 /* DOUEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = D89A6A99162D384100954BC4 /* DOUEvent.h */; };
+ D89A6AA2162D384100954BC4 /* DOUEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = D89A6A9A162D384100954BC4 /* DOUEvent.m */; };
+ D89A6AA3162D384100954BC4 /* DOUEventArray.h in Headers */ = {isa = PBXBuildFile; fileRef = D89A6A9B162D384100954BC4 /* DOUEventArray.h */; };
+ D89A6AA4162D384100954BC4 /* DOUEventArray.m in Sources */ = {isa = PBXBuildFile; fileRef = D89A6A9C162D384100954BC4 /* DOUEventArray.m */; };
+ D89A6AA5162D384100954BC4 /* DOULoc.h in Headers */ = {isa = PBXBuildFile; fileRef = D89A6A9D162D384100954BC4 /* DOULoc.h */; };
+ D89A6AA6162D384100954BC4 /* DOULoc.m in Sources */ = {isa = PBXBuildFile; fileRef = D89A6A9E162D384100954BC4 /* DOULoc.m */; };
+ D89A6AA7162D384100954BC4 /* DOULocArray.h in Headers */ = {isa = PBXBuildFile; fileRef = D89A6A9F162D384100954BC4 /* DOULocArray.h */; };
+ D89A6AA8162D384100954BC4 /* DOULocArray.m in Sources */ = {isa = PBXBuildFile; fileRef = D89A6AA0162D384100954BC4 /* DOULocArray.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -606,8 +615,6 @@
D87D4C7815C3F14E0006FAFE /* DOUComment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DOUComment.m; sourceTree = "<group>"; };
D87D4C7915C3F14E0006FAFE /* DOUCommentArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOUCommentArray.h; sourceTree = "<group>"; };
D87D4C7A15C3F14E0006FAFE /* DOUCommentArray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DOUCommentArray.m; sourceTree = "<group>"; };
- D87D4C7B15C3F14E0006FAFE /* DOUPeople.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOUPeople.h; sourceTree = "<group>"; };
- D87D4C7C15C3F14E0006FAFE /* DOUPeople.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DOUPeople.m; sourceTree = "<group>"; };
D87D4C8515C3F2A70006FAFE /* DoubanCityTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DoubanCityTests.m; sourceTree = "<group>"; };
D87D4C8615C3F2A70006FAFE /* DoubanCommentTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DoubanCommentTests.m; sourceTree = "<group>"; };
D87D4C8715C3F2A70006FAFE /* DoubanEventCategoryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DoubanEventCategoryTests.m; sourceTree = "<group>"; };
@@ -649,6 +656,17 @@
D882161715889DDE004B4AD4 /* DOUTestResponseLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOUTestResponseLoader.h; sourceTree = "<group>"; };
D882161815889DDE004B4AD4 /* DOUTestResponseLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DOUTestResponseLoader.m; sourceTree = "<group>"; };
D88EAEFC14691D0800A4DE43 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+ D89A2A5515ECA3360027C0B0 /* Event.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Event.json; sourceTree = "<group>"; };
+ D89A6A94162D37EE00954BC4 /* DOUUser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOUUser.h; sourceTree = "<group>"; };
+ D89A6A95162D37EE00954BC4 /* DOUUser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DOUUser.m; sourceTree = "<group>"; };
+ D89A6A99162D384100954BC4 /* DOUEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOUEvent.h; sourceTree = "<group>"; };
+ D89A6A9A162D384100954BC4 /* DOUEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DOUEvent.m; sourceTree = "<group>"; };
+ D89A6A9B162D384100954BC4 /* DOUEventArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOUEventArray.h; sourceTree = "<group>"; };
+ D89A6A9C162D384100954BC4 /* DOUEventArray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DOUEventArray.m; sourceTree = "<group>"; };
+ D89A6A9D162D384100954BC4 /* DOULoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOULoc.h; sourceTree = "<group>"; };
+ D89A6A9E162D384100954BC4 /* DOULoc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DOULoc.m; sourceTree = "<group>"; };
+ D89A6A9F162D384100954BC4 /* DOULocArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOULocArray.h; sourceTree = "<group>"; };
+ D89A6AA0162D384100954BC4 /* DOULocArray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DOULocArray.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -957,6 +975,7 @@
D87D4B0315C3EF350006FAFE /* Model2 */ = {
isa = PBXGroup;
children = (
+ D89A6A98162D384100954BC4 /* Event */,
D87D4B3215C3F00C0006FAFE /* Photo */,
D87D4B2915C3EFBF0006FAFE /* Community */,
D87D4B1115C3EF600006FAFE /* DOUObject.h */,
@@ -970,12 +989,12 @@
D87D4B2915C3EFBF0006FAFE /* Community */ = {
isa = PBXGroup;
children = (
+ D89A6A94162D37EE00954BC4 /* DOUUser.h */,
+ D89A6A95162D37EE00954BC4 /* DOUUser.m */,
D87D4C7715C3F14E0006FAFE /* DOUComment.h */,
D87D4C7815C3F14E0006FAFE /* DOUComment.m */,
D87D4C7915C3F14E0006FAFE /* DOUCommentArray.h */,
D87D4C7A15C3F14E0006FAFE /* DOUCommentArray.m */,
- D87D4C7B15C3F14E0006FAFE /* DOUPeople.h */,
- D87D4C7C15C3F14E0006FAFE /* DOUPeople.m */,
D87D4B1315C3EF600006FAFE /* DOUObject+Utils.h */,
D87D4B1415C3EF600006FAFE /* DOUObject+Utils.m */,
D87D4B2A15C3EFE70006FAFE /* DOUOnline.h */,
@@ -1325,6 +1344,7 @@
isa = PBXGroup;
children = (
D87D4CB715C3F5580006FAFE /* Album.json */,
+ D89A2A5515ECA3360027C0B0 /* Event.json */,
D87D4CB815C3F5580006FAFE /* CommentArray.json */,
D87D4CB915C3F5580006FAFE /* Online.json */,
D87D4CBA15C3F5580006FAFE /* OnlineArray.json */,
@@ -1352,6 +1372,21 @@
path = Resources;
sourceTree = "<group>";
};
+ D89A6A98162D384100954BC4 /* Event */ = {
+ isa = PBXGroup;
+ children = (
+ D89A6A99162D384100954BC4 /* DOUEvent.h */,
+ D89A6A9A162D384100954BC4 /* DOUEvent.m */,
+ D89A6A9B162D384100954BC4 /* DOUEventArray.h */,
+ D89A6A9C162D384100954BC4 /* DOUEventArray.m */,
+ D89A6A9D162D384100954BC4 /* DOULoc.h */,
+ D89A6A9E162D384100954BC4 /* DOULoc.m */,
+ D89A6A9F162D384100954BC4 /* DOULocArray.h */,
+ D89A6AA0162D384100954BC4 /* DOULocArray.m */,
+ );
+ path = Event;
+ sourceTree = "<group>";
+ };
D8CFD43C151C742700CCC311 /* Base64 */ = {
isa = PBXGroup;
children = (
@@ -1502,7 +1537,11 @@
D87D4C7515C3F11C0006FAFE /* NSData+Base64.h in Headers */,
D87D4C7D15C3F14E0006FAFE /* DOUComment.h in Headers */,
D87D4C7F15C3F14E0006FAFE /* DOUCommentArray.h in Headers */,
- D87D4C8115C3F14E0006FAFE /* DOUPeople.h in Headers */,
+ D89A6A96162D37EE00954BC4 /* DOUUser.h in Headers */,
+ D89A6AA1162D384100954BC4 /* DOUEvent.h in Headers */,
+ D89A6AA3162D384100954BC4 /* DOUEventArray.h in Headers */,
+ D89A6AA5162D384100954BC4 /* DOULoc.h in Headers */,
+ D89A6AA7162D384100954BC4 /* DOULocArray.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1600,6 +1639,7 @@
D87D4CC015C3F5580006FAFE /* OnlineArray.json in Resources */,
D87D4CC115C3F5580006FAFE /* Photo.json in Resources */,
D87D4CC215C3F5580006FAFE /* PhotoArray.json in Resources */,
+ D89A2A5615ECA3360027C0B0 /* Event.json in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1750,7 +1790,11 @@
D87D4C7615C3F11C0006FAFE /* NSData+Base64.m in Sources */,
D87D4C7E15C3F14E0006FAFE /* DOUComment.m in Sources */,
D87D4C8015C3F14E0006FAFE /* DOUCommentArray.m in Sources */,
- D87D4C8215C3F14E0006FAFE /* DOUPeople.m in Sources */,
+ D89A6A97162D37EE00954BC4 /* DOUUser.m in Sources */,
+ D89A6AA2162D384100954BC4 /* DOUEvent.m in Sources */,
+ D89A6AA4162D384100954BC4 /* DOUEventArray.m in Sources */,
+ D89A6AA6162D384100954BC4 /* DOULoc.m in Sources */,
+ D89A6AA8162D384100954BC4 /* DOULocArray.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
3  DoubanAPIEngine/DoubanAPIEngine/Sources/DOUAPIConfig.m
@@ -11,14 +11,13 @@
//
// Douban parameters:
//
-
+//
NSString * const kHttpsApiBaseUrl = @"https://api.douban.com";
NSString * const kHttpApiBaseUrl = @"http://api.douban.com";
//NSString * const kHttpApiBaseUrl = @"http://loc-zeta.douban.com/service/api";
//NSString * const kHttpsApiBaseUrl = @"https://loc-zeta.douban.com/service/api";
-
NSString * const kAuthUrl = @"https://www.douban.com/service/auth2/auth";
NSString * const kTokenUrl = @"https://www.douban.com/service/auth2/token";
View
6 DoubanAPIEngine/DoubanAPIEngine/Sources/Model/GDataDoubanWrapper/Elements/DoubanLocation.h
@@ -3,7 +3,7 @@
// douban-objective-c
//
// Created by py on 3/19/10.
-// Copyright 2010 __MyCompanyName__. All rights reserved.
+// Copyright 2010 Douban.inc All rights reserved.
//
#import "GDataExtendedProperty.h"
@@ -14,6 +14,10 @@
- (void)setIdentity:(NSString *)str;
+- (NSString *)uid;
+
+- (void)setUid:(NSString *)str;
+
- (NSString *)content;
- (void)setContent:(NSString *)str;
View
13 DoubanAPIEngine/DoubanAPIEngine/Sources/Model/GDataDoubanWrapper/Elements/DoubanLocation.m
@@ -10,7 +10,7 @@
#import "DoubanLocation.h"
static NSString* const kIdentityAttr = @"id";
-static NSString* const kContentAttr = @"content";
+static NSString* const kNIdentifyAttr = @"n_id";
@implementation DoubanLocation
@@ -21,7 +21,7 @@ + (NSString *)extensionElementLocalName { return @"location"; }
- (void)addParseDeclarations {
NSArray *attrs = [NSArray arrayWithObjects:
- kIdentityAttr, kContentAttr, nil];
+ kIdentityAttr, kNIdentifyAttr, nil];
[self addLocalAttributeDeclarations:attrs];
[self addContentValueDeclaration];
@@ -38,6 +38,15 @@ - (void)setIdentity:(NSString *)str {
}
+- (NSString *)uid {
+ return [self stringValueForAttribute:kIdentityAttr];
+}
+
+
+- (void)setUid:(NSString *)str {
+ [self setStringValue:str forAttribute:kIdentityAttr];
+}
+
- (NSString *)content {
return [self contentStringValue];
}
View
4 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Community/DOUComment.h
@@ -8,7 +8,7 @@
#import "DOUObject.h"
-@class DOUPeople;
+@class DOUUser;
@interface DOUComment : DOUObject
@@ -18,6 +18,6 @@
@property (nonatomic, copy) NSString *createTimeStr;
@property (nonatomic, retain) NSDate *createTime;
-@property (nonatomic, retain) DOUPeople *author;
+@property (nonatomic, retain) DOUUser *author;
@end
View
8 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Community/DOUComment.m
@@ -7,7 +7,7 @@
//
#import "DOUComment.h"
-#import "DOUPeople.h"
+#import "DOUUser.h"
#import "DOUObject+Utils.h"
@@ -40,10 +40,10 @@ - (NSDate *)createTime {
}
-- (DOUPeople *)author {
+- (DOUUser *)author {
NSDictionary *dic = [self.dictionary objectForKey:@"author"];
- DOUPeople *people = [DOUPeople objectWithDictionary:dic];
- return people;
+ DOUUser *user = [DOUUser objectWithDictionary:dic];
+ return user;
}
View
4 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Community/DOUOnline.h
@@ -8,7 +8,7 @@
#import "DOUObject.h"
-@class DOUPeople;
+@class DOUUser;
@interface DOUOnline : DOUObject
@property (nonatomic, copy) NSString *identifier;
@@ -45,7 +45,7 @@
@property (nonatomic, copy) NSString *image;
-@property (nonatomic, retain) DOUPeople *owner;
+@property (nonatomic, retain) DOUUser *owner;
@property (nonatomic, assign) BOOL liked;
@property (nonatomic, assign) BOOL participated;
View
8 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Community/DOUOnline.m
@@ -7,7 +7,7 @@
//
#import "DOUOnline.h"
-#import "DOUPeople.h"
+#import "DOUUser.h"
#import "DOUObject+Utils.h"
@@ -166,10 +166,10 @@ - (NSString *)image {
}
-- (DOUPeople *)owner {
+- (DOUUser *)owner {
NSDictionary *dic = [self.dictionary objectForKey:@"owner"];
- DOUPeople *people = [DOUPeople objectWithDictionary:dic];
- return people;
+ DOUUser *user = [DOUUser objectWithDictionary:dic];
+ return user;
}
View
8 ...banAPIEngine/Sources/Model2/Community/DOUPeople.h → ...oubanAPIEngine/Sources/Model2/Community/DOUUser.h
@@ -1,5 +1,5 @@
//
-// DOUPeople.h
+// DOUUser.h
// DoubanApiClient
//
// Created by Lin GUO on 4/25/12.
@@ -8,12 +8,16 @@
#import "DOUObject.h"
-@interface DOUPeople : DOUObject
+@interface DOUUser : DOUObject
@property (nonatomic, copy) NSString *identifier;
@property (nonatomic, copy) NSString *avatar;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *alt;
@property (nonatomic, copy) NSString *uid;
+@property (nonatomic, copy) NSString *desc;
+
+@property (nonatomic, copy) NSString *locId;
+@property (nonatomic, copy) NSString *locName;
@end
View
25 ...banAPIEngine/Sources/Model2/Community/DOUPeople.m → ...oubanAPIEngine/Sources/Model2/Community/DOUUser.m
@@ -1,20 +1,23 @@
//
-// DOUPeople.m
+// DOUUser.m
// DoubanApiClient
//
// Created by Lin GUO on 4/25/12.
// Copyright (c) 2012 Douban Inc. All rights reserved.
//
-#import "DOUPeople.h"
+#import "DOUUser.h"
-@implementation DOUPeople
+@implementation DOUUser
@dynamic identifier;
@dynamic avatar;
@dynamic alt;
@dynamic name;
@dynamic uid;
+@dynamic desc;
+@dynamic locId;
+@dynamic locName;
- (NSString *)identifier {
@@ -41,4 +44,20 @@ - (NSString *)uid {
return [self.dictionary objectForKey:@"uid"];
}
+
+- (NSString *)desc {
+ return [self.dictionary objectForKey:@"desc"];
+}
+
+
+- (NSString *)locId {
+ return [self.dictionary objectForKey:@"loc_id"];
+}
+
+
+- (NSString *)locName {
+ return [self.dictionary objectForKey:@"loc_name"];
+}
+
+
@end
View
2  DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/DOUObject+Utils.m
@@ -12,7 +12,7 @@ @implementation DOUObject (Utils)
+ (NSDate *)dateOfString:(NSString *)dateString {
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
- [dateFormat setDateFormat:@"YYYY-MM-dd HH:mm:SS"];
+ [dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:SS"];
NSDate *date = [dateFormat dateFromString:dateString];
[dateFormat release];
return date;
View
42 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/DOUObject.m
@@ -12,21 +12,32 @@
@implementation DOUObject
-@synthesize string = string_;
+@dynamic string;
@synthesize dictionary = dictionary_;
+- (id)init {
+ self = [super init];
+ if (self) {
+ self.dictionary = [NSMutableDictionary dictionary];
+ }
+ return self;
+}
+
+
- (id)initWithString:(NSString *)theJsonStr {
self = [super init];
if (self) {
if (!theJsonStr || [theJsonStr length] <= 0) {
return nil;
}
+
+ NSMutableDictionary *dic = (NSMutableDictionary *)[theJsonStr JSONValue];
+ if (!dic) {
+ return nil;
+ }
- self.string = theJsonStr;
-
- NSDictionary *dic = (NSDictionary *)[theJsonStr JSONValue];
- self.dictionary = [[[NSMutableDictionary alloc] initWithDictionary:dic] autorelease];
+ self.dictionary = dic;
}
return self;
}
@@ -36,8 +47,6 @@ - (id)initWithDictionary:(NSDictionary *)theDictionary {
self = [super init];
if (self) {
self.dictionary = [[[NSMutableDictionary alloc] initWithDictionary:theDictionary] autorelease];
- NSString *result = [self.dictionary JSONRepresentation];
- self.string = result;
}
return self;
}
@@ -57,10 +66,27 @@ + (id)objectWithDictionary:(NSDictionary *)theDictionary {
- (void)dealloc {
- [string_ release]; string_ = nil;
[dictionary_ release]; dictionary_ = nil;
[super dealloc];
}
+- (NSString *)string {
+ if (self.dictionary) {
+ NSString *result = [self.dictionary JSONRepresentation];
+ return result;
+ }
+ return nil;
+}
+
+
+- (void)setString:(NSString *)theJsonStr {
+ NSMutableDictionary *dic = (NSMutableDictionary *)[theJsonStr JSONValue];
+ if (!dic) {
+ return ;
+ }
+ self.dictionary = dic;
+}
+
+
@end
View
56 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Event/DOUEvent.h
@@ -0,0 +1,56 @@
+//
+// DOUEvent.h
+// DoubanAPIEngine
+//
+// Created by Lin GUO on 4/25/12.
+// Copyright (c) 2012 Douban Inc. All rights reserved.
+//
+
+#import "DOUObject.h"
+
+@class DOUUser;
+@interface DOUEvent : DOUObject
+
+extern NSString * const kParticipatedStatus;
+extern NSString * const kWishedStatus;
+extern NSString * const kArrivedStatus;
+
+@property (nonatomic, copy) NSString *identifier;
+@property (nonatomic, copy) NSString *alt;
+
+@property (nonatomic, copy) NSString *title;
+@property (nonatomic, copy) NSString *content;
+
+@property (nonatomic, copy) NSString *beginTimeStr;
+@property (nonatomic, retain) NSDate *beginTime;
+@property (nonatomic, copy) NSString *endTimeStr;
+@property (nonatomic, retain) NSDate *endTime;
+@property (nonatomic, copy) NSString *category;
+@property (nonatomic, copy) NSString *categoryName;
+
+
+@property (nonatomic, copy) NSString *adaptUrl;
+@property (nonatomic, copy) NSString *locId;
+@property (nonatomic, copy) NSString *locName;
+@property (nonatomic, copy) NSString *address;
+
+@property (nonatomic, copy) NSString *albumId;
+
+@property (nonatomic, assign) NSInteger participantCount;
+@property (nonatomic, assign) NSInteger wisherCount;
+
+@property (nonatomic, copy) NSString *imageMobile;
+@property (nonatomic, copy) NSString *imageLarge;
+@property (nonatomic, copy) NSString *image;
+@property (nonatomic, copy) NSString *icon;
+
+@property (nonatomic, retain) DOUUser *owner;
+
+@property (nonatomic, copy) NSString *participateDateStr;
+@property (nonatomic, retain) NSDate *participateDate;
+@property (nonatomic, copy) NSString *status;
+
+@property (nonatomic, assign) float lat;
+@property (nonatomic, assign) float lng;
+
+@end
View
282 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Event/DOUEvent.m
@@ -0,0 +1,282 @@
+//
+// DOUEvent.m
+// DoubanAPIEngine
+//
+// Created by Lin GUO on 4/25/12.
+// Copyright (c) 2012 Douban Inc. All rights reserved.
+//
+
+#import "DOUEvent.h"
+#import "DOUUser.h"
+#import "DOUObject+Utils.h"
+
+
+@implementation DOUEvent
+
+NSString * const kParticipatedStatus = @"participate";
+NSString * const kWishedStatus = @"wish";
+NSString * const kArrivedStatus = @"arrive";
+
+static NSString * const kEventAllCategory = @"all";
+static NSString * const kEventDramaCategory = @"drama";
+static NSString * const kEventMusicCategory = @"music";
+static NSString * const kEventExhibitionCategory = @"exhibition";
+static NSString * const kEventSportsCategory = @"sports";
+static NSString * const kEventPartyCategory = @"party";
+static NSString * const kEventCommonwealCategory = @"commonweal";
+static NSString * const kEventTravelCategory = @"travel";
+static NSString * const kEventFilmCategory = @"film";
+static NSString * const kEventSalonCategory = @"salon";
+static NSString * const kEventOthersCategory = @"others";
+
+static NSString * const kEventAllCategoryName = @"类型";
+static NSString * const kEventDramaCategoryName = @"戏剧/曲艺";
+static NSString * const kEventMusicCategoryName = @"音乐/演出";
+static NSString * const kEventExhibitionCategoryName = @"展览";
+static NSString * const kEventSportsCategoryName = @"体育";
+static NSString * const kEventPartyCategoryName = @"生活/聚会";
+static NSString * const kEventCommonwealCategoryName = @"公益";
+static NSString * const kEventTravelCategoryName = @"旅行";
+static NSString * const kEventFilmCategoryName = @"电影";
+static NSString * const kEventSalonCategoryName = @"讲座/沙龙";
+static NSString * const kEventOthersCategoryName = @"其他";
+
+
+@dynamic identifier;
+@dynamic alt;
+@dynamic title;
+@dynamic content;
+
+@dynamic beginTimeStr;
+@dynamic beginTime;
+@dynamic endTimeStr;
+@dynamic endTime;
+@dynamic category;
+@dynamic categoryName;
+@dynamic adaptUrl;
+@dynamic albumId;
+
+@dynamic participantCount;
+@dynamic wisherCount;
+
+@dynamic locId;
+@dynamic locName;
+@dynamic address;
+
+@dynamic imageMobile;
+@dynamic imageLarge;
+@dynamic image;
+@dynamic icon;
+
+@dynamic owner;
+
+@dynamic participateDateStr;
+@dynamic participateDate;
+
+@dynamic status;
+
+@dynamic lat;
+@dynamic lng;
+
+
+- (NSString *)identifier {
+ return [self.dictionary objectForKey:@"id"];
+}
+
+- (NSString *)alt {
+ return [self.dictionary objectForKey:@"alt"];
+}
+
+
+- (NSString *)title {
+ return [self.dictionary objectForKey:@"title"];
+}
+
+
+- (NSString *)content {
+ return [self.dictionary objectForKey:@"content"];
+}
+
+
+- (NSString *)beginTimeStr {
+ return [self.dictionary objectForKey:@"begin_time"];
+}
+
+
+- (NSDate *)beginTime {
+ return [[self class] dateOfString:self.beginTimeStr];
+}
+
+
+- (NSString *)endTimeStr {
+ return [self.dictionary objectForKey:@"end_time"];
+}
+
+
+- (NSDate *)endTime {
+ return [[self class] dateOfString:self.endTimeStr];
+}
+
+
+- (NSString *)category {
+ return [self.dictionary objectForKey:@"category"];
+}
+
+
+- (NSString *)categoryName {
+ NSString *category = self.category;
+ NSString *categoryName = kEventAllCategoryName;
+
+ if ([category isEqualToString:kEventDramaCategory]) {
+ categoryName = kEventDramaCategoryName;
+ }
+ else if ([category isEqualToString:kEventMusicCategory]) {
+ categoryName = kEventMusicCategoryName;
+ }
+ else if ([category isEqualToString:kEventExhibitionCategory]) {
+ categoryName = kEventExhibitionCategoryName;
+ }
+ else if ([category isEqualToString:kEventSportsCategory]) {
+ categoryName = kEventSportsCategoryName;
+ }
+ else if ([category isEqualToString:kEventPartyCategory]) {
+ categoryName = kEventPartyCategoryName;
+ }
+ else if ([category isEqualToString:kEventCommonwealCategory]) {
+ categoryName = kEventCommonwealCategoryName;
+ }
+ else if ([category isEqualToString:kEventTravelCategory]) {
+ categoryName = kEventTravelCategoryName;
+ }
+ else if ([category isEqualToString:kEventFilmCategory]) {
+ categoryName = kEventFilmCategoryName;
+ }
+ else if ([category isEqualToString:kEventSalonCategory]) {
+ categoryName = kEventSalonCategoryName;
+ }
+
+ return categoryName;
+}
+
+
+- (NSString *)adaptUrl {
+ return [self.dictionary objectForKey:@"adapt_url"];
+}
+
+
+- (NSString *)albumId {
+ return [self.dictionary objectForKey:@"album"];
+}
+
+
+- (NSInteger)participantCount {
+ return [[self.dictionary objectForKey:@"participant_count"] integerValue];
+}
+
+
+- (NSInteger)wisherCount {
+ return [[self.dictionary objectForKey:@"wisher_count"] integerValue];
+}
+
+
+- (NSString *)locId {
+ return [self.dictionary objectForKey:@"loc_id"];
+}
+
+
+- (NSString *)locName {
+ return [self.dictionary objectForKey:@"loc_name"];
+}
+
+
+- (NSString *)address {
+ return [self.dictionary objectForKey:@"address"];
+}
+
+
+- (NSString *)icon {
+ return [self.dictionary objectForKey:@"icon"];
+}
+
+
+- (NSString *)image {
+ return [self.dictionary objectForKey:@"image"];
+}
+
+
+- (NSString *)imageMobile {
+ return [self.dictionary objectForKey:@"image_lmobile"];
+}
+
+
+- (NSString *)imageLarge {
+ return [self.dictionary objectForKey:@"image_hlarge"];
+}
+
+
+- (NSString *)status {
+ return [self.dictionary objectForKey:@"status"];
+}
+
+
+- (void)setStatus:(NSString *)status {
+ return [self.dictionary setValue:status forKey:@"status"];
+}
+
+
+- (NSString *)participateDateStr {
+ return [self.dictionary objectForKey:@"participate_date"];
+}
+
+
+- (void)setParticipateDateStr:(NSString *)participateDateStr {
+ return [self.dictionary setValue:participateDateStr forKey:@"participate_date"];
+}
+
+
+- (NSDate *)participateDate {
+ if (!self.participateDateStr) {
+ return nil;
+ }
+ NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
+ [dateFormat setDateFormat:@"yyyy-MM-dd"];
+ NSDate *date = [dateFormat dateFromString:self.participateDateStr];
+ [dateFormat release];
+ return date;
+}
+
+
+- (DOUUser *)owner {
+ NSDictionary *dic = [self.dictionary objectForKey:@"owner"];
+ DOUUser *user = [DOUUser objectWithDictionary:dic];
+ return user;
+}
+
+
+- (float)lat {
+ NSString *geo = [self.dictionary objectForKey:@"geo"];
+ if (geo) {
+ NSArray *words = [geo componentsSeparatedByString:@" "];
+ if ([words count] == 2 && [words objectAtIndex:0]) {
+ NSString *str = [words objectAtIndex:0];
+ return [str floatValue];
+ }
+ }
+ return 0;
+}
+
+
+- (float)lng {
+ NSString *geo = [self.dictionary objectForKey:@"geo"];
+ if (geo) {
+ NSArray *words = [geo componentsSeparatedByString:@" "];
+ if ([words count] == 2 && [words objectAtIndex:1]) {
+ NSString *str = [words objectAtIndex:1];
+ return [str floatValue];
+ }
+ }
+ return 0;
+}
+
+
+@end
View
13 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Event/DOUEventArray.h
@@ -0,0 +1,13 @@
+//
+// DOUEventArray.h
+// DoubanAPIEngine
+//
+// Created by Lin GUO on 4/25/12.
+// Copyright (c) 2012 Douban Inc. All rights reserved.
+//
+
+#import "DOUObjectArray.h"
+
+@interface DOUEventArray : DOUObjectArray
+
+@end
View
22 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Event/DOUEventArray.m
@@ -0,0 +1,22 @@
+//
+// DOUEventArray.m
+// DoubanAPIEngine
+//
+// Created by Lin GUO on 4/25/12.
+// Copyright (c) 2012 Douban Inc. All rights reserved.
+//
+
+#import "DOUEventArray.h"
+#import "DOUEvent.h"
+
+@implementation DOUEventArray
+
++ (Class)objectClass {
+ return [DOUEvent class];
+}
+
++ (NSString *)objectName {
+ return @"events";
+}
+
+@end
View
19 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Event/DOULoc.h
@@ -0,0 +1,19 @@
+//
+// DOULoc.h
+// DoubanAPIEngine
+//
+// Created by Lin GUO on 9/7/12.
+// Copyright (c) 2012 Douban Inc. All rights reserved.
+//
+
+#import "DOUObject.h"
+
+@interface DOULoc : DOUObject
+
+@property (nonatomic, copy) NSString *identifier;
+@property (nonatomic, copy) NSString *parent;
+@property (nonatomic, copy) NSString *name;
+@property (nonatomic, copy) NSString *uid;
+@property (nonatomic, assign) BOOL isHabitable;
+
+@end
View
85 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Event/DOULoc.m
@@ -0,0 +1,85 @@
+//
+// DOULoc.m
+// DoubanAPIEngine
+//
+// Created by Lin GUO on 9/7/12.
+// Copyright (c) 2012 Douban Inc. All rights reserved.
+//
+
+#import "DOULoc.h"
+
+@implementation DOULoc
+
+@dynamic identifier;
+@dynamic parent;
+@dynamic name;
+@dynamic uid;
+@dynamic isHabitable;
+
+
+- (NSString *)identifier {
+ return [self.dictionary objectForKey:@"id"];
+}
+
+- (void)setIdentifier:(NSString *)identifier {
+ [self.dictionary setValue:identifier forKey:@"id"];
+
+}
+
+
+- (NSString *)parent {
+ return [self.dictionary objectForKey:@"parent"];
+}
+
+- (void)setParent:(NSString *)parent {
+ return [self.dictionary setObject:parent forKey:@"parent"];
+}
+
+
+- (NSString *)name {
+ return [self.dictionary objectForKey:@"name"];
+}
+
+- (void)setName:(NSString *)name {
+ return [self.dictionary setObject:name forKey:@"name"];
+}
+
+
+- (NSString *)uid {
+ return [self.dictionary objectForKey:@"uid"];
+}
+
+- (void)setUid:(NSString *)uid {
+ return [self.dictionary setObject:uid forKey:@"uid"];
+}
+
+
+- (BOOL)isHabitable {
+ return [[self.dictionary objectForKey:@"habitable"] boolValue];
+}
+
+
+- (void)setIsHabitable:(BOOL)isHabitable {
+ [self.dictionary setValue:[NSNumber numberWithBool:isHabitable] forKey:@"habitable"];
+}
+
+
+- (BOOL)isEqual:(id)object {
+ if (self == object) {
+ return YES;
+ }
+ if ([object isKindOfClass:[self class]]) {
+ if (![[self identifier] isEqualToString:[(DOULoc *)object identifier]])
+ return NO;
+
+ return YES;
+ }
+ return NO;
+}
+
+
+- (NSUInteger)hash {
+ return [[self identifier] hash];
+}
+
+@end
View
13 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Event/DOULocArray.h
@@ -0,0 +1,13 @@
+//
+// DOULocArray.h
+// DoubanAPIEngine
+//
+// Created by Lin GUO on 9/7/12.
+// Copyright (c) 2012 Douban Inc. All rights reserved.
+//
+
+#import "DOUObjectArray.h"
+
+@interface DOULocArray : DOUObjectArray
+
+@end
View
22 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Event/DOULocArray.m
@@ -0,0 +1,22 @@
+//
+// DOULocArray.m
+// DoubanAPIEngine
+//
+// Created by Lin GUO on 9/7/12.
+// Copyright (c) 2012 Douban Inc. All rights reserved.
+//
+
+#import "DOULocArray.h"
+#import "DOULoc.h"
+
+@implementation DOULocArray
+
++ (Class)objectClass {
+ return [DOULoc class];
+}
+
++ (NSString *)objectName {
+ return @"locs";
+}
+
+@end
View
4 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Photo/DOUAlbum.h
@@ -8,7 +8,7 @@
#import "DOUObject.h"
-@class DOUPeople;
+@class DOUUser;
@interface DOUAlbum : DOUObject
@property (nonatomic, copy) NSString *identifier;
@@ -33,6 +33,6 @@
@property (nonatomic, copy) NSString *cover;
@property (nonatomic, copy) NSString *image;
-@property (nonatomic, retain) DOUPeople *author;
+@property (nonatomic, retain) DOUUser *author;
@end
View
6 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Photo/DOUAlbum.m
@@ -8,7 +8,7 @@
#import "DOUAlbum.h"
#import "DOUObject+Utils.h"
-#import "DOUPeople.h"
+#import "DOUUser.h"
@implementation DOUAlbum
@@ -105,9 +105,9 @@ - (NSString *)image {
}
-- (DOUPeople *)author {
+- (DOUUser *)author {
NSDictionary *dic = [self.dictionary objectForKey:@"author"];
- DOUPeople *people = [DOUPeople objectWithDictionary:dic];
+ DOUUser *people = [DOUUser objectWithDictionary:dic];
return people;
}
View
4 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Photo/DOUPhoto.h
@@ -8,7 +8,7 @@
#import <UIKit/UIKit.h>
#import "DOUObject.h"
-@class DOUPeople;
+@class DOUUser;
@interface DOUPhoto : DOUObject
@property (nonatomic, copy) NSString *identifier;
@@ -33,7 +33,7 @@
@property (nonatomic, copy) NSString *nextPhoto;
@property (nonatomic, assign) BOOL liked;
-@property (nonatomic, retain) DOUPeople *author;
+@property (nonatomic, retain) DOUUser *author;
@property (nonatomic, assign) NSString *albumId;
@property (nonatomic, assign) NSString *albumTitle;
View
8 DoubanAPIEngine/DoubanAPIEngine/Sources/Model2/Photo/DOUPhoto.m
@@ -8,7 +8,7 @@
#import "DOUPhoto.h"
#import "DOUObject+Utils.h"
-#import "DOUPeople.h"
+#import "DOUUser.h"
@implementation DOUPhoto
@@ -121,10 +121,10 @@ - (NSString *)nextPhoto {
}
-- (DOUPeople *)author {
+- (DOUUser *)author {
NSDictionary *dic = [self.dictionary objectForKey:@"author"];
- DOUPeople *people = [DOUPeople objectWithDictionary:dic];
- return people;
+ DOUUser *user = [DOUUser objectWithDictionary:dic];
+ return user;
}
View
2  DoubanAPIEngine/DoubanAPIEngine/Sources/Network/DOUHttpRequest.m
@@ -29,7 +29,7 @@ @implementation DOUHttpRequest
+ (DOUHttpRequest *)requestWithURL:(NSURL *)URL {
DOUHttpRequest *req = [[[DOUHttpRequest alloc] initWithURL:URL] autorelease];
req.useCookiePersistence = NO;
- [req setValidatesSecureCertificate:NO];
+ //[req setValidatesSecureCertificate:NO];
[req setAllowCompressedResponse:YES];// YES is the default
[req setTimeOutSeconds:kDefaultTimeoutSeconds];
return req;
View
1  DoubanAPIEngine/DoubanAPIEngine/Sources/Network/DOUService.h
@@ -9,7 +9,6 @@
#import <Foundation/Foundation.h>
#import "DOUHttpRequest.h"
#import "GDataEntryBase.h"
-#import "DoubanEntryPhoto.h"
@class ASINetworkQueue;
View
27 DoubanAPIEngine/DoubanAPIEngine/Sources/Network/DOUService.m
@@ -208,13 +208,14 @@ - (BOOL)isValid {
#if NS_BLOCKS_AVAILABLE
-
- (DOUHttpRequest *)get:(DOUQuery *)query callback:(DOUReqBlock)block {
query.apiBaseUrlString = self.apiBaseUrlString;
// __block, It tells the block not to retain the request, which is important in preventing a retain-cycle,
// since the request will always retain the block
__block DOUHttpRequest * req = [DOUHttpRequest requestWithQuery:query completionBlock:^{
- block(req);
+ if (block != NULL) {
+ block(req);
+ }
}];
[req setRequestMethod:@"GET"];
@@ -227,7 +228,9 @@ - (DOUHttpRequest *)get:(DOUQuery *)query callback:(DOUReqBlock)block {
- (DOUHttpRequest *)post:(DOUQuery *)query postBody:(NSString *)body callback:(DOUReqBlock)block {
query.apiBaseUrlString = self.apiBaseUrlString;
__block DOUHttpRequest * req = [DOUHttpRequest requestWithQuery:query completionBlock:^{
- block(req);
+ if (block != NULL) {
+ block(req);
+ }
}];
[req setRequestMethod:@"POST"];
@@ -236,7 +239,7 @@ - (DOUHttpRequest *)post:(DOUQuery *)query postBody:(NSString *)body callback:(D
if (body && [body length] > 0) {
NSError *error = nil;
- GDataXMLElement *element = [[GDataXMLElement alloc] initWithXMLString:body error:&error];
+ GDataXMLElement *element = [[[GDataXMLElement alloc] initWithXMLString:body error:&error] autorelease];
if (!error && element) {
// if body is XML, Content-Type must be application/atom+xml
[req addRequestHeader:@"Content-Type" value:@"application/atom+xml"];
@@ -265,7 +268,9 @@ - (DOUHttpRequest *)post2:(DOUQuery *)query
query.apiBaseUrlString = self.apiBaseUrlString;
__block DOUHttpRequest * req = [DOUHttpRequest requestWithQuery:query completionBlock:^{
- block(req);
+ if (block != NULL) {
+ block(req);
+ }
}];
@@ -321,7 +326,9 @@ - (DOUHttpRequest *)post:(DOUQuery *)query
query.apiBaseUrlString = self.apiBaseUrlString;
__block DOUHttpRequest * req = [DOUHttpRequest requestWithQuery:query completionBlock:^{
- block(req);
+ if (block != NULL) {
+ block(req);
+ }
}];
@@ -384,7 +391,9 @@ - (DOUHttpRequest *)delete:(DOUQuery *)query callback:(DOUReqBlock)block {
query.apiBaseUrlString = self.apiBaseUrlString;
__block DOUHttpRequest * req = [DOUHttpRequest requestWithQuery:query completionBlock:^{
- block(req);
+ if (block != NULL) {
+ block(req);
+ }
}];
[req setRequestMethod:@"DELETE"];
@@ -401,6 +410,8 @@ - (DOUHttpRequest *)delete:(DOUQuery *)query callback:(DOUReqBlock)block {
- (DOUHttpRequest *)get:(DOUQuery *)query delegate:(id<DOUHttpRequestDelegate>)delegate {
query.apiBaseUrlString = self.apiBaseUrlString;
DOUHttpRequest * req = [DOUHttpRequest requestWithQuery:query target:delegate];
+
+ [req setRequestMethod:@"GET"];
[self addRequest:req];
return req;
}
@@ -416,7 +427,7 @@ - (DOUHttpRequest *)post:(DOUQuery *)query postBody:(NSString *)body delegate:(i
if (body && [body length] > 0) {
NSError *error = nil;
- GDataXMLElement *element = [[GDataXMLElement alloc] initWithXMLString:body error:&error];
+ GDataXMLElement *element = [[[GDataXMLElement alloc] initWithXMLString:body error:&error] autorelease];
if (!error && element) {
// if body is XML, Content-Type must be application/atom+xml
[req addRequestHeader:@"Content-Type" value:@"application/atom+xml"];
View
14 DoubanAPIEngine/DoubanAPIEngineTests/DoubanAPIEngineTests.m
@@ -13,6 +13,8 @@
#import "DOUService.h"
#import "DOUQuery.h"
#import "DoubanEntrySubject.h"
+#import "DOUAPIEngine.h"
+
@interface DoubanAPIEngineTests : SenTestCase
@@ -72,18 +74,8 @@ + (DOUQuery *)queryBookWithId:(int)bookId {
return [query autorelease];
}
-
- (void)testPostEvent {
-
- DOUTestResponseLoader *loader = [DOUTestResponseLoader responseLoader];
- [loader setTimeout:10];
- DOUQuery *query = [[self class] queryCreateEvent];
- DOUService *service = [DOUService sharedInstance];
- service.apiBaseUrlString = kHttpsApiBaseUrl;
-
- [service post:query delegate:loader];
- [loader waitForResponse];
- STAssertTrue(loader.wasSuccessful == YES, @"");
+// todo
}
View
1  DoubanAPIEngine/DoubanAPIEngineTests/Model/DoubanPeopleTests.m
@@ -45,6 +45,7 @@ - (void)testDoubanEntryPeople {
DoubanEntryPeople *people = [[DoubanEntryPeople alloc] initWithData:data];
+ NSLog(@"identify : %@", [people.location identity]);
STAssertTrue([[people.location identity] isEqualToString:@"beijing"], @"location");
STAssertTrue([[people.location content] isEqualToString:@"北京"], @"location");
View
2  DoubanAPIEngine/DoubanAPIEngineTests/Model2/DOUOnlineTests.m
@@ -9,7 +9,7 @@
#import <SenTestingKit/SenTestingKit.h>
#import "DOUOnline.h"
#import "DOUOnlineArray.h"
-#import "DOUPeople.h"
+#import "DOUUser.h"
@interface DOUOnlineTests : SenTestCase
View
2  DoubanAPIEngine/DoubanAPIEngineTests/Model2/DOUPhotoTests.m
@@ -10,7 +10,7 @@
#import "DOUPhoto.h"
#import "DOUPhotoArray.h"
#import "DOUAlbum.h"
-#import "DOUPeople.h"
+#import "DOUUser.h"
@interface DOUPhotoTests : SenTestCase
View
2  DoubanAPIEngine/DoubanAPIEngineTests/Resources/Model/DoubanEntryEvent.xml
@@ -24,7 +24,7 @@
<db:attribute name="participants">342</db:attribute>
<db:attribute name="wishers">1118</db:attribute>
<db:attribute name="album">58416320</db:attribute>
- <db:location id="beijing">北京</db:location>
+ <db:location n_id="beijing">北京</db:location>
<gd:when endTime="2011-12-18T21:30:00+08:00" startTime="2011-12-18T19:30:00+08:00"/>
<gd:where valueString="北京 西城区 西直门/动物园 北京展览馆剧场"/>
<georss:point>39.904213 116.40741</georss:point>
Something went wrong with that request. Please try again.