From 866880eaa9799a2ab6d47771ed04bc17ec6f9a89 Mon Sep 17 00:00:00 2001 From: Giuseppe Nucifora Date: Wed, 11 Jan 2017 01:14:46 +0100 Subject: [PATCH 1/4] - Aggiornato readme --- Example/PNObject/PNObjAppDelegate.m | 31 ++---- Example/PNObject/PNObjViewController.m | 78 +++---------- README.md | 147 +++++++++++++++++++++++++ 3 files changed, 170 insertions(+), 86 deletions(-) diff --git a/Example/PNObject/PNObjAppDelegate.m b/Example/PNObject/PNObjAppDelegate.m index cdbdcff..ef24ef8 100644 --- a/Example/PNObject/PNObjAppDelegate.m +++ b/Example/PNObject/PNObjAppDelegate.m @@ -31,29 +31,16 @@ _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. - /* - [PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @"http://packman.local/app_dev.php/api/v1/", - EnvironmentStage : @"https://packman.ppreview.it/app_stage.php/api/v1/", - EnvironmentProduction : @"http://packman.ppreview.it/app_stage.php/api/v1/" - } userSubclass:[PNUser class] withOauth:YES]; - [[PNObjectConfig sharedInstance] setHTTPHeaderValue:@"application/x-www-form-urlencoded" forKey:@"Content-Type"]; - [[PNObjectConfig sharedInstance] setClientID:@"1_pqjo2w5k7j4g8skco408oc048w8so0ws840gcg8k8gwsgk0g4" clientSecret:@"10w0vg2v6eggooc4wks4w4s0wkwok0wkck0w888so0o80g88w8" forEnv:EnvironmentProduction]; -#ifdef DEBUG + + [PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @"http://pnobject.local/api/v1/", + EnvironmentStage : @"http://pnobject.stage.it/api/v1/", + EnvironmentProduction : @"http://pnobject.prod.it/api/v1/" + } userSubclass:[PNUser class] withOauthMode:OAuthModeClientCredential]; + + [[PNObjectConfig sharedInstance] setClientID:@"xxxxxxxxx" clientSecret:@"xxxxxxxxxxxx" forEnv:EnvironmentStage]; + [[PNObjectConfig sharedInstance] setClientID:@"xxxxxxxxx" clientSecret:@"xxxxxxxxxxxx" forEnv:EnvironmentProduction]; + [[PNObjectConfig sharedInstance] setEnvironment:EnvironmentStage]; -#endif*/ - - [PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @"http://bmwcallingweb.local/app_dev.php/api/v1/", - EnvironmentStage : @"http://bmwcallingweb.ppreview.it/app_dev.php/api/v1/", - EnvironmentProduction : @"http://bmwcallingweb.ppreview.it/app_dev.php/api/v1/" - } userSubclass:[PNUser class] withOauthMode:OAuthModePassword]; - - [[PNObjectConfig sharedInstance] setClientID:@"1_pqjo2w5k7j4g8skco408oc048w8so0ws840gcg8k8gwsgk0g4" clientSecret:@"10w0vg2v6eggooc4wks4w4s0wkwok0wkck0w888so0o80g88w8" forEnv:EnvironmentStage]; - - - [[PNObjectConfig sharedInstance] setOauthUserName:@"admin" oauthPassword:@"admin" forEnv:EnvironmentStage]; - - [[PNObjectConfig sharedInstance] setEnvironment:EnvironmentStage]; - //[[PNObjectConfig sharedInstance] setHTTPHeaderValue:@"XMLHttpRequest" forKey:@"X-Request-With"]; diff --git a/Example/PNObject/PNObjViewController.m b/Example/PNObject/PNObjViewController.m index 76b5ef2..13d0a2a 100644 --- a/Example/PNObject/PNObjViewController.m +++ b/Example/PNObject/PNObjViewController.m @@ -30,7 +30,7 @@ - (void)viewDidLoad { [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. + // Do any additional setup after loading the view, typically from a nib. _refreshToken = [UIButton newAutoLayoutView]; [_refreshToken addTarget:self action:@selector(refreshTokenAction) forControlEvents:UIControlEventTouchUpInside]; @@ -102,72 +102,22 @@ - (void) apiCallAction { - /*PNObjcPassword *password = [PNObjcPassword new]; - [password setPassword:@"asdasdasd"]; - [password setConfirmPassword:@"asdasdasd"]; - - User *user = [User new]; - [user setFirstName:@"Giuseppe"]; - [user setLastName:@"Nuficora"]; - [user setEmail:@"packman5@giuseppenucifora.com"]; - [user setPassword:password]; - [user setHasAcceptedNewsletter:YES]; - [user setHasAcceptedPrivacy:YES]; - */ - //[user saveLocally]; + PNObjcPassword *password = [PNObjcPassword new]; + [password setPassword:@"asdasdasd"]; + [password setConfirmPassword:@"asdasdasd"]; + + PNUser *user = [PNUser new]; + [user setFirstName:@"Test"]; + [user setLastName:@"Test"]; + [user setEmail:@"pnobject@pnobject.com"]; + [user setPassword:password]; + [user setHasAcceptedNewsletter:YES]; + [user setHasAcceptedPrivacy:YES]; + + [user saveLocally]; NSLog(@"%@",[[PNUser currentUser] JSONFormObject]); - //NSLog(@"%@",[user JSONObjectMap]); - /*[user registerWithBlockSuccess:^(PNUser * _Nullable responseObject) { - - } failure:^(NSError * _Nonnull error) { - - }];*/ - /*[[User currentUser] socialLoginWithBlockSuccessFromViewController:self - blockSuccess:^(PNUser * _Nullable responseObject) { - - } failure:^(NSError * _Nonnull error) { - - }];*/ - - //User * user = [User currentUser]; - - //if ([user isAuthenticated]) { - - /*[User loginCurrentUserWithEmail:@"demo@packman.example" password:@"demo@packman.example" withBlockSuccess:^(PNUser * _Nullable responseObject) { - - NSLog(@"response : %@",responseObject); - - NSLog(@"%@",[User currentUser]); - } failure:^(NSError * _Nonnull error) { - NSLog(@"response : %@",error); - }];*/ - - /*[PNUser socialLoginWithBlockSuccess:^(PNUser * _Nullable responseObject) { - - } failure:^(NSError * _Nonnull error) { - - }];*/ - - /*[PNUser socialUserFromViewController:self blockSuccess:^(PNUser * _Nullable responseObject) { - - NSLog(@"%@",[[PNUser currentUser] JSONFormObject]); - - - } failure:^(NSError * _Nonnull error) { - - }];*/ - - - - /*[User resetPasswordForEmail:@"packman@giuseppenucifora.com" Progress:^(NSProgress * _Nonnull uploadProgress) { - - } Success:^(NSDictionary * _Nullable responseObject) { - - } failure:^(NSError * _Nonnull error) { - - }];*/ } diff --git a/README.md b/README.md index 1ef140c..95fc348 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,153 @@ it, simply add the following line to your Podfile: pod "PNObject" ``` +Configure PNObject endpoint client ID, client secret and OAuthModePassword +### + +``` +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + +[PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @"http://pnobject.local/api/v1/", + EnvironmentStage : @"http://pnobject.stage.it/api/v1/", + EnvironmentProduction : @"http://pnobject.prod.it/api/v1/" + } userSubclass:[PNUser class] withOauthMode:OAuthModePassword]; + + [[PNObjectConfig sharedInstance] setClientID:@"xxxxxxxxx" clientSecret:@"xxxxxxxxxxxx" forEnv:EnvironmentStage]; + [[PNObjectConfig sharedInstance] setClientID:@"xxxxxxxxx" clientSecret:@"xxxxxxxxxxxx" forEnv:EnvironmentProduction]; + + + + [[PNObjectConfig sharedInstance] setOauthUserName:@"admin" oauthPassword:@"admin" forEnv:EnvironmentStage]; + + [[PNObjectConfig sharedInstance] setEnvironment:EnvironmentStage]; +} +``` +### +Configure PNObject endpoint client ID, client secret and OAuthModeClientCredential +--- + + +``` +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + +[PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @"http://pnobject.local/api/v1/", + EnvironmentStage : @"http://pnobject.stage.it/api/v1/", + EnvironmentProduction : @"http://pnobject.prod.it/api/v1/" + } userSubclass:[PNUser class] withOauthMode:OAuthModeClientCredential]; + + [[PNObjectConfig sharedInstance] setClientID:@"xxxxxxxxx" clientSecret:@"xxxxxxxxxxxx" forEnv:EnvironmentStage]; + [[PNObjectConfig sharedInstance] setClientID:@"xxxxxxxxx" clientSecret:@"xxxxxxxxxxxx" forEnv:EnvironmentProduction]; + + [[PNObjectConfig sharedInstance] setEnvironment:EnvironmentStage]; +} +``` +### +Configure PNObject endpoint and using custom PNUser object +--- + +``` +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + +[PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @"http://pnobject.local/api/v1/", + EnvironmentStage : @"http://pnobject.stage.it/api/v1/", + EnvironmentProduction : @"http://pnobject.prod.it/api/v1/" + } userSubclass:[PNUser class] withOauthMode:OAuthModeClientCredential]; + + [[PNObjectConfig sharedInstance] setClientID:@"xxxxxxxxx" clientSecret:@"xxxxxxxxxxxx" forEnv:EnvironmentStage]; + [[PNObjectConfig sharedInstance] setClientID:@"xxxxxxxxx" clientSecret:@"xxxxxxxxxxxx" forEnv:EnvironmentProduction]; + + [[PNObjectConfig sharedInstance] setEnvironment:EnvironmentStage]; +} +``` + +### +User.h +--- + +``` + + +#import + +@interface User : PNUser + +@end +``` + +### +User.m +--- +``` +#import "User.h" +#import "PNObject+Protected.h" +#import "PNObject+PNObjectConnection.h" +#import + +@interface User () + +@end + + +@implementation User + ++ (NSDictionary *)objcetMapping { + + NSMutableDictionary *userMapping = [[NSMutableDictionary alloc] initWithDictionary:[[PNUser class] objcetMapping]]; + + return userMapping; +} + ++ (BOOL) singleInstance { + return [[self class] singleInstance]; +} + ++ (NSString * _Nonnull) objectEndPoint { + return @"User"; +} + + ++ (NSString * _Nonnull ) objectClassName { + return @"User"; +} + +### +Custom Reset Password + ++ (void) resetPasswordForEmail:(NSString * _Nonnull) userEmail + Progress:(nullable void (^)(NSProgress * _Nonnull uploadProgress)) uploadProgress + Success:(nullable void (^)(NSDictionary * _Nullable responseObject))success + failure:(nullable void (^)(NSError * _Nonnull error))failure { + + [self POSTWithEndpointAction:@"password-reset-request" + parameters:[self resetPasswordFormObject:userEmail] + progress:uploadProgress + success:^(NSURLSessionDataTask * _Nullable task, NSDictionary * _Nullable responseObject) { + if (success) { + success(responseObject); + } + } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { + if (failure) { + failure(error); + } + }]; +} + ++ (NSDictionary * _Nonnull) resetPasswordFormObject:(NSString *) email { + + NSMutableDictionary *resetPasswordDictionary = [[NSMutableDictionary alloc] init]; + [resetPasswordDictionary setObject:email forKey:@"email"]; + + return resetPasswordDictionary; +} + +``` + + + + ## Author Giuseppe Nucifora, me@giuseppenucifora.com From 7cd3419a3a621a3c4726fcf557c5dc844a159279 Mon Sep 17 00:00:00 2001 From: Giuseppe Nucifora Date: Wed, 11 Jan 2017 01:18:07 +0100 Subject: [PATCH 2/4] - Release 1.1.5 --- PNObject.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PNObject.podspec b/PNObject.podspec index b783118..da82ae3 100644 --- a/PNObject.podspec +++ b/PNObject.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'PNObject' -s.version = '1.1.3' +s.version = '1.1.5' s.summary = 'PNObject is a simple replica of the more complex ParseObject' From 6ef2dd01c33e7aa995df10d85945e33d557fcc31 Mon Sep 17 00:00:00 2001 From: Giuseppe Nucifora Date: Wed, 11 Jan 2017 01:30:25 +0100 Subject: [PATCH 3/4] no message --- PNObject.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PNObject.podspec b/PNObject.podspec index da82ae3..eebe5d7 100644 --- a/PNObject.podspec +++ b/PNObject.podspec @@ -14,11 +14,11 @@ s.summary = 'PNObject is a simple replica of the more complex ParseObje #s.description = <<-DESC TODO: Add long description of the pod here. DESC -s.homepage = "https://git.giuseppenucifora.com/giuseppenucifora/PNObject" +s.homepage = "https://github.com/giuseppenucifora/PNObject" # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { 'Giuseppe Nucifora' => 'me@giuseppenucifora.com' } -s.source = { :git => "https://git.giuseppenucifora.com/giuseppenucifora/PNObject.git", :tag => s.version.to_s } +s.source = { :git => "https://github.com/giuseppenucifora/PNObject.git", :tag => s.version.to_s } # s.social_media_url = 'https://twitter.com/' s.ios.deployment_target = '8.0' From da079b0cd0134026be5d106a2636a4e48a8b1f4b Mon Sep 17 00:00:00 2001 From: Giuseppe Nucifora Date: Wed, 11 Jan 2017 01:33:12 +0100 Subject: [PATCH 4/4] 1.2.0 --- PNObject.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PNObject.podspec b/PNObject.podspec index eebe5d7..6b28ec1 100644 --- a/PNObject.podspec +++ b/PNObject.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'PNObject' -s.version = '1.1.5' +s.version = '1.2.0' s.summary = 'PNObject is a simple replica of the more complex ParseObject'