Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs in authorization process #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
xcuserdata
xcshareddata
*.xcuserstate
*.DS_Store

42 changes: 39 additions & 3 deletions EEAPI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@
objects = {

/* Begin PBXBuildFile section */
40C4AFA61B24E071003B6C88 /* EERequest.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 922F59F216073DD40088F2CA /* EERequest.h */; };
40C4AFA71B24E11F003B6C88 /* EEAlbumsQuery.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 92DD4B8F1612178900B350A4 /* EEAlbumsQuery.h */; };
40C4AFA81B24E11F003B6C88 /* EEUsersQuery.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 92DD4B921612179600B350A4 /* EEUsersQuery.h */; };
40C4AFA91B24E11F003B6C88 /* EEPhotosQuery.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 92DD4B95161217A800B350A4 /* EEPhotosQuery.h */; };
40C4AFAA1B24E11F003B6C88 /* EENewsQuery.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 92DD4B98161217BB00B350A4 /* EENewsQuery.h */; };
40C4AFAB1B24E11F003B6C88 /* EETopicsQuery.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 92DD4B9B16121B1300B350A4 /* EETopicsQuery.h */; };
40C4AFAC1B24E11F003B6C88 /* EESearchQuery.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 92DD4B9E16121B4000B350A4 /* EESearchQuery.h */; };
40C4AFAD1B24E11F003B6C88 /* EEVenuesQuery.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 92DD4BA116121B5300B350A4 /* EEVenuesQuery.h */; };
40C4AFAE1B24E11F003B6C88 /* EEComment.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 929194221609B9C300625402 /* EEComment.h */; };
40C4AFAF1B24E11F003B6C88 /* EEAlbum.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9291941F1608D94300625402 /* EEAlbum.h */; };
40C4AFB01B24E11F003B6C88 /* EEUser.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9291941C1608D92900625402 /* EEUser.h */; };
40C4AFB11B24E11F003B6C88 /* EEOAuthUser.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 92919446160A157400625402 /* EEOAuthUser.h */; };
40C4AFB21B24E11F003B6C88 /* EELocation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 929194281609C5B600625402 /* EELocation.h */; };
40C4AFB31B24E11F003B6C88 /* EEPhoto.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 929194171608D8F100625402 /* EEPhoto.h */; };
40C4AFB41B24E11F003B6C88 /* EENews.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9263F29B160B28A10018A4DB /* EENews.h */; };
40C4AFB51B24E127003B6C88 /* EEQuery.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9263F28F160B1C250018A4DB /* EEQuery.h */; };
922F59E216072DDF0088F2CA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 922F59E116072DDF0088F2CA /* Foundation.framework */; };
922F59E716072DDF0088F2CA /* EyeEmAPI.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 922F59E616072DDF0088F2CA /* EyeEmAPI.h */; };
922F59F416073DD40088F2CA /* EERequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 922F59F316073DD40088F2CA /* EERequest.m */; };
Expand Down Expand Up @@ -36,6 +52,22 @@
dstPath = "include/${PRODUCT_NAME}";
dstSubfolderSpec = 16;
files = (
40C4AFB51B24E127003B6C88 /* EEQuery.h in CopyFiles */,
40C4AFA71B24E11F003B6C88 /* EEAlbumsQuery.h in CopyFiles */,
40C4AFA81B24E11F003B6C88 /* EEUsersQuery.h in CopyFiles */,
40C4AFA91B24E11F003B6C88 /* EEPhotosQuery.h in CopyFiles */,
40C4AFAA1B24E11F003B6C88 /* EENewsQuery.h in CopyFiles */,
40C4AFAB1B24E11F003B6C88 /* EETopicsQuery.h in CopyFiles */,
40C4AFAC1B24E11F003B6C88 /* EESearchQuery.h in CopyFiles */,
40C4AFAD1B24E11F003B6C88 /* EEVenuesQuery.h in CopyFiles */,
40C4AFAE1B24E11F003B6C88 /* EEComment.h in CopyFiles */,
40C4AFAF1B24E11F003B6C88 /* EEAlbum.h in CopyFiles */,
40C4AFB01B24E11F003B6C88 /* EEUser.h in CopyFiles */,
40C4AFB11B24E11F003B6C88 /* EEOAuthUser.h in CopyFiles */,
40C4AFB21B24E11F003B6C88 /* EELocation.h in CopyFiles */,
40C4AFB31B24E11F003B6C88 /* EEPhoto.h in CopyFiles */,
40C4AFB41B24E11F003B6C88 /* EENews.h in CopyFiles */,
40C4AFA61B24E071003B6C88 /* EERequest.h in CopyFiles */,
922F59E716072DDF0088F2CA /* EyeEmAPI.h in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -214,7 +246,7 @@
922F59D516072DDF0088F2CA /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0600;
LastUpgradeCheck = 0630;
ORGANIZATIONNAME = EyeEm;
};
buildConfigurationList = 922F59D816072DDF0088F2CA /* Build configuration list for PBXProject "EEAPI" */;
Expand Down Expand Up @@ -279,6 +311,7 @@
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
Expand All @@ -292,9 +325,10 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
VALID_ARCHS = "arm64 armv7 armv7s";
};
name = Debug;
};
Expand All @@ -314,16 +348,18 @@
COPY_PHASE_STRIP = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
VALID_ARCHS = "arm64 armv7 armv7s";
};
name = Release;
};
Expand Down
87 changes: 53 additions & 34 deletions EEAPI/EyeEmAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,49 +25,70 @@
#import "EEComment.h"
#import "EEOAuthUser.h"

@protocol EESessionDelegate;
@class EEAlbum,EEComment,EERequest,EEPhoto,EEUser,EEQuery;
@interface EyeEmAPI : NSObject

@protocol EESessionDelegate<NSObject>

@property(nonatomic, strong) NSString* clientId;
@property(nonatomic, strong) NSString* baseURL;
@property(nonatomic, strong) NSString* accessToken;
@property(nonatomic, strong) EERequest* eeRequest;
@property(nonatomic) NSMutableArray* requests;
@property(nonatomic, weak) id<EESessionDelegate> sessionDelegate;
-(void)sessionValid:(BOOL)valid;

@end

-(id)initWithClientId:(NSString*)clientId;
-(void) authorize;
- (NSString *)combiningParameters: (NSDictionary* ) parameters;
-(NSDictionary*)parseURLParameters:(NSString *)query;
-(BOOL) isOAuthValid;
-(void) requestWithEndpoint:(NSString*) endpoint
parameters:(NSDictionary*) parameters
httpMethod:(NSString*) method
completion:(EERequestCompletionBlock) completionBlock;

@interface EyeEmAPI : NSObject

@property(nonatomic) EERequest* eeRequest;
@property(nonatomic) NSMutableArray* requests;

-(void) getPopularPhotosWithLimit:(NSInteger) limit
/*
* Initialization
*
* Creating new object of the EyeEmAPI class can be done by invoking
* the -init method or by using the +defaultClient static method
* which is responsible for creating shared instance of EyeEmAPI class.
*/
- (instancetype)init; //Creates a new EyeEmAPI object.
+ (instancetype)defaultClient; //Convenient way to work with shared instance of EyeEmAPI class.

/*
* Authorization
*
* Invoking -authorizeWithClientId: begins the process of authorization
* that is ended when AppDelegate recieves message
* -application:openURL:sourceApplication:sourceApplication:annotation:.
* In context of this method must be send the -parseAuthorizationURL: message
* to the EyeEmAPI object.
*
* Checking if the session has been established can be done by reading
* the value of the authorized property from the EyeEmAPI object
*
* In case when particular object wants to be notified about
* result of authorization process it must implement the EESessionDelegate protocol
* and must be assigned as a sessionDeelgate for the EyeEmAPI object.
*/
- (void)authorizeWithClientId:(NSString*)clientId; //Begins the process of authorization with specified cliendId.
- (BOOL)parseAuthorizationURL:(NSURL*)authorizeURL; //Parses the URL received in response to a request for authorization.

@property(nonatomic, weak) id<EESessionDelegate>sessionDelegate; //Weak reference to an object that wants to be notified about result of a authorization process.
@property (nonatomic, readonly, getter=isAuthorized) BOOL authorized; //Returns YES if the session has been established or NO otherwise.

//Requests
- (void)requestWithEndpoint:(NSString*)endpoint
parameters:(NSDictionary*)parameters
httpMethod:(NSString*)method
completion:(EERequestCompletionBlock)completionBlock;

-(void)getPopularPhotosWithLimit:(NSInteger) limit
offset:(NSInteger) offset
otherOptions:(NSDictionary*) parameters
completion:(void(^)(NSArray* , NSDictionary*, NSError* ))completionBlock;
- (BOOL) handleOpenURL: (NSURL*) url;


- (void) getRequestWithParameters: (NSDictionary*) parameters
completion: (void(^)(NSHTTPURLResponse *httpResponse, NSDictionary*, NSError* ))completionBlock;

- (void) putRequestWithParameters: (NSDictionary*) parameters
completion: (void(^)(NSHTTPURLResponse *httpResponse, NSDictionary*, NSError* ))completionBlock;
- (void)getRequestWithParameters:(NSDictionary*)parameters
completion:(void(^)(NSHTTPURLResponse *httpResponse, NSDictionary*, NSError* ))completionBlock;

- (void) postRequestWithParameters: (NSDictionary*) parameters
completion: (void(^)(NSHTTPURLResponse *httpResponse, NSDictionary*, NSError* ))completionBlock;
- (NSDictionary* ) sortResponse: (NSMutableDictionary*) response;
- (NSString*) extractString: (NSString *) string;
- (void)putRequestWithParameters:(NSDictionary*) parameters
completion:(void(^)(NSHTTPURLResponse *httpResponse, NSDictionary*, NSError* ))completionBlock;

- (void)postRequestWithParameters:(NSDictionary*) parameters
completion:(void(^)(NSHTTPURLResponse *httpResponse, NSDictionary*, NSError* ))completionBlock;
- (NSDictionary*)sortResponse:(NSMutableDictionary*) response;

-(NSURL*) urlFromPathForPhoto:(NSURL*)urlPath withPixelSize:(CGSize)imageSize;
-(NSURL*) urlFromPathForPhoto:(NSURL*)urlPath withPixelWidth:(NSInteger)imageWidth;
Expand All @@ -76,6 +97,4 @@

@end

@protocol EESessionDelegate <NSObject>
-(void) sessionValid:(BOOL) valid;
@end

Loading