diff --git a/NSDictionary+OTRestRequestSerialization.h b/NSDictionary+OTRestRequestSerialization.h new file mode 100644 index 00000000..1caed68f --- /dev/null +++ b/NSDictionary+OTRestRequestSerialization.h @@ -0,0 +1,18 @@ +// +// NSDictionary+OTRestRequestSerialization.h +// gateguru +// +// Created by Blake Watters on 7/28/09. +// Copyright 2009 Objective 3. All rights reserved. +// + +#import +#import "OTRestRequestSerializable.h" + +@interface NSDictionary (OTRestRequestSerialization) + +- (NSString*)URLEncodedString; +- (NSString*)ContentTypeHTTPHeader; +- (NSData*)HTTPBody; + +@end diff --git a/NSDictionary+OTRestRequestSerialization.m b/NSDictionary+OTRestRequestSerialization.m new file mode 100644 index 00000000..6dec7322 --- /dev/null +++ b/NSDictionary+OTRestRequestSerialization.m @@ -0,0 +1,45 @@ +// +// NSDictionary+OTRestRequestSerialization.m +// gateguru +// +// Created by Blake Watters on 7/28/09. +// Copyright 2009 Objective 3. All rights reserved. +// + +#import "NSDictionary+OTRestRequestSerialization.h" + +// private helper function to convert any object to its string representation +static NSString *toString(id object) { + return [NSString stringWithFormat: @"%@", object]; +} + +// private helper function to convert string to UTF-8 and URL encode it +static NSString *urlEncode(id object) { + NSString *string = toString(object); + return [string stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; +} + + +@implementation NSDictionary (OTRestRequestSerialization) + +- (NSString*)URLEncodedString { + NSMutableArray *parts = [NSMutableArray array]; + for (id key in self) { + id value = [self objectForKey: key]; + NSString *part = [NSString stringWithFormat: @"%@=%@", + urlEncode(key), urlEncode(value)]; + [parts addObject: part]; + } + + return [parts componentsJoinedByString: @"&"]; +} + +- (NSString*)ContentTypeHTTPHeader { + return @"application/x-www-form-urlencoded"; +} + +- (NSData*)HTTPBody { + return [[self URLEncodedString] dataUsingEncoding:NSUTF8StringEncoding]; +} + +@end diff --git a/OTRestClient.h b/OTRestClient.h new file mode 100644 index 00000000..53e77cd3 --- /dev/null +++ b/OTRestClient.h @@ -0,0 +1,87 @@ +// +// OTRestClient.h +// gateguru +// +// Created by Blake Watters on 7/28/09. +// Copyright 2009 Objective 3. All rights reserved. +// + +#import "OTRestRequest.h" +#import "OTRestParams.h" +#import "OTRestResponse.h" +#import "NSDictionary+OTRestRequestSerialization.h" +#import "Element+OTRestAdditions.h" + +@interface OTRestClient : NSObject { + NSString* _baseURL; + NSString* _username; + NSString* _password; + NSMutableDictionary* _HTTPHeaders; +} + +/** + * The base URL all resources are nested underneath + */ +@property(nonatomic, retain) NSString* baseURL; + +/** + * The username to use for authentication via HTTP AUTH + */ +@property(nonatomic, retain) NSString* username; + +/** + * The password to use for authentication via HTTP AUTH + */ +@property(nonatomic, retain) NSString* password; + +/** + * A dictionary of headers to be sent with each request + */ +@property(nonatomic, readonly) NSDictionary* HTTPHeaders; + +/** + * Return the configured singleton instance of the Rest client + */ ++ (OTRestClient*)client; + +/** + * Set the shared singleton issue of the Rest client + */ ++ (void)setClient:(OTRestClient*)client; + +/** + * Return a Rest client scoped to a particular base URL. If the singleton client is nil, the return client is set as the singleton + */ ++ (OTRestClient*)clientWithBaseURL:(NSString*)baseURL; + +/** + * Return a Rest client scoped to a particular base URL with a set of HTTP AUTH credentials. If the singleton client is nil, the return client is set as the singleton + */ ++ (OTRestClient*)clientWithBaseURL:(NSString*)baseURL username:(NSString*)username password:(NSString*)password; + +/** + * Fetch a resource via an HTTP GET and invoke a callback with the resulting payload + */ +- (OTRestRequest*)get:(NSString*)resourcePath delegate:(id)delegate callback:(SEL)callback; + +/** + * Create a resource via an HTTP POST with a set of form parameters and invoke a callback with the resulting payload + */ +- (OTRestRequest*)post:(NSString*)resourcePath params:(NSObject*)params delegate:(id)delegate callback:(SEL)callback; + +/** + * Update a resource via an HTTP PUT and invoke a callback with the resulting payload + */ +- (OTRestRequest*)put:(NSString*)resourcePath params:(NSObject*)params delegate:(id)delegate callback:(SEL)callback; + +/** + * Destroy a resource via an HTTP DELETE and invoke a callback with the resulting payload + */ +- (OTRestRequest*)delete:(NSString*)resourcePath delegate:(id)delegate callback:(SEL)callback; + +/** + * Adds an HTTP header to each request dispatched through the Rest client + */ +- (void)setValue:(NSString*)value forHTTPHeaderField:(NSString*)header; + +@end diff --git a/OTRestClient.m b/OTRestClient.m new file mode 100644 index 00000000..ec990375 --- /dev/null +++ b/OTRestClient.m @@ -0,0 +1,102 @@ +// +// OTRestClient.m +// gateguru +// +// Created by Blake Watters on 7/28/09. +// Copyright 2009 Objective 3. All rights reserved. +// + +#import "OTRestClient.h" + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// global + +static OTRestClient* sharedClient = nil; + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +@implementation OTRestClient + +@synthesize baseURL = _baseURL, username = _username, password = _password, HTTPHeaders = _HTTPHeaders; + ++ (OTRestClient*)client { + return sharedClient; +} + ++ (void)setClient:(OTRestClient*)client { + [sharedClient release]; + sharedClient = [client retain]; +} + ++ (OTRestClient*)clientWithBaseURL:(NSString*)baseURL { + OTRestClient* client = [[[OTRestClient alloc] init] autorelease]; + client.baseURL = baseURL; + if (sharedClient == nil) { + [OTRestClient setClient:client]; + } + + return client; +} + ++ (OTRestClient*)clientWithBaseURL:(NSString*)baseURL username:(NSString*)username password:(NSString*)password { + OTRestClient* client = [OTRestClient clientWithBaseURL:baseURL]; + client.username = username; + client.password = password; + + return client; +} + +- (id)init { + if (self = [super init]) { + _HTTPHeaders = [[NSMutableDictionary alloc] init]; + } + + return self; +} + +- (void)dealloc { + [_baseURL release]; + [_username release]; + [_password release]; + [_HTTPHeaders release]; + [super dealloc]; +} + +- (NSURL*)URLForResourcePath:(NSString*)resourcePath { + NSString* urlString = [NSString stringWithFormat:@"%@%@", self.baseURL, resourcePath]; + return [NSURL URLWithString:urlString]; +} + +- (OTRestRequest*)get:(NSString*)resourcePath delegate:(id)delegate callback:(SEL)callback { + OTRestRequest* request = [[OTRestRequest alloc] initWithURL:[self URLForResourcePath:resourcePath] delegate:delegate callback:callback]; + request.additionalHTTPHeaders = _HTTPHeaders; + [request get]; + return request; +} + +- (OTRestRequest*)post:(NSString*)resourcePath params:(NSObject*)params delegate:(id)delegate callback:(SEL)callback { + OTRestRequest* request = [[OTRestRequest alloc] initWithURL:[self URLForResourcePath:resourcePath] delegate:delegate callback:callback]; + request.additionalHTTPHeaders = _HTTPHeaders; + [request postParams:params]; + return request; +} + +- (OTRestRequest*)put:(NSString*)resourcePath params:(NSObject*)params delegate:(id)delegate callback:(SEL)callback { + OTRestRequest* request = [[OTRestRequest alloc] initWithURL:[self URLForResourcePath:resourcePath] delegate:delegate callback:callback]; + request.additionalHTTPHeaders = _HTTPHeaders; + [request putParams:params]; + return request; +} + +- (OTRestRequest*)delete:(NSString*)resourcePath delegate:(id)delegate callback:(SEL)callback { + OTRestRequest* request = [[OTRestRequest alloc] initWithURL:[self URLForResourcePath:resourcePath] delegate:delegate callback:callback]; + request.additionalHTTPHeaders = _HTTPHeaders; + [request delete]; + return request; +} + +- (void)setValue:(NSString*)value forHTTPHeaderField:(NSString*)header { + [_HTTPHeaders setValue:value forKey:header]; +} + +@end diff --git a/OTRestFramework.xcodeproj/jeremy.mode1v3 b/OTRestFramework.xcodeproj/jeremy.mode1v3 deleted file mode 100644 index a3025034..00000000 --- a/OTRestFramework.xcodeproj/jeremy.mode1v3 +++ /dev/null @@ -1,1351 +0,0 @@ - - - - - ActivePerspectiveName - Project - AllowedModules - - - BundleLoadPath - - MaxInstances - n - Module - PBXSmartGroupTreeModule - Name - Groups and Files Outline View - - - BundleLoadPath - - MaxInstances - n - Module - PBXNavigatorGroup - Name - Editor - - - BundleLoadPath - - MaxInstances - n - Module - XCTaskListModule - Name - Task List - - - BundleLoadPath - - MaxInstances - n - Module - XCDetailModule - Name - File and Smart Group Detail Viewer - - - BundleLoadPath - - MaxInstances - 1 - Module - PBXBuildResultsModule - Name - Detailed Build Results Viewer - - - BundleLoadPath - - MaxInstances - 1 - Module - PBXProjectFindModule - Name - Project Batch Find Tool - - - BundleLoadPath - - MaxInstances - n - Module - XCProjectFormatConflictsModule - Name - Project Format Conflicts List - - - BundleLoadPath - - MaxInstances - n - Module - PBXBookmarksModule - Name - Bookmarks Tool - - - BundleLoadPath - - MaxInstances - n - Module - PBXClassBrowserModule - Name - Class Browser - - - BundleLoadPath - - MaxInstances - n - Module - PBXCVSModule - Name - Source Code Control Tool - - - BundleLoadPath - - MaxInstances - n - Module - PBXDebugBreakpointsModule - Name - Debug Breakpoints Tool - - - BundleLoadPath - - MaxInstances - n - Module - XCDockableInspector - Name - Inspector - - - BundleLoadPath - - MaxInstances - n - Module - PBXOpenQuicklyModule - Name - Open Quickly Tool - - - BundleLoadPath - - MaxInstances - 1 - Module - PBXDebugSessionModule - Name - Debugger - - - BundleLoadPath - - MaxInstances - 1 - Module - PBXDebugCLIModule - Name - Debug Console - - - BundleLoadPath - - MaxInstances - n - Module - XCSnapshotModule - Name - Snapshots Tool - - - BundlePath - /Developer/Library/PrivateFrameworks/DevToolsInterface.framework/Resources - Description - DefaultDescriptionKey - DockingSystemVisible - - Extension - mode1v3 - FavBarConfig - - PBXProjectModuleGUID - 3F4E187C102DD18F00320118 - XCBarModuleItemNames - - XCBarModuleItems - - - FirstTimeWindowDisplayed - - Identifier - com.apple.perspectives.project.mode1v3 - MajorVersion - 33 - MinorVersion - 0 - Name - Default - Notifications - - OpenEditors - - PerspectiveWidths - - -1 - -1 - - Perspectives - - - ChosenToolbarItems - - active-combo-popup - action - NSToolbarFlexibleSpaceItem - buildOrClean - build-and-goOrGo - com.apple.ide.PBXToolbarStopButton - get-info - NSToolbarFlexibleSpaceItem - com.apple.pbx.toolbar.searchfield - - ControllerClassBaseName - - IconName - WindowOfProjectWithEditor - Identifier - perspective.project - IsVertical - - Layout - - - BecomeActive - - ContentConfiguration - - PBXBottomSmartGroupGIDs - - 1C37FBAC04509CD000000102 - 1C37FAAC04509CD000000102 - 1C08E77C0454961000C914BD - 1C37FABC05509CD000000102 - 1C37FABC05539CD112110102 - E2644B35053B69B200211256 - 1C37FABC04509CD000100104 - 1CC0EA4004350EF90044410B - 1CC0EA4004350EF90041110B - - PBXProjectModuleGUID - 1CE0B1FE06471DED0097A5F4 - PBXProjectModuleLabel - Files - PBXProjectStructureProvided - yes - PBXSmartGroupTreeModuleColumnData - - PBXSmartGroupTreeModuleColumnWidthsKey - - 186 - - PBXSmartGroupTreeModuleColumnsKey_v4 - - MainColumn - - - PBXSmartGroupTreeModuleOutlineStateKey_v7 - - PBXSmartGroupTreeModuleOutlineStateExpansionKey - - 0867D691FE84028FC02AAC07 - 1C37FABC05509CD000000102 - - PBXSmartGroupTreeModuleOutlineStateSelectionKey - - - 0 - - - PBXSmartGroupTreeModuleOutlineStateVisibleRectKey - {{0, 0}, {186, 445}} - - PBXTopSmartGroupGIDs - - XCIncludePerspectivesSwitch - - XCSharingToken - com.apple.Xcode.GFSharingToken - - GeometryConfiguration - - Frame - {{0, 0}, {203, 463}} - GroupTreeTableConfiguration - - MainColumn - 186 - - RubberWindowFrame - 78 374 788 504 0 0 1440 878 - - Module - PBXSmartGroupTreeModule - Proportion - 203pt - - - Dock - - - ContentConfiguration - - PBXProjectModuleGUID - 1CE0B20306471E060097A5F4 - PBXProjectModuleLabel - MyNewFile14.java - PBXSplitModuleInNavigatorKey - - Split0 - - PBXProjectModuleGUID - 1CE0B20406471E060097A5F4 - PBXProjectModuleLabel - MyNewFile14.java - - SplitCount - 1 - - StatusBarVisibility - - - GeometryConfiguration - - Frame - {{0, 0}, {580, 285}} - RubberWindowFrame - 78 374 788 504 0 0 1440 878 - - Module - PBXNavigatorGroup - Proportion - 285pt - - - ContentConfiguration - - PBXProjectModuleGUID - 1CE0B20506471E060097A5F4 - PBXProjectModuleLabel - Detail - - GeometryConfiguration - - Frame - {{0, 290}, {580, 173}} - RubberWindowFrame - 78 374 788 504 0 0 1440 878 - - Module - XCDetailModule - Proportion - 173pt - - - Proportion - 580pt - - - Name - Project - ServiceClasses - - XCModuleDock - PBXSmartGroupTreeModule - XCModuleDock - PBXNavigatorGroup - XCDetailModule - - TableOfContents - - 3F4E187A102DD18F00320118 - 1CE0B1FE06471DED0097A5F4 - 3F4E187B102DD18F00320118 - 1CE0B20306471E060097A5F4 - 1CE0B20506471E060097A5F4 - - ToolbarConfiguration - xcode.toolbar.config.defaultV3 - - - ControllerClassBaseName - - IconName - WindowOfProject - Identifier - perspective.morph - IsVertical - 0 - Layout - - - BecomeActive - 1 - ContentConfiguration - - PBXBottomSmartGroupGIDs - - 1C37FBAC04509CD000000102 - 1C37FAAC04509CD000000102 - 1C08E77C0454961000C914BD - 1C37FABC05509CD000000102 - 1C37FABC05539CD112110102 - E2644B35053B69B200211256 - 1C37FABC04509CD000100104 - 1CC0EA4004350EF90044410B - 1CC0EA4004350EF90041110B - - PBXProjectModuleGUID - 11E0B1FE06471DED0097A5F4 - PBXProjectModuleLabel - Files - PBXProjectStructureProvided - yes - PBXSmartGroupTreeModuleColumnData - - PBXSmartGroupTreeModuleColumnWidthsKey - - 186 - - PBXSmartGroupTreeModuleColumnsKey_v4 - - MainColumn - - - PBXSmartGroupTreeModuleOutlineStateKey_v7 - - PBXSmartGroupTreeModuleOutlineStateExpansionKey - - 29B97314FDCFA39411CA2CEA - 1C37FABC05509CD000000102 - - PBXSmartGroupTreeModuleOutlineStateSelectionKey - - - 0 - - - PBXSmartGroupTreeModuleOutlineStateVisibleRectKey - {{0, 0}, {186, 337}} - - PBXTopSmartGroupGIDs - - XCIncludePerspectivesSwitch - 1 - XCSharingToken - com.apple.Xcode.GFSharingToken - - GeometryConfiguration - - Frame - {{0, 0}, {203, 355}} - GroupTreeTableConfiguration - - MainColumn - 186 - - RubberWindowFrame - 373 269 690 397 0 0 1440 878 - - Module - PBXSmartGroupTreeModule - Proportion - 100% - - - Name - Morph - PreferredWidth - 300 - ServiceClasses - - XCModuleDock - PBXSmartGroupTreeModule - - TableOfContents - - 11E0B1FE06471DED0097A5F4 - - ToolbarConfiguration - xcode.toolbar.config.default.shortV3 - - - PerspectivesBarVisible - - ShelfIsVisible - - SourceDescription - file at '/Developer/Library/PrivateFrameworks/DevToolsInterface.framework/Resources/XCPerspectivesSpecificationMode1.xcperspec' - StatusbarIsVisible - - TimeStamp - 0.0 - ToolbarDisplayMode - 1 - ToolbarIsVisible - - ToolbarSizeMode - 1 - Type - Perspectives - UpdateMessage - The Default Workspace in this version of Xcode now includes support to hide and show the detail view (what has been referred to as the "Metro-Morph" feature). You must discard your current Default Workspace settings and update to the latest Default Workspace in order to gain this feature. Do you wish to update to the latest Workspace defaults for project '%@'? - WindowJustification - 5 - WindowOrderList - - /Users/jeremy/objective3/OTRestFramework/OTRestFramework.xcodeproj - - WindowString - 78 374 788 504 0 0 1440 878 - WindowToolsV3 - - - Identifier - windowTool.build - Layout - - - Dock - - - ContentConfiguration - - PBXProjectModuleGUID - 1CD0528F0623707200166675 - PBXProjectModuleLabel - <No Editor> - PBXSplitModuleInNavigatorKey - - Split0 - - PBXProjectModuleGUID - 1CD052900623707200166675 - - SplitCount - 1 - - StatusBarVisibility - 1 - - GeometryConfiguration - - Frame - {{0, 0}, {500, 215}} - RubberWindowFrame - 192 257 500 500 0 0 1280 1002 - - Module - PBXNavigatorGroup - Proportion - 218pt - - - BecomeActive - 1 - ContentConfiguration - - PBXProjectModuleGUID - XCMainBuildResultsModuleGUID - PBXProjectModuleLabel - Build - - GeometryConfiguration - - Frame - {{0, 222}, {500, 236}} - RubberWindowFrame - 192 257 500 500 0 0 1280 1002 - - Module - PBXBuildResultsModule - Proportion - 236pt - - - Proportion - 458pt - - - Name - Build Results - ServiceClasses - - PBXBuildResultsModule - - StatusbarIsVisible - 1 - TableOfContents - - 1C78EAA5065D492600B07095 - 1C78EAA6065D492600B07095 - 1CD0528F0623707200166675 - XCMainBuildResultsModuleGUID - - ToolbarConfiguration - xcode.toolbar.config.buildV3 - WindowString - 192 257 500 500 0 0 1280 1002 - - - Identifier - windowTool.debugger - Layout - - - Dock - - - ContentConfiguration - - Debugger - - HorizontalSplitView - - _collapsingFrameDimension - 0.0 - _indexOfCollapsedView - 0 - _percentageOfCollapsedView - 0.0 - isCollapsed - yes - sizes - - {{0, 0}, {317, 164}} - {{317, 0}, {377, 164}} - - - VerticalSplitView - - _collapsingFrameDimension - 0.0 - _indexOfCollapsedView - 0 - _percentageOfCollapsedView - 0.0 - isCollapsed - yes - sizes - - {{0, 0}, {694, 164}} - {{0, 164}, {694, 216}} - - - - LauncherConfigVersion - 8 - PBXProjectModuleGUID - 1C162984064C10D400B95A72 - PBXProjectModuleLabel - Debug - GLUTExamples (Underwater) - - GeometryConfiguration - - DebugConsoleDrawerSize - {100, 120} - DebugConsoleVisible - None - DebugConsoleWindowFrame - {{200, 200}, {500, 300}} - DebugSTDIOWindowFrame - {{200, 200}, {500, 300}} - Frame - {{0, 0}, {694, 380}} - RubberWindowFrame - 321 238 694 422 0 0 1440 878 - - Module - PBXDebugSessionModule - Proportion - 100% - - - Proportion - 100% - - - Name - Debugger - ServiceClasses - - PBXDebugSessionModule - - StatusbarIsVisible - 1 - TableOfContents - - 1CD10A99069EF8BA00B06720 - 1C0AD2AB069F1E9B00FABCE6 - 1C162984064C10D400B95A72 - 1C0AD2AC069F1E9B00FABCE6 - - ToolbarConfiguration - xcode.toolbar.config.debugV3 - WindowString - 321 238 694 422 0 0 1440 878 - WindowToolGUID - 1CD10A99069EF8BA00B06720 - WindowToolIsVisible - 0 - - - Identifier - windowTool.find - Layout - - - Dock - - - Dock - - - ContentConfiguration - - PBXProjectModuleGUID - 1CDD528C0622207200134675 - PBXProjectModuleLabel - <No Editor> - PBXSplitModuleInNavigatorKey - - Split0 - - PBXProjectModuleGUID - 1CD0528D0623707200166675 - - SplitCount - 1 - - StatusBarVisibility - 1 - - GeometryConfiguration - - Frame - {{0, 0}, {781, 167}} - RubberWindowFrame - 62 385 781 470 0 0 1440 878 - - Module - PBXNavigatorGroup - Proportion - 781pt - - - Proportion - 50% - - - BecomeActive - 1 - ContentConfiguration - - PBXProjectModuleGUID - 1CD0528E0623707200166675 - PBXProjectModuleLabel - Project Find - - GeometryConfiguration - - Frame - {{8, 0}, {773, 254}} - RubberWindowFrame - 62 385 781 470 0 0 1440 878 - - Module - PBXProjectFindModule - Proportion - 50% - - - Proportion - 428pt - - - Name - Project Find - ServiceClasses - - PBXProjectFindModule - - StatusbarIsVisible - 1 - TableOfContents - - 1C530D57069F1CE1000CFCEE - 1C530D58069F1CE1000CFCEE - 1C530D59069F1CE1000CFCEE - 1CDD528C0622207200134675 - 1C530D5A069F1CE1000CFCEE - 1CE0B1FE06471DED0097A5F4 - 1CD0528E0623707200166675 - - WindowString - 62 385 781 470 0 0 1440 878 - WindowToolGUID - 1C530D57069F1CE1000CFCEE - WindowToolIsVisible - 0 - - - Identifier - MENUSEPARATOR - - - Identifier - windowTool.debuggerConsole - Layout - - - Dock - - - BecomeActive - 1 - ContentConfiguration - - PBXProjectModuleGUID - 1C78EAAC065D492600B07095 - PBXProjectModuleLabel - Debugger Console - - GeometryConfiguration - - Frame - {{0, 0}, {650, 250}} - RubberWindowFrame - 516 632 650 250 0 0 1680 1027 - - Module - PBXDebugCLIModule - Proportion - 209pt - - - Proportion - 209pt - - - Name - Debugger Console - ServiceClasses - - PBXDebugCLIModule - - StatusbarIsVisible - 1 - TableOfContents - - 1C78EAAD065D492600B07095 - 1C78EAAE065D492600B07095 - 1C78EAAC065D492600B07095 - - ToolbarConfiguration - xcode.toolbar.config.consoleV3 - WindowString - 650 41 650 250 0 0 1280 1002 - WindowToolGUID - 1C78EAAD065D492600B07095 - WindowToolIsVisible - 0 - - - Identifier - windowTool.snapshots - Layout - - - Dock - - - Module - XCSnapshotModule - Proportion - 100% - - - Proportion - 100% - - - Name - Snapshots - ServiceClasses - - XCSnapshotModule - - StatusbarIsVisible - Yes - ToolbarConfiguration - xcode.toolbar.config.snapshots - WindowString - 315 824 300 550 0 0 1440 878 - WindowToolIsVisible - Yes - - - Identifier - windowTool.scm - Layout - - - Dock - - - ContentConfiguration - - PBXProjectModuleGUID - 1C78EAB2065D492600B07095 - PBXProjectModuleLabel - <No Editor> - PBXSplitModuleInNavigatorKey - - Split0 - - PBXProjectModuleGUID - 1C78EAB3065D492600B07095 - - SplitCount - 1 - - StatusBarVisibility - 1 - - GeometryConfiguration - - Frame - {{0, 0}, {452, 0}} - RubberWindowFrame - 743 379 452 308 0 0 1280 1002 - - Module - PBXNavigatorGroup - Proportion - 0pt - - - BecomeActive - 1 - ContentConfiguration - - PBXProjectModuleGUID - 1CD052920623707200166675 - PBXProjectModuleLabel - SCM - - GeometryConfiguration - - ConsoleFrame - {{0, 259}, {452, 0}} - Frame - {{0, 7}, {452, 259}} - RubberWindowFrame - 743 379 452 308 0 0 1280 1002 - TableConfiguration - - Status - 30 - FileName - 199 - Path - 197.0950012207031 - - TableFrame - {{0, 0}, {452, 250}} - - Module - PBXCVSModule - Proportion - 262pt - - - Proportion - 266pt - - - Name - SCM - ServiceClasses - - PBXCVSModule - - StatusbarIsVisible - 1 - TableOfContents - - 1C78EAB4065D492600B07095 - 1C78EAB5065D492600B07095 - 1C78EAB2065D492600B07095 - 1CD052920623707200166675 - - ToolbarConfiguration - xcode.toolbar.config.scm - WindowString - 743 379 452 308 0 0 1280 1002 - - - Identifier - windowTool.breakpoints - IsVertical - 0 - Layout - - - Dock - - - BecomeActive - 1 - ContentConfiguration - - PBXBottomSmartGroupGIDs - - 1C77FABC04509CD000000102 - - PBXProjectModuleGUID - 1CE0B1FE06471DED0097A5F4 - PBXProjectModuleLabel - Files - PBXProjectStructureProvided - no - PBXSmartGroupTreeModuleColumnData - - PBXSmartGroupTreeModuleColumnWidthsKey - - 168 - - PBXSmartGroupTreeModuleColumnsKey_v4 - - MainColumn - - - PBXSmartGroupTreeModuleOutlineStateKey_v7 - - PBXSmartGroupTreeModuleOutlineStateExpansionKey - - 1C77FABC04509CD000000102 - - PBXSmartGroupTreeModuleOutlineStateSelectionKey - - - 0 - - - PBXSmartGroupTreeModuleOutlineStateVisibleRectKey - {{0, 0}, {168, 350}} - - PBXTopSmartGroupGIDs - - XCIncludePerspectivesSwitch - 0 - - GeometryConfiguration - - Frame - {{0, 0}, {185, 368}} - GroupTreeTableConfiguration - - MainColumn - 168 - - RubberWindowFrame - 315 424 744 409 0 0 1440 878 - - Module - PBXSmartGroupTreeModule - Proportion - 185pt - - - ContentConfiguration - - PBXProjectModuleGUID - 1CA1AED706398EBD00589147 - PBXProjectModuleLabel - Detail - - GeometryConfiguration - - Frame - {{190, 0}, {554, 368}} - RubberWindowFrame - 315 424 744 409 0 0 1440 878 - - Module - XCDetailModule - Proportion - 554pt - - - Proportion - 368pt - - - MajorVersion - 3 - MinorVersion - 0 - Name - Breakpoints - ServiceClasses - - PBXSmartGroupTreeModule - XCDetailModule - - StatusbarIsVisible - 1 - TableOfContents - - 1CDDB66807F98D9800BB5817 - 1CDDB66907F98D9800BB5817 - 1CE0B1FE06471DED0097A5F4 - 1CA1AED706398EBD00589147 - - ToolbarConfiguration - xcode.toolbar.config.breakpointsV3 - WindowString - 315 424 744 409 0 0 1440 878 - WindowToolGUID - 1CDDB66807F98D9800BB5817 - WindowToolIsVisible - 1 - - - Identifier - windowTool.debugAnimator - Layout - - - Dock - - - Module - PBXNavigatorGroup - Proportion - 100% - - - Proportion - 100% - - - Name - Debug Visualizer - ServiceClasses - - PBXNavigatorGroup - - StatusbarIsVisible - 1 - ToolbarConfiguration - xcode.toolbar.config.debugAnimatorV3 - WindowString - 100 100 700 500 0 0 1280 1002 - - - Identifier - windowTool.bookmarks - Layout - - - Dock - - - Module - PBXBookmarksModule - Proportion - 100% - - - Proportion - 100% - - - Name - Bookmarks - ServiceClasses - - PBXBookmarksModule - - StatusbarIsVisible - 0 - WindowString - 538 42 401 187 0 0 1280 1002 - - - Identifier - windowTool.projectFormatConflicts - Layout - - - Dock - - - Module - XCProjectFormatConflictsModule - Proportion - 100% - - - Proportion - 100% - - - Name - Project Format Conflicts - ServiceClasses - - XCProjectFormatConflictsModule - - StatusbarIsVisible - 0 - WindowContentMinSize - 450 300 - WindowString - 50 850 472 307 0 0 1440 877 - - - Identifier - windowTool.classBrowser - Layout - - - Dock - - - BecomeActive - 1 - ContentConfiguration - - OptionsSetName - Hierarchy, all classes - PBXProjectModuleGUID - 1CA6456E063B45B4001379D8 - PBXProjectModuleLabel - Class Browser - NSObject - - GeometryConfiguration - - ClassesFrame - {{0, 0}, {374, 96}} - ClassesTreeTableConfiguration - - PBXClassNameColumnIdentifier - 208 - PBXClassBookColumnIdentifier - 22 - - Frame - {{0, 0}, {630, 331}} - MembersFrame - {{0, 105}, {374, 395}} - MembersTreeTableConfiguration - - PBXMemberTypeIconColumnIdentifier - 22 - PBXMemberNameColumnIdentifier - 216 - PBXMemberTypeColumnIdentifier - 97 - PBXMemberBookColumnIdentifier - 22 - - PBXModuleWindowStatusBarHidden2 - 1 - RubberWindowFrame - 385 179 630 352 0 0 1440 878 - - Module - PBXClassBrowserModule - Proportion - 332pt - - - Proportion - 332pt - - - Name - Class Browser - ServiceClasses - - PBXClassBrowserModule - - StatusbarIsVisible - 0 - TableOfContents - - 1C0AD2AF069F1E9B00FABCE6 - 1C0AD2B0069F1E9B00FABCE6 - 1CA6456E063B45B4001379D8 - - ToolbarConfiguration - xcode.toolbar.config.classbrowser - WindowString - 385 179 630 352 0 0 1440 878 - WindowToolGUID - 1C0AD2AF069F1E9B00FABCE6 - WindowToolIsVisible - 0 - - - Identifier - windowTool.refactoring - IncludeInToolsMenu - 0 - Layout - - - Dock - - - BecomeActive - 1 - GeometryConfiguration - - Frame - {0, 0}, {500, 335} - RubberWindowFrame - {0, 0}, {500, 335} - - Module - XCRefactoringModule - Proportion - 100% - - - Proportion - 100% - - - Name - Refactoring - ServiceClasses - - XCRefactoringModule - - WindowString - 200 200 500 356 0 0 1920 1200 - - - - diff --git a/OTRestFramework.xcodeproj/jeremy.pbxuser b/OTRestFramework.xcodeproj/jeremy.pbxuser deleted file mode 100644 index 4708145d..00000000 --- a/OTRestFramework.xcodeproj/jeremy.pbxuser +++ /dev/null @@ -1,51 +0,0 @@ -// !$*UTF8*$! -{ - 0867D690FE84028FC02AAC07 /* Project object */ = { - activeBuildConfigurationName = Debug; - activeTarget = D2AAC07D0554694100DB518D /* OTRestFramework */; - codeSenseManager = 3F4E187E102DD18F00320118 /* Code sense */; - perUserDictionary = { - PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { - PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; - PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; - PBXFileTableDataSourceColumnWidthsKey = ( - 20, - 341, - 20, - 48.16259765625, - 43, - 43, - 20, - ); - PBXFileTableDataSourceColumnsKey = ( - PBXFileDataSource_FiletypeID, - PBXFileDataSource_Filename_ColumnID, - PBXFileDataSource_Built_ColumnID, - PBXFileDataSource_ObjectSize_ColumnID, - PBXFileDataSource_Errors_ColumnID, - PBXFileDataSource_Warnings_ColumnID, - PBXFileDataSource_Target_ColumnID, - ); - }; - PBXPerProjectTemplateStateSaveDate = 271438212; - PBXWorkspaceStateSaveDate = 271438212; - }; - sourceControlManager = 3F4E187D102DD18F00320118 /* Source Control */; - userBuildSettings = { - }; - }; - 3F4E187D102DD18F00320118 /* Source Control */ = { - isa = PBXSourceControlManager; - fallbackIsa = XCSourceControlManager; - isSCMEnabled = 0; - scmConfiguration = { - }; - }; - 3F4E187E102DD18F00320118 /* Code sense */ = { - isa = PBXCodeSenseManager; - indexTemplatePath = ""; - }; - D2AAC07D0554694100DB518D /* OTRestFramework */ = { - activeExec = 0; - }; -} diff --git a/OTRestFramework.xcodeproj/project.pbxproj b/OTRestFramework.xcodeproj/project.pbxproj index ecfda21a..64ea1415 100644 --- a/OTRestFramework.xcodeproj/project.pbxproj +++ b/OTRestFramework.xcodeproj/project.pbxproj @@ -7,11 +7,101 @@ objects = { /* Begin PBXBuildFile section */ + 3F4E18F2102DD38800320118 /* OTRestClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E18E3102DD38700320118 /* OTRestClient.h */; }; + 3F4E18F3102DD38800320118 /* OTRestClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F4E18E4102DD38700320118 /* OTRestClient.m */; }; + 3F4E18F4102DD38800320118 /* OTRestParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E18E5102DD38700320118 /* OTRestParams.h */; }; + 3F4E18F5102DD38800320118 /* OTRestParams.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F4E18E6102DD38700320118 /* OTRestParams.m */; }; + 3F4E18F6102DD38800320118 /* OTRestParamsAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E18E7102DD38700320118 /* OTRestParamsAttachment.h */; }; + 3F4E18F7102DD38800320118 /* OTRestParamsAttachment.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F4E18E8102DD38700320118 /* OTRestParamsAttachment.m */; }; + 3F4E18F8102DD38800320118 /* OTRestParamsDataAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E18E9102DD38700320118 /* OTRestParamsDataAttachment.h */; }; + 3F4E18F9102DD38800320118 /* OTRestParamsDataAttachment.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F4E18EA102DD38700320118 /* OTRestParamsDataAttachment.m */; }; + 3F4E18FA102DD38800320118 /* OTRestParamsFileAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E18EB102DD38700320118 /* OTRestParamsFileAttachment.h */; }; + 3F4E18FB102DD38800320118 /* OTRestParamsFileAttachment.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F4E18EC102DD38700320118 /* OTRestParamsFileAttachment.m */; }; + 3F4E18FC102DD38800320118 /* OTRestRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E18ED102DD38700320118 /* OTRestRequest.h */; }; + 3F4E18FD102DD38800320118 /* OTRestRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F4E18EE102DD38700320118 /* OTRestRequest.m */; }; + 3F4E18FE102DD38800320118 /* OTRestRequestSerializable.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E18EF102DD38700320118 /* OTRestRequestSerializable.h */; }; + 3F4E18FF102DD38800320118 /* OTRestResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E18F0102DD38700320118 /* OTRestResponse.h */; }; + 3F4E1900102DD38800320118 /* OTRestResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F4E18F1102DD38800320118 /* OTRestResponse.m */; }; + 3F4E191A102DD42F00320118 /* NSDictionary+OTRestRequestSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E1918102DD42F00320118 /* NSDictionary+OTRestRequestSerialization.h */; }; + 3F4E191B102DD42F00320118 /* NSDictionary+OTRestRequestSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F4E1919102DD42F00320118 /* NSDictionary+OTRestRequestSerialization.m */; }; + 3F4E1936102DD4B300320118 /* CDataChunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E1925102DD4B300320118 /* CDataChunk.h */; }; + 3F4E1937102DD4B300320118 /* Chunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E1926102DD4B300320118 /* Chunk.h */; }; + 3F4E1938102DD4B300320118 /* CommentChunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E1927102DD4B300320118 /* CommentChunk.h */; }; + 3F4E1939102DD4B300320118 /* CSSPartMatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E1928102DD4B300320118 /* CSSPartMatcher.h */; }; + 3F4E193A102DD4B300320118 /* CSSSelector.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E1929102DD4B300320118 /* CSSSelector.h */; }; + 3F4E193B102DD4B300320118 /* CSSSelectorMatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E192A102DD4B300320118 /* CSSSelectorMatcher.h */; }; + 3F4E193C102DD4B300320118 /* CSSSelectorPart.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E192B102DD4B300320118 /* CSSSelectorPart.h */; }; + 3F4E193D102DD4B300320118 /* DoctypeChunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E192C102DD4B300320118 /* DoctypeChunk.h */; }; + 3F4E193E102DD4B300320118 /* DocumentRoot.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E192D102DD4B300320118 /* DocumentRoot.h */; }; + 3F4E193F102DD4B300320118 /* Element.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E192E102DD4B300320118 /* Element.h */; }; + 3F4E1940102DD4B300320118 /* ElementParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E192F102DD4B300320118 /* ElementParser.h */; }; + 3F4E1941102DD4B300320118 /* EntityChunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E1930102DD4B300320118 /* EntityChunk.h */; }; + 3F4E1942102DD4B300320118 /* NSString_HTML.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E1931102DD4B300320118 /* NSString_HTML.h */; }; + 3F4E1943102DD4B300320118 /* ProcessingInstructionChunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E1932102DD4B300320118 /* ProcessingInstructionChunk.h */; }; + 3F4E1944102DD4B300320118 /* TagChunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E1933102DD4B300320118 /* TagChunk.h */; }; + 3F4E1945102DD4B300320118 /* TxtChunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E1934102DD4B300320118 /* TxtChunk.h */; }; + 3F4E1946102DD4B300320118 /* URLParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E1935102DD4B300320118 /* URLParser.h */; }; + 3F4E194A102DD4C900320118 /* Element+OTRestAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F4E1948102DD4C900320118 /* Element+OTRestAdditions.h */; }; + 3F4E194B102DD4C900320118 /* Element+OTRestAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F4E1949102DD4C900320118 /* Element+OTRestAdditions.m */; }; AA747D9F0F9514B9006C5449 /* OTRestFramework_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* OTRestFramework_Prefix.pch */; }; AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + 3F4E18DA102DD31E00320118 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 3F4E18D6102DD31E00320118 /* ElementParser.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = D2AAC07E0554694100DB518D /* libElementParser.a */; + remoteInfo = ElementParser; + }; + 3F4E18DC102DD32A00320118 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 3F4E18D6102DD31E00320118 /* ElementParser.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = D2AAC07D0554694100DB518D /* ElementParser */; + remoteInfo = ElementParser; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXFileReference section */ + 3F4E18D6102DD31E00320118 /* ElementParser.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ElementParser.xcodeproj; path = ../ElementParser/ElementParser.xcodeproj; sourceTree = SOURCE_ROOT; }; + 3F4E18E3102DD38700320118 /* OTRestClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OTRestClient.h; sourceTree = SOURCE_ROOT; }; + 3F4E18E4102DD38700320118 /* OTRestClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OTRestClient.m; sourceTree = SOURCE_ROOT; }; + 3F4E18E5102DD38700320118 /* OTRestParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OTRestParams.h; sourceTree = SOURCE_ROOT; }; + 3F4E18E6102DD38700320118 /* OTRestParams.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OTRestParams.m; sourceTree = SOURCE_ROOT; }; + 3F4E18E7102DD38700320118 /* OTRestParamsAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OTRestParamsAttachment.h; sourceTree = SOURCE_ROOT; }; + 3F4E18E8102DD38700320118 /* OTRestParamsAttachment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OTRestParamsAttachment.m; sourceTree = SOURCE_ROOT; }; + 3F4E18E9102DD38700320118 /* OTRestParamsDataAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OTRestParamsDataAttachment.h; sourceTree = SOURCE_ROOT; }; + 3F4E18EA102DD38700320118 /* OTRestParamsDataAttachment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OTRestParamsDataAttachment.m; sourceTree = SOURCE_ROOT; }; + 3F4E18EB102DD38700320118 /* OTRestParamsFileAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OTRestParamsFileAttachment.h; sourceTree = SOURCE_ROOT; }; + 3F4E18EC102DD38700320118 /* OTRestParamsFileAttachment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OTRestParamsFileAttachment.m; sourceTree = SOURCE_ROOT; }; + 3F4E18ED102DD38700320118 /* OTRestRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OTRestRequest.h; sourceTree = SOURCE_ROOT; }; + 3F4E18EE102DD38700320118 /* OTRestRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OTRestRequest.m; sourceTree = SOURCE_ROOT; }; + 3F4E18EF102DD38700320118 /* OTRestRequestSerializable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OTRestRequestSerializable.h; sourceTree = SOURCE_ROOT; }; + 3F4E18F0102DD38700320118 /* OTRestResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OTRestResponse.h; sourceTree = SOURCE_ROOT; }; + 3F4E18F1102DD38800320118 /* OTRestResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OTRestResponse.m; sourceTree = SOURCE_ROOT; }; + 3F4E1918102DD42F00320118 /* NSDictionary+OTRestRequestSerialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+OTRestRequestSerialization.h"; sourceTree = SOURCE_ROOT; }; + 3F4E1919102DD42F00320118 /* NSDictionary+OTRestRequestSerialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+OTRestRequestSerialization.m"; sourceTree = SOURCE_ROOT; }; + 3F4E1925102DD4B300320118 /* CDataChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDataChunk.h; path = ../ElementParser/Classes/CDataChunk.h; sourceTree = SOURCE_ROOT; }; + 3F4E1926102DD4B300320118 /* Chunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Chunk.h; path = ../ElementParser/Classes/Chunk.h; sourceTree = SOURCE_ROOT; }; + 3F4E1927102DD4B300320118 /* CommentChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommentChunk.h; path = ../ElementParser/Classes/CommentChunk.h; sourceTree = SOURCE_ROOT; }; + 3F4E1928102DD4B300320118 /* CSSPartMatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSSPartMatcher.h; path = ../ElementParser/Classes/CSSPartMatcher.h; sourceTree = SOURCE_ROOT; }; + 3F4E1929102DD4B300320118 /* CSSSelector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSSSelector.h; path = ../ElementParser/Classes/CSSSelector.h; sourceTree = SOURCE_ROOT; }; + 3F4E192A102DD4B300320118 /* CSSSelectorMatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSSSelectorMatcher.h; path = ../ElementParser/Classes/CSSSelectorMatcher.h; sourceTree = SOURCE_ROOT; }; + 3F4E192B102DD4B300320118 /* CSSSelectorPart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSSSelectorPart.h; path = ../ElementParser/Classes/CSSSelectorPart.h; sourceTree = SOURCE_ROOT; }; + 3F4E192C102DD4B300320118 /* DoctypeChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DoctypeChunk.h; path = ../ElementParser/Classes/DoctypeChunk.h; sourceTree = SOURCE_ROOT; }; + 3F4E192D102DD4B300320118 /* DocumentRoot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DocumentRoot.h; path = ../ElementParser/Classes/DocumentRoot.h; sourceTree = SOURCE_ROOT; }; + 3F4E192E102DD4B300320118 /* Element.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Element.h; path = ../ElementParser/Classes/Element.h; sourceTree = SOURCE_ROOT; }; + 3F4E192F102DD4B300320118 /* ElementParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ElementParser.h; path = ../ElementParser/Classes/ElementParser.h; sourceTree = SOURCE_ROOT; }; + 3F4E1930102DD4B300320118 /* EntityChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EntityChunk.h; path = ../ElementParser/Classes/EntityChunk.h; sourceTree = SOURCE_ROOT; }; + 3F4E1931102DD4B300320118 /* NSString_HTML.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NSString_HTML.h; path = ../ElementParser/Classes/NSString_HTML.h; sourceTree = SOURCE_ROOT; }; + 3F4E1932102DD4B300320118 /* ProcessingInstructionChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ProcessingInstructionChunk.h; path = ../ElementParser/Classes/ProcessingInstructionChunk.h; sourceTree = SOURCE_ROOT; }; + 3F4E1933102DD4B300320118 /* TagChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TagChunk.h; path = ../ElementParser/Classes/TagChunk.h; sourceTree = SOURCE_ROOT; }; + 3F4E1934102DD4B300320118 /* TxtChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TxtChunk.h; path = ../ElementParser/Classes/TxtChunk.h; sourceTree = SOURCE_ROOT; }; + 3F4E1935102DD4B300320118 /* URLParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = URLParser.h; path = ../ElementParser/Classes/URLParser.h; sourceTree = SOURCE_ROOT; }; + 3F4E1948102DD4C900320118 /* Element+OTRestAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "Element+OTRestAdditions.h"; path = "../gateguru-iphone/Element+OTRestAdditions.h"; sourceTree = SOURCE_ROOT; }; + 3F4E1949102DD4C900320118 /* Element+OTRestAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "Element+OTRestAdditions.m"; path = "../gateguru-iphone/Element+OTRestAdditions.m"; sourceTree = SOURCE_ROOT; }; AA747D9E0F9514B9006C5449 /* OTRestFramework_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OTRestFramework_Prefix.pch; sourceTree = SOURCE_ROOT; }; AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; D2AAC07E0554694100DB518D /* libOTRestFramework.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libOTRestFramework.a; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -40,6 +130,8 @@ 0867D691FE84028FC02AAC07 /* OTRestFramework */ = { isa = PBXGroup; children = ( + 3F4E1924102DD4B300320118 /* ElementParserHeaders */, + 3F4E18D6102DD31E00320118 /* ElementParser.xcodeproj */, 08FB77AEFE84172EC02AAC07 /* Classes */, 32C88DFF0371C24200C91783 /* Other Sources */, 0867D69AFE84028FC02AAC07 /* Frameworks */, @@ -59,6 +151,25 @@ 08FB77AEFE84172EC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 3F4E1948102DD4C900320118 /* Element+OTRestAdditions.h */, + 3F4E1949102DD4C900320118 /* Element+OTRestAdditions.m */, + 3F4E1918102DD42F00320118 /* NSDictionary+OTRestRequestSerialization.h */, + 3F4E1919102DD42F00320118 /* NSDictionary+OTRestRequestSerialization.m */, + 3F4E18E3102DD38700320118 /* OTRestClient.h */, + 3F4E18E4102DD38700320118 /* OTRestClient.m */, + 3F4E18E5102DD38700320118 /* OTRestParams.h */, + 3F4E18E6102DD38700320118 /* OTRestParams.m */, + 3F4E18E7102DD38700320118 /* OTRestParamsAttachment.h */, + 3F4E18E8102DD38700320118 /* OTRestParamsAttachment.m */, + 3F4E18E9102DD38700320118 /* OTRestParamsDataAttachment.h */, + 3F4E18EA102DD38700320118 /* OTRestParamsDataAttachment.m */, + 3F4E18EB102DD38700320118 /* OTRestParamsFileAttachment.h */, + 3F4E18EC102DD38700320118 /* OTRestParamsFileAttachment.m */, + 3F4E18ED102DD38700320118 /* OTRestRequest.h */, + 3F4E18EE102DD38700320118 /* OTRestRequest.m */, + 3F4E18EF102DD38700320118 /* OTRestRequestSerializable.h */, + 3F4E18F0102DD38700320118 /* OTRestResponse.h */, + 3F4E18F1102DD38800320118 /* OTRestResponse.m */, ); name = Classes; sourceTree = ""; @@ -71,6 +182,38 @@ name = "Other Sources"; sourceTree = ""; }; + 3F4E18D7102DD31E00320118 /* Products */ = { + isa = PBXGroup; + children = ( + 3F4E18DB102DD31E00320118 /* libElementParser.a */, + ); + name = Products; + sourceTree = ""; + }; + 3F4E1924102DD4B300320118 /* ElementParserHeaders */ = { + isa = PBXGroup; + children = ( + 3F4E1925102DD4B300320118 /* CDataChunk.h */, + 3F4E1926102DD4B300320118 /* Chunk.h */, + 3F4E1927102DD4B300320118 /* CommentChunk.h */, + 3F4E1928102DD4B300320118 /* CSSPartMatcher.h */, + 3F4E1929102DD4B300320118 /* CSSSelector.h */, + 3F4E192A102DD4B300320118 /* CSSSelectorMatcher.h */, + 3F4E192B102DD4B300320118 /* CSSSelectorPart.h */, + 3F4E192C102DD4B300320118 /* DoctypeChunk.h */, + 3F4E192D102DD4B300320118 /* DocumentRoot.h */, + 3F4E192E102DD4B300320118 /* Element.h */, + 3F4E192F102DD4B300320118 /* ElementParser.h */, + 3F4E1930102DD4B300320118 /* EntityChunk.h */, + 3F4E1931102DD4B300320118 /* NSString_HTML.h */, + 3F4E1932102DD4B300320118 /* ProcessingInstructionChunk.h */, + 3F4E1933102DD4B300320118 /* TagChunk.h */, + 3F4E1934102DD4B300320118 /* TxtChunk.h */, + 3F4E1935102DD4B300320118 /* URLParser.h */, + ); + name = ElementParserHeaders; + sourceTree = SOURCE_ROOT; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -79,6 +222,33 @@ buildActionMask = 2147483647; files = ( AA747D9F0F9514B9006C5449 /* OTRestFramework_Prefix.pch in Headers */, + 3F4E18F2102DD38800320118 /* OTRestClient.h in Headers */, + 3F4E18F4102DD38800320118 /* OTRestParams.h in Headers */, + 3F4E18F6102DD38800320118 /* OTRestParamsAttachment.h in Headers */, + 3F4E18F8102DD38800320118 /* OTRestParamsDataAttachment.h in Headers */, + 3F4E18FA102DD38800320118 /* OTRestParamsFileAttachment.h in Headers */, + 3F4E18FC102DD38800320118 /* OTRestRequest.h in Headers */, + 3F4E18FE102DD38800320118 /* OTRestRequestSerializable.h in Headers */, + 3F4E18FF102DD38800320118 /* OTRestResponse.h in Headers */, + 3F4E191A102DD42F00320118 /* NSDictionary+OTRestRequestSerialization.h in Headers */, + 3F4E1936102DD4B300320118 /* CDataChunk.h in Headers */, + 3F4E1937102DD4B300320118 /* Chunk.h in Headers */, + 3F4E1938102DD4B300320118 /* CommentChunk.h in Headers */, + 3F4E1939102DD4B300320118 /* CSSPartMatcher.h in Headers */, + 3F4E193A102DD4B300320118 /* CSSSelector.h in Headers */, + 3F4E193B102DD4B300320118 /* CSSSelectorMatcher.h in Headers */, + 3F4E193C102DD4B300320118 /* CSSSelectorPart.h in Headers */, + 3F4E193D102DD4B300320118 /* DoctypeChunk.h in Headers */, + 3F4E193E102DD4B300320118 /* DocumentRoot.h in Headers */, + 3F4E193F102DD4B300320118 /* Element.h in Headers */, + 3F4E1940102DD4B300320118 /* ElementParser.h in Headers */, + 3F4E1941102DD4B300320118 /* EntityChunk.h in Headers */, + 3F4E1942102DD4B300320118 /* NSString_HTML.h in Headers */, + 3F4E1943102DD4B300320118 /* ProcessingInstructionChunk.h in Headers */, + 3F4E1944102DD4B300320118 /* TagChunk.h in Headers */, + 3F4E1945102DD4B300320118 /* TxtChunk.h in Headers */, + 3F4E1946102DD4B300320118 /* URLParser.h in Headers */, + 3F4E194A102DD4C900320118 /* Element+OTRestAdditions.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -96,6 +266,7 @@ buildRules = ( ); dependencies = ( + 3F4E18DD102DD32A00320118 /* PBXTargetDependency */, ); name = OTRestFramework; productName = OTRestFramework; @@ -113,6 +284,12 @@ mainGroup = 0867D691FE84028FC02AAC07 /* OTRestFramework */; productRefGroup = 034768DFFF38A50411DB9C8B /* Products */; projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 3F4E18D7102DD31E00320118 /* Products */; + ProjectRef = 3F4E18D6102DD31E00320118 /* ElementParser.xcodeproj */; + }, + ); projectRoot = ""; targets = ( D2AAC07D0554694100DB518D /* OTRestFramework */, @@ -120,16 +297,43 @@ }; /* End PBXProject section */ +/* Begin PBXReferenceProxy section */ + 3F4E18DB102DD31E00320118 /* libElementParser.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libElementParser.a; + remoteRef = 3F4E18DA102DD31E00320118 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + /* Begin PBXSourcesBuildPhase section */ D2AAC07B0554694100DB518D /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 3F4E18F3102DD38800320118 /* OTRestClient.m in Sources */, + 3F4E18F5102DD38800320118 /* OTRestParams.m in Sources */, + 3F4E18F7102DD38800320118 /* OTRestParamsAttachment.m in Sources */, + 3F4E18F9102DD38800320118 /* OTRestParamsDataAttachment.m in Sources */, + 3F4E18FB102DD38800320118 /* OTRestParamsFileAttachment.m in Sources */, + 3F4E18FD102DD38800320118 /* OTRestRequest.m in Sources */, + 3F4E1900102DD38800320118 /* OTRestResponse.m in Sources */, + 3F4E191B102DD42F00320118 /* NSDictionary+OTRestRequestSerialization.m in Sources */, + 3F4E194B102DD4C900320118 /* Element+OTRestAdditions.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + 3F4E18DD102DD32A00320118 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = ElementParser; + targetProxy = 3F4E18DC102DD32A00320118 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin XCBuildConfiguration section */ 1DEB921F08733DC00010E9CD /* Debug */ = { isa = XCBuildConfiguration; diff --git a/OTRestParams.h b/OTRestParams.h new file mode 100644 index 00000000..d010e22c --- /dev/null +++ b/OTRestParams.h @@ -0,0 +1,69 @@ +// +// OTRestParams.h +// gateguru +// +// Created by Blake Watters on 8/3/09. +// Copyright 2009 Objective 3. All rights reserved. +// + +#import +#import "OTRestRequestSerializable.h" +#import "OTRestParamsFileAttachment.h" +#import "OTRestParamsDataAttachment.h" + +@interface OTRestParams : NSObject { + NSMutableDictionary* _valueData; + NSMutableDictionary* _fileData; +} + +/** + * Returns an empty params object ready for population + */ ++ (OTRestParams*)params; + +/** + * Initialize a params object from a dictionary of key/value pairs + */ ++ (OTRestParams*)paramsWithDictionary:(NSDictionary*)dictionary; + +/** + * Initalize a params object from a dictionary of key/value pairs + */ +- (OTRestParams*)initWithDictionary:(NSDictionary*)dictionary; + +/** + * Sets the value for a named parameter + */ +- (void)setValue:(id )value forParam:(NSString*)param; + +/** + * Sets the value for a named parameter to the data contained in a file at the given path + */ +- (OTRestParamsFileAttachment*)setFile:(NSString*)filePath forParam:(NSString*)param; + +/** + * Sets the value for a named parameter to the data contained in a file at the given path with the specified MIME Type and attachment file name + */ +- (OTRestParamsFileAttachment*)setFile:(NSString*)filePath MIMEType:(NSString*)MIMEType fileName:(NSString*)fileName forParam:(NSString*)param; + +/** + * Sets the value to the data object for a named parameter + */ +- (OTRestParamsDataAttachment*)setData:(NSData*)data forParam:(NSString*)param; + +/** + * Sets the value for a named parameter to a data object with the specified MIME Type and attachment file name + */ +- (OTRestParamsDataAttachment*)setData:(NSData*)data MIMEType:(NSString*)MIMEType fileName:(NSString*)fileName forParam:(NSString*)param; + +/** + * Returns the value for the Content-Type header for these params + */ +- (NSString*)ContentTypeHTTPHeader; + +/** + * Returns the data contained in this params object as a MIME string + */ +- (NSData*)HTTPBody; + +@end diff --git a/OTRestParams.m b/OTRestParams.m new file mode 100644 index 00000000..8e2f76b1 --- /dev/null +++ b/OTRestParams.m @@ -0,0 +1,139 @@ +// +// OTRestParams.m +// gateguru +// +// Created by Blake Watters on 8/3/09. +// Copyright 2009 Objective 3. All rights reserved. +// + +#import "OTRestParams.h" + +static NSString* kOTRestStringBoundary = @"0xKhTmLbOuNdArY"; + +@implementation OTRestParams + ++ (OTRestParams*)params { + OTRestParams* params = [[[OTRestParams alloc] init] autorelease]; + return params; +} + ++ (OTRestParams*)paramsWithDictionary:(NSDictionary*)dictionary { + OTRestParams* params = [[[OTRestParams alloc] initWithDictionary:dictionary] autorelease]; + return params; +} + +- (id)init { + if (self = [super init]) { + _valueData = [[NSMutableDictionary alloc] init]; + _fileData = [[NSMutableDictionary alloc] init]; + } + + return self; +} + +- (void)dealloc { + [_valueData release]; + [_fileData release]; + [super dealloc]; +} + +- (OTRestParams*)initWithDictionary:(NSDictionary*)dictionary { + if (self = [super init]) { + _valueData = [[NSMutableDictionary dictionaryWithDictionary:dictionary] retain]; + _fileData = [[NSMutableDictionary alloc] init]; + } + + return self; +} + + +- (void)setValue:(id )value forParam:(NSString*)param { + [_valueData setObject:value forKey:param]; +} + +- (OTRestParamsFileAttachment*)setFile:(NSString*)filePath forParam:(NSString*)param { + OTRestParamsFileAttachment* attachment = [OTRestParamsFileAttachment attachment]; + attachment.filePath = filePath; + [_fileData setObject:attachment forKey:param]; + return attachment; +} + +- (OTRestParamsFileAttachment*)setFile:(NSString*)filePath MIMEType:(NSString*)MIMEType fileName:(NSString*)fileName forParam:(NSString*)param { + OTRestParamsFileAttachment* attachment = [self setFile:filePath forParam:param]; + if (MIMEType != nil) { + attachment.MIMEType = MIMEType; + } + if (fileName != nil) { + attachment.fileName = fileName; + } + return attachment; +} + +- (OTRestParamsDataAttachment*)setData:(NSData*)data forParam:(NSString*)param { + OTRestParamsDataAttachment* attachment = [OTRestParamsDataAttachment attachment]; + attachment.data = data; + [_fileData setObject:attachment forKey:param]; + return attachment; +} + +- (OTRestParamsDataAttachment*)setData:(NSData*)data MIMEType:(NSString*)MIMEType fileName:(NSString*)fileName forParam:(NSString*)param { + OTRestParamsDataAttachment* attachment = [self setData:data forParam:param]; + if (MIMEType != nil) { + attachment.MIMEType = MIMEType; + } + if (fileName != nil) { + attachment.fileName = fileName; + } + return attachment; +} + +- (NSData*)endItemBoundary { + return [[NSString stringWithFormat:@"\r\n--%@\r\n", kOTRestStringBoundary] dataUsingEncoding:NSUTF8StringEncoding]; +} + +- (void)addValuesToHTTPBody:(NSMutableData*)HTTPBody { + int i = 0; + for (id key in _valueData) { + id value = [_valueData valueForKey:key]; + [HTTPBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", key] dataUsingEncoding:NSUTF8StringEncoding]]; + [HTTPBody appendData:[value dataUsingEncoding:NSUTF8StringEncoding]]; + i++; + + // Only add the boundary if this is not the last item in the post body + if (i != [_valueData count] || [_fileData count] > 0) { + [HTTPBody appendData:[self endItemBoundary]]; + } + } +} + +- (void)addAttachmentsToHTTPBody:(NSMutableData*)HTTPBody { + int i = 0; + for (id key in _fileData) { + OTRestParamsAttachment* attachment = (OTRestParamsAttachment*) [_fileData valueForKey:key]; + [HTTPBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", key, attachment.fileName] dataUsingEncoding:NSUTF8StringEncoding]]; + [HTTPBody appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n\r\n", attachment.MIMEType] dataUsingEncoding:NSUTF8StringEncoding]]; + [attachment writeAttachmentToHTTPBody:HTTPBody]; + i++; + + if (i != [_fileData count]) { + [HTTPBody appendData:[self endItemBoundary]]; + } + } +} + +- (NSData*)HTTPBody { + NSMutableData* HTTPBody = [NSMutableData data]; + + [HTTPBody appendData:[[NSString stringWithFormat:@"--%@\r\n", kOTRestStringBoundary] dataUsingEncoding:NSUTF8StringEncoding]]; + [self addValuesToHTTPBody:HTTPBody]; + [self addAttachmentsToHTTPBody:HTTPBody]; + [HTTPBody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", kOTRestStringBoundary] dataUsingEncoding:NSUTF8StringEncoding]]; + + return HTTPBody; +} + +- (NSString*)ContentTypeHTTPHeader { + return [NSString stringWithFormat:@"multipart/form-data; boundary=%@", kOTRestStringBoundary]; +} + +@end diff --git a/OTRestParamsAttachment.h b/OTRestParamsAttachment.h new file mode 100644 index 00000000..6a97b824 --- /dev/null +++ b/OTRestParamsAttachment.h @@ -0,0 +1,38 @@ +// +// OTRestParamsAttachment.h +// gateguru +// +// Created by Blake Watters on 8/6/09. +// Copyright 2009 Objective 3. All rights reserved. +// + +#import + +@interface OTRestParamsAttachment : NSObject { + NSString* _fileName; + NSString* _MIMEType; +} + +/** + * The name of the attached file in the MIME stream + * Defaults to 'file' if not specified + */ +@property (nonatomic, retain) NSString* fileName; + +/** + * The MIME type of the attached file in the MIME stream + * Defaults to 'application/octet-stream' if not specified + */ +@property (nonatomic, retain) NSString* MIMEType; + +/** + * Returns an autoreleased attachment object + */ ++ (id)attachment; + +/** + * Abstract method implementing writing this attachment into an HTTP stream + */ +- (void)writeAttachmentToHTTPBody:(NSMutableData*)HTTPBody; + +@end diff --git a/OTRestParamsAttachment.m b/OTRestParamsAttachment.m new file mode 100644 index 00000000..45254993 --- /dev/null +++ b/OTRestParamsAttachment.m @@ -0,0 +1,38 @@ +// +// OTRestAttachment.m +// gateguru +// +// Created by Blake Watters on 8/6/09. +// Copyright 2009 Objective 3. All rights reserved. +// + +#import "OTRestParamsAttachment.h" + +@implementation OTRestParamsAttachment + +@synthesize fileName = _fileName, MIMEType = _MIMEType; + ++ (id)attachment { + return [[[self alloc] init] autorelease]; +} + +- (id)init { + if (self = [super init]) { + self.fileName = @"file"; + self.MIMEType = @"application/octet-stream"; + } + + return self; +} + +- (void)dealloc { + [_fileName release]; + [_MIMEType release]; + [super dealloc]; +} + +- (void)writeAttachmentToHTTPBody:(NSMutableData*)HTTPBody { + [self doesNotRecognizeSelector:_cmd]; +} + +@end diff --git a/OTRestParamsDataAttachment.h b/OTRestParamsDataAttachment.h new file mode 100644 index 00000000..638e6240 --- /dev/null +++ b/OTRestParamsDataAttachment.h @@ -0,0 +1,20 @@ +// +// OTRestParamsDataAttachment.h +// gateguru +// +// Created by Blake Watters on 8/6/09. +// Copyright 2009 Objective 3. All rights reserved. +// + +#import "OTRestParamsAttachment.h" + +@interface OTRestParamsDataAttachment : OTRestParamsAttachment { + NSData* _data; +} + +/** + * The data being attached to the MIME stream + */ +@property (nonatomic, retain) NSData* data; + +@end diff --git a/OTRestParamsDataAttachment.m b/OTRestParamsDataAttachment.m new file mode 100644 index 00000000..62b739d8 --- /dev/null +++ b/OTRestParamsDataAttachment.m @@ -0,0 +1,27 @@ +// +// OTRestParamsDataAttachment.m +// gateguru +// +// Created by Blake Watters on 8/6/09. +// Copyright 2009 Objective 3. All rights reserved. +// + +#import "OTRestParamsDataAttachment.h" + +@implementation OTRestParamsDataAttachment + +@synthesize data = _data; + +- (void)dealloc { + [_data release]; + [super dealloc]; +} + +- (void)writeAttachmentToHTTPBody:(NSMutableData*)HTTPBody { + if ([_data length] == 0) { + return; + } + [HTTPBody appendData:_data]; +} + +@end diff --git a/OTRestParamsFileAttachment.h b/OTRestParamsFileAttachment.h new file mode 100644 index 00000000..36ebc104 --- /dev/null +++ b/OTRestParamsFileAttachment.h @@ -0,0 +1,20 @@ +// +// OTRestParamsFileAttachment.h +// gateguru +// +// Created by Blake Watters on 8/6/09. +// Copyright 2009 Objective 3. All rights reserved. +// + +#import "OTRestParamsAttachment.h" + +@interface OTRestParamsFileAttachment : OTRestParamsAttachment { + NSString* _filePath; +} + +/** + * The path to this file attachment on disk + */ +@property (nonatomic, retain) NSString* filePath; + +@end diff --git a/OTRestParamsFileAttachment.m b/OTRestParamsFileAttachment.m new file mode 100644 index 00000000..f8333f06 --- /dev/null +++ b/OTRestParamsFileAttachment.m @@ -0,0 +1,35 @@ +// +// OTRestParamsFileAttachment.m +// gateguru +// +// Created by Blake Watters on 8/6/09. +// Copyright 2009 Objective 3. All rights reserved. +// + +#import "OTRestParamsFileAttachment.h" + +@implementation OTRestParamsFileAttachment + +@synthesize filePath = _filePath; + +- (void)dealloc { + [_filePath release]; + [super dealloc]; +} + +- (void)writeAttachmentToHTTPBody:(NSMutableData*)HTTPBody { + NSInputStream *stream = [[[NSInputStream alloc] initWithFileAtPath:_filePath] autorelease]; + [stream open]; + int bytesRead; + while ([stream hasBytesAvailable]) { + unsigned char buffer[1024*256]; + bytesRead = [stream read:buffer maxLength:sizeof(buffer)]; + if (bytesRead == 0) { + break; + } + [HTTPBody appendData:[NSData dataWithBytes:buffer length:bytesRead]]; + } + [stream close]; +} + +@end diff --git a/OTRestRequest.h b/OTRestRequest.h new file mode 100644 index 00000000..041b9bd3 --- /dev/null +++ b/OTRestRequest.h @@ -0,0 +1,88 @@ +// +// OTRestRequest.h +// gateguru +// +// Created by Jeremy Ellison on 7/27/09. +// Copyright 2009 Objective3. All rights reserved. +// + +#import +#import "DocumentRoot.h" +#import "OTRestRequestSerializable.h" + +@interface OTRestRequest : NSObject { + NSURL* _URL; + NSMutableURLRequest* _URLRequest; + NSDictionary* _additionalHTTPHeaders; + NSObject* _params; + id _delegate; + SEL _callback; +} + +@property(nonatomic, readonly) NSURL* URL; + +/** + * The NSMutableURLRequest being sent for the Restful request + */ +@property(nonatomic, readonly) NSMutableURLRequest* URLRequest; + +/** + * The HTTP Method used for this request + */ +@property(nonatomic, readonly) NSString* HTTPMethod; + +/** + * The delegate to inform when the request is completed + */ +@property(nonatomic, retain) id delegate; + +/** + * The selector to invoke when the request is completed + */ +@property(nonatomic, assign) SEL callback; + +/** + * A Dictionary of additional HTTP Headers to send with the request + */ +@property(nonatomic, retain) NSDictionary* additionalHTTPHeaders; + +/** + * A serializable collection of parameters sent as the HTTP Body of the request + */ +@property(nonatomic, readonly) NSObject* params; + + +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + +/** + * Return a REST request that is ready for dispatching + */ ++ (OTRestRequest*)requestWithURL:(NSURL*)URL delegate:(id)delegate callback:(SEL)callback; + +/** + * Initialize a REST request and prepare it for dispatching + */ +- (id)initWithURL:(NSURL*)URL delegate:(id)delegate callback:(SEL)callback; + +/** + * GET the resource and invoke the callback with the response payload + */ +- (void)get; + +/** + * POST a collection of params to the resource and invoke the callback with the response payload + */ +- (void)postParams:(NSObject*)params; + +/** + * PUT a collection of params to the resource and invoke the callback with the response payload + */ +- (void)putParams:(NSObject*)params; + +/** + * DELETE the resource and invoke the callback with the response payload + */ +- (void)delete; + +@end diff --git a/OTRestRequest.m b/OTRestRequest.m new file mode 100644 index 00000000..fcf11cd4 --- /dev/null +++ b/OTRestRequest.m @@ -0,0 +1,96 @@ +// +// OTRestRequest.m +// gateguru +// +// Created by Jeremy Ellison on 7/27/09. +// Copyright 2009 Objective3. All rights reserved. +// + +#import "OTRestRequest.h" +#import "OTRestResponse.h" +#import "NSDictionary+OTRestRequestSerialization.h" + +@implementation OTRestRequest + +@synthesize URL = _URL, URLRequest = _URLRequest, delegate = _delegate, callback = _callback, additionalHTTPHeaders = _additionalHTTPHeaders, + params = _params; + ++ (OTRestRequest*)requestWithURL:(NSURL*)URL delegate:(id)delegate callback:(SEL)callback { + OTRestRequest* request = [[OTRestRequest alloc] initWithURL:URL delegate:delegate callback:callback]; + [request autorelease]; + + return request; +} + +- (id)initWithURL:(NSURL*)URL delegate:(id)delegate callback:(SEL)callback { + if (self = [self init]) { + _URL = [URL retain]; + _URLRequest = [[NSMutableURLRequest alloc] initWithURL:_URL]; + _delegate = [delegate retain]; + _callback = callback; + } + + return self; +} + +- (void)dealloc { + [_URL release]; + [_URLRequest release]; + [_delegate release]; + [_params release]; + [_additionalHTTPHeaders release]; + [super dealloc]; +} + +- (NSString*)HTTPMethod { + return [_URLRequest HTTPMethod]; +} + +- (void)addHeadersToRequest { + NSString* header; + for (header in _additionalHTTPHeaders) { + [_URLRequest setValue:[_additionalHTTPHeaders valueForKey:header] forHTTPHeaderField:header]; + } + if (_params != nil) { + [_URLRequest setValue:[_params ContentTypeHTTPHeader] forHTTPHeaderField:@"Content-Type"]; + } + NSLog(@"Headers: %@", [_URLRequest allHTTPHeaderFields]); +} + +- (void)send { + NSString* body = [[NSString alloc] initWithData:[_URLRequest HTTPBody] encoding:NSUTF8StringEncoding]; + NSLog(@"Sending %@ request to URL %@. HTTP Body: %@", [self HTTPMethod], [[self URL] absoluteString], body); + [body release]; + OTRestResponse* response = [[OTRestResponse alloc] initWithRestRequest:self]; + [[NSURLConnection connectionWithRequest:_URLRequest delegate:response] retain]; +} + +- (void)get { + [_URLRequest setHTTPMethod:@"GET"]; + [self addHeadersToRequest]; + [self send]; +} + +- (void)postParams:(NSObject*)params { + [_URLRequest setHTTPMethod:@"POST"]; + _params = [params retain]; + [_URLRequest setHTTPBody:[_params HTTPBody]]; + [self addHeadersToRequest]; + [self send]; +} + +- (void)putParams:(NSObject*)params { + [_URLRequest setHTTPMethod:@"PUT"]; + _params = [params retain]; + [_URLRequest setHTTPBody:[_params HTTPBody]]; + [self addHeadersToRequest]; + [self send]; +} + +- (void)delete { + [_URLRequest setHTTPMethod:@"DELETE"]; + [self addHeadersToRequest]; + [self send]; +} + +@end diff --git a/OTRestRequestSerializable.h b/OTRestRequestSerializable.h new file mode 100644 index 00000000..a86e5b25 --- /dev/null +++ b/OTRestRequestSerializable.h @@ -0,0 +1,26 @@ +// +// OTRestRequestSerializable.h +// gateguru +// +// Created by Blake Watters on 8/3/09. +// Copyright 2009 Objective 3. All rights reserved. +// + +/* + * This protocol is implemented by objects that can be serialized into a representation suitable + * for transmission over a REST request. Suitable serializations are x-www-form-urlencoded and + * multipart/form-data. + */ +@protocol OTRestRequestSerializable + +/** + * The value of the Content-Type header for the HTTP Body representation of the serialization + */ +- (NSString*)ContentTypeHTTPHeader; + +/** + * An NSData representing the HTTP Body serialization of the object implementing the protocol + */ +- (NSData*)HTTPBody; + +@end diff --git a/OTRestResponse.h b/OTRestResponse.h new file mode 100644 index 00000000..dfd166f9 --- /dev/null +++ b/OTRestResponse.h @@ -0,0 +1,69 @@ +// +// OTRestResponse.h +// gateguru +// +// Created by Blake Watters on 7/28/09. +// Copyright 2009 Objective 3. All rights reserved. +// + +#import +#import "OTRestRequest.h" +#import "DocumentRoot.h" + +@interface OTRestResponse : NSObject { + OTRestRequest* _request; + NSHTTPURLResponse* _httpURLResponse; + NSMutableData* _payload; +} + +/** + * The request that generated this response + */ +@property(nonatomic, readonly) OTRestRequest* request; + +/** + * The URL the response was loaded from + */ +@property(nonatomic, readonly) NSURL* URL; + +/** + * The MIME Type of the response payload + */ +@property(nonatomic, readonly) NSString* MIMEType; + +/** + * The status code of the HTTP response + */ +@property(nonatomic, readonly) NSInteger statusCode; + +/** + * Return a dictionary of headers sent with the HTTP response + */ +@property(nonatomic, readonly) NSDictionary* allHeaderFields; + +/** + * The data returned as the response payload + */ +@property(nonatomic, readonly) NSData* payload; + +/** + * Initialize a new response object for a REST request + */ +- (OTRestResponse*)initWithRestRequest:(OTRestRequest*)request; + +/** + * Return the localized human readable representation of the HTTP Status Code returned + */ +- (NSString*)localizedStatusCodeString; + +/** + * Return the response payload as an NSString + */ +- (NSString*)payloadString; + +/** + * Parse the response payload into an XML Document via ElementParser + */ +- (DocumentRoot*)payloadXMLDocument; + +@end diff --git a/OTRestResponse.m b/OTRestResponse.m new file mode 100644 index 00000000..dec3d6e1 --- /dev/null +++ b/OTRestResponse.m @@ -0,0 +1,79 @@ +// +// OTRestResponse.m +// gateguru +// +// Created by Blake Watters on 7/28/09. +// Copyright 2009 Objective 3. All rights reserved. +// + +#import "OTRestResponse.h" + +@implementation OTRestResponse + +@synthesize payload = _payload, request = _request; + +- (id)init { + if (self = [super init]) { + _payload = [[NSMutableData alloc] init]; + } + + return self; +} + +- (id)initWithRestRequest:(OTRestRequest*)request { + if (self = [self init]) { + _request = [request retain]; + } + + return self; +} + +- (void)dealloc { + [_httpURLResponse release]; + [_payload release]; + [_request release]; + [super dealloc]; +} + +- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { + [_payload appendData:data]; +} + +- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSHTTPURLResponse *)response { + _httpURLResponse = [response retain]; +} + +- (void)connectionDidFinishLoading:(NSURLConnection *)connection { + [connection release]; + [[_request delegate] performSelector:[_request callback] withObject:self]; +} + +- (NSString*)localizedStatusCodeString { + return [NSHTTPURLResponse localizedStringForStatusCode:[self statusCode]]; +} + +- (NSString*)payloadString { + return [[[NSString alloc] initWithData:_payload encoding:NSUTF8StringEncoding] autorelease]; +} + +- (DocumentRoot*)payloadXMLDocument { + return [DocumentRoot parseXML:[self payloadString]]; +} + +- (NSURL*)URL { + return [_httpURLResponse URL]; +} + +- (NSString*)MIMEType { + return [_httpURLResponse MIMEType]; +} + +- (NSInteger)statusCode { + return [_httpURLResponse statusCode]; +} + +- (NSDictionary*)allHeaderFields { + return [_httpURLResponse allHeaderFields]; +} + +@end diff --git a/build/OTRestFramework.build/OTRestFramework.pbxindex/categories.pbxbtree b/build/OTRestFramework.build/OTRestFramework.pbxindex/categories.pbxbtree index d3f6bb3b..b2bb1d60 100644 Binary files a/build/OTRestFramework.build/OTRestFramework.pbxindex/categories.pbxbtree and b/build/OTRestFramework.build/OTRestFramework.pbxindex/categories.pbxbtree differ diff --git a/build/OTRestFramework.build/OTRestFramework.pbxindex/cdecls.pbxbtree b/build/OTRestFramework.build/OTRestFramework.pbxindex/cdecls.pbxbtree index 5fb938ed..a41b165a 100644 Binary files a/build/OTRestFramework.build/OTRestFramework.pbxindex/cdecls.pbxbtree and b/build/OTRestFramework.build/OTRestFramework.pbxindex/cdecls.pbxbtree differ diff --git a/build/OTRestFramework.build/OTRestFramework.pbxindex/decls.pbxbtree b/build/OTRestFramework.build/OTRestFramework.pbxindex/decls.pbxbtree index 5fb938ed..4352579a 100644 Binary files a/build/OTRestFramework.build/OTRestFramework.pbxindex/decls.pbxbtree and b/build/OTRestFramework.build/OTRestFramework.pbxindex/decls.pbxbtree differ diff --git a/build/OTRestFramework.build/OTRestFramework.pbxindex/files.pbxbtree b/build/OTRestFramework.build/OTRestFramework.pbxindex/files.pbxbtree index bdfbdb91..afb30091 100644 Binary files a/build/OTRestFramework.build/OTRestFramework.pbxindex/files.pbxbtree and b/build/OTRestFramework.build/OTRestFramework.pbxindex/files.pbxbtree differ diff --git a/build/OTRestFramework.build/OTRestFramework.pbxindex/imports.pbxbtree b/build/OTRestFramework.build/OTRestFramework.pbxindex/imports.pbxbtree index 73067540..47538528 100644 Binary files a/build/OTRestFramework.build/OTRestFramework.pbxindex/imports.pbxbtree and b/build/OTRestFramework.build/OTRestFramework.pbxindex/imports.pbxbtree differ diff --git a/build/OTRestFramework.build/OTRestFramework.pbxindex/pbxindex.header b/build/OTRestFramework.build/OTRestFramework.pbxindex/pbxindex.header index 493d0444..09209aed 100644 Binary files a/build/OTRestFramework.build/OTRestFramework.pbxindex/pbxindex.header and b/build/OTRestFramework.build/OTRestFramework.pbxindex/pbxindex.header differ diff --git a/build/OTRestFramework.build/OTRestFramework.pbxindex/protocols.pbxbtree b/build/OTRestFramework.build/OTRestFramework.pbxindex/protocols.pbxbtree index d3f6bb3b..869dbfd9 100644 Binary files a/build/OTRestFramework.build/OTRestFramework.pbxindex/protocols.pbxbtree and b/build/OTRestFramework.build/OTRestFramework.pbxindex/protocols.pbxbtree differ diff --git a/build/OTRestFramework.build/OTRestFramework.pbxindex/refs.pbxbtree b/build/OTRestFramework.build/OTRestFramework.pbxindex/refs.pbxbtree index 89bb0257..ea95d713 100644 Binary files a/build/OTRestFramework.build/OTRestFramework.pbxindex/refs.pbxbtree and b/build/OTRestFramework.build/OTRestFramework.pbxindex/refs.pbxbtree differ diff --git a/build/OTRestFramework.build/OTRestFramework.pbxindex/strings.pbxstrings/control b/build/OTRestFramework.build/OTRestFramework.pbxindex/strings.pbxstrings/control index cf750af5..91f4720d 100644 Binary files a/build/OTRestFramework.build/OTRestFramework.pbxindex/strings.pbxstrings/control and b/build/OTRestFramework.build/OTRestFramework.pbxindex/strings.pbxstrings/control differ diff --git a/build/OTRestFramework.build/OTRestFramework.pbxindex/strings.pbxstrings/strings b/build/OTRestFramework.build/OTRestFramework.pbxindex/strings.pbxstrings/strings index 11937445..62152386 100644 Binary files a/build/OTRestFramework.build/OTRestFramework.pbxindex/strings.pbxstrings/strings and b/build/OTRestFramework.build/OTRestFramework.pbxindex/strings.pbxstrings/strings differ diff --git a/build/OTRestFramework.build/OTRestFramework.pbxindex/subclasses.pbxbtree b/build/OTRestFramework.build/OTRestFramework.pbxindex/subclasses.pbxbtree index 124d1575..48e6f21b 100644 Binary files a/build/OTRestFramework.build/OTRestFramework.pbxindex/subclasses.pbxbtree and b/build/OTRestFramework.build/OTRestFramework.pbxindex/subclasses.pbxbtree differ