- Fi vari

This commit is contained in:
Giuseppe Nucifora 2016-02-19 14:48:25 +01:00
parent bc854abc37
commit a818aafa0c
17 changed files with 995 additions and 951 deletions

View File

@ -34,7 +34,7 @@
[PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @"http://packman.local/app_dev.php/api/v1/", [PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @"http://packman.local/app_dev.php/api/v1/",
EnvironmentStage : @"https://packman.ppreview.it/app_stage.php/api/v1/", EnvironmentStage : @"https://packman.ppreview.it/app_stage.php/api/v1/",
EnvironmentProduction : @"http://packman.ppreview.it/app_stage.php/api/v1/" EnvironmentProduction : @"http://packman.ppreview.it/app_stage.php/api/v1/"
} withOauth:YES]; } userSubclass:[User class] withOauth:YES];
[[PNObjectConfig sharedInstance] setHTTPHeaderValue:@"application/x-www-form-urlencoded" forKey:@"Content-Type"]; [[PNObjectConfig sharedInstance] setHTTPHeaderValue:@"application/x-www-form-urlencoded" forKey:@"Content-Type"];
[[PNObjectConfig sharedInstance] setClientID:@"1_pqjo2w5k7j4g8skco408oc048w8so0ws840gcg8k8gwsgk0g4" clientSecret:@"10w0vg2v6eggooc4wks4w4s0wkwok0wkck0w888so0o80g88w8" forEnv:EnvironmentProduction]; [[PNObjectConfig sharedInstance] setClientID:@"1_pqjo2w5k7j4g8skco408oc048w8so0ws840gcg8k8gwsgk0g4" clientSecret:@"10w0vg2v6eggooc4wks4w4s0wkwok0wkck0w888so0o80g88w8" forEnv:EnvironmentProduction];
#ifdef DEBUG #ifdef DEBUG

View File

@ -135,7 +135,7 @@
//if ([user isAuthenticated]) { //if ([user isAuthenticated]) {
[User loginCurrentUserWithEmail:@"packman@giuseppenucifora.com" password:@"asdasdasd" withBlockSuccess:^(PNUser * _Nullable responseObject) { [User loginCurrentUserWithEmail:@"demo@packman.example" password:@"demo@packman.example" withBlockSuccess:^(PNUser * _Nullable responseObject) {
NSLog(@"response : %@",responseObject); NSLog(@"response : %@",responseObject);

View File

@ -37,10 +37,10 @@ PODS:
- FBSnapshotTestCase/SwiftSupport (2.0.7): - FBSnapshotTestCase/SwiftSupport (2.0.7):
- FBSnapshotTestCase/Core - FBSnapshotTestCase/Core
- NSDate_Utils (0.1.0) - NSDate_Utils (0.1.0)
- NSString-Helper (1.0.2) - NSString-Helper (1.0.3)
- nv-ios-http-status (0.0.1) - nv-ios-http-status (0.0.1)
- PEAR-FileManager-iOS (1.3.1) - PEAR-FileManager-iOS (1.3.1)
- PNObject (0.3.8): - PNObject (0.3.9):
- AFNetworking - AFNetworking
- CodFis-Helper - CodFis-Helper
- FBSDKCoreKit - FBSDKCoreKit
@ -93,10 +93,10 @@ SPEC CHECKSUMS:
FBSDKShareKit: 54587b4624706ace1e810cf83412a918141f807a FBSDKShareKit: 54587b4624706ace1e810cf83412a918141f807a
FBSnapshotTestCase: 7e85180d0d141a0cf472352edda7e80d7eaeb547 FBSnapshotTestCase: 7e85180d0d141a0cf472352edda7e80d7eaeb547
NSDate_Utils: 4a57f91094123d5b7600c7de8c9ad9e1d43306a3 NSDate_Utils: 4a57f91094123d5b7600c7de8c9ad9e1d43306a3
NSString-Helper: 0ee74919829a332f9838fa87b28cb2d1d991e92c NSString-Helper: d4c5459e8142ee6a96b070118009f08637030c2d
nv-ios-http-status: b6c2b5fc8656cc19e0d3000dadce2080b99d0e2f nv-ios-http-status: b6c2b5fc8656cc19e0d3000dadce2080b99d0e2f
PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3 PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3
PNObject: f2ff42ecb60a86983e76d460a478b15a5c57d9cf PNObject: d0c5fda51507511773cc512928a3b7ab9ef6088c
PureLayout: f35f5384c9c4e4479df041dbe33ad7577b71ddfb PureLayout: f35f5384c9c4e4479df041dbe33ad7577b71ddfb
RNCryptor: 59d6483908115af5c12b884db23392024e52a5fe RNCryptor: 59d6483908115af5c12b884db23392024e52a5fe
Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2 Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2

View File

@ -1,6 +1,6 @@
{ {
"name": "PNObject", "name": "PNObject",
"version": "0.3.8", "version": "0.3.9",
"summary": "PNObject is a simple replica of the more complex ParseObject", "summary": "PNObject is a simple replica of the more complex ParseObject",
"homepage": "https://github.com/giuseppenucifora/PNObject", "homepage": "https://github.com/giuseppenucifora/PNObject",
"license": "MIT", "license": "MIT",
@ -9,7 +9,7 @@
}, },
"source": { "source": {
"git": "https://github.com/giuseppenucifora/PNObject.git", "git": "https://github.com/giuseppenucifora/PNObject.git",
"tag": "0.3.8" "tag": "0.3.9"
}, },
"platforms": { "platforms": {
"ios": "7.0" "ios": "7.0"

View File

@ -37,10 +37,10 @@ PODS:
- FBSnapshotTestCase/SwiftSupport (2.0.7): - FBSnapshotTestCase/SwiftSupport (2.0.7):
- FBSnapshotTestCase/Core - FBSnapshotTestCase/Core
- NSDate_Utils (0.1.0) - NSDate_Utils (0.1.0)
- NSString-Helper (1.0.2) - NSString-Helper (1.0.3)
- nv-ios-http-status (0.0.1) - nv-ios-http-status (0.0.1)
- PEAR-FileManager-iOS (1.3.1) - PEAR-FileManager-iOS (1.3.1)
- PNObject (0.3.8): - PNObject (0.3.9):
- AFNetworking - AFNetworking
- CodFis-Helper - CodFis-Helper
- FBSDKCoreKit - FBSDKCoreKit
@ -93,10 +93,10 @@ SPEC CHECKSUMS:
FBSDKShareKit: 54587b4624706ace1e810cf83412a918141f807a FBSDKShareKit: 54587b4624706ace1e810cf83412a918141f807a
FBSnapshotTestCase: 7e85180d0d141a0cf472352edda7e80d7eaeb547 FBSnapshotTestCase: 7e85180d0d141a0cf472352edda7e80d7eaeb547
NSDate_Utils: 4a57f91094123d5b7600c7de8c9ad9e1d43306a3 NSDate_Utils: 4a57f91094123d5b7600c7de8c9ad9e1d43306a3
NSString-Helper: 0ee74919829a332f9838fa87b28cb2d1d991e92c NSString-Helper: d4c5459e8142ee6a96b070118009f08637030c2d
nv-ios-http-status: b6c2b5fc8656cc19e0d3000dadce2080b99d0e2f nv-ios-http-status: b6c2b5fc8656cc19e0d3000dadce2080b99d0e2f
PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3 PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3
PNObject: f2ff42ecb60a86983e76d460a478b15a5c57d9cf PNObject: d0c5fda51507511773cc512928a3b7ab9ef6088c
PureLayout: f35f5384c9c4e4479df041dbe33ad7577b71ddfb PureLayout: f35f5384c9c4e4479df041dbe33ad7577b71ddfb
RNCryptor: 59d6483908115af5c12b884db23392024e52a5fe RNCryptor: 59d6483908115af5c12b884db23392024e52a5fe
Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2 Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2

View File

@ -13,7 +13,7 @@
- (BOOL) isValidEmail - (BOOL) isValidEmail
{ {
BOOL stricterFilter = YES; BOOL stricterFilter = YES;
NSString *stricterFilterString = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; NSString *stricterFilterString = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,15}";
NSString *laxString = @".+@.+\\.[A-Za-z]{2}[A-Za-z]*"; NSString *laxString = @".+@.+\\.[A-Za-z]{2}[A-Za-z]*";
NSString *emailRegex = stricterFilter ? stricterFilterString : laxString; NSString *emailRegex = stricterFilter ? stricterFilterString : laxString;
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@
buildForArchiving = "YES"> buildForArchiving = "YES">
<BuildableReference <BuildableReference
BuildableIdentifier = 'primary' BuildableIdentifier = 'primary'
BlueprintIdentifier = 'FB7B8B19AE1F5E597E5C759195549ABD' BlueprintIdentifier = 'C8C004A101D5139E1B027E4C65815A0A'
BlueprintName = 'PNObject' BlueprintName = 'PNObject'
ReferencedContainer = 'container:Pods.xcodeproj' ReferencedContainer = 'container:Pods.xcodeproj'
BuildableName = 'PNObject.framework'> BuildableName = 'PNObject.framework'>

View File

@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.0.2</string> <string>1.0.3</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>

View File

@ -13,7 +13,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>BNDL</string> <string>BNDL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.0.2</string> <string>1.0.3</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>

View File

@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.3.8</string> <string>0.3.9</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>

View File

@ -10,6 +10,7 @@
#import "PNObject.h" #import "PNObject.h"
#import "PNObjectConfig.h" #import "PNObjectConfig.h"
#import "PNObjectConstants.h" #import "PNObjectConstants.h"
#import "PNObjectFormData.h"
#import "PNObjectModel.h" #import "PNObjectModel.h"
#import "AFJSONResponseSerializerWithData.h" #import "AFJSONResponseSerializerWithData.h"
#import "AFHTTPRequestSerializer+OAuth2.h" #import "AFHTTPRequestSerializer+OAuth2.h"

View File

@ -13,7 +13,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>BNDL</string> <string>BNDL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.3.8</string> <string>0.3.9</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>

View File

@ -8,7 +8,7 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = "PNObject" s.name = "PNObject"
s.version = "0.3.9" s.version = "0.3.10"
s.summary = "PNObject is a simple replica of the more complex ParseObject" s.summary = "PNObject is a simple replica of the more complex ParseObject"
# This description is used to generate tags and improve search results. # This description is used to generate tags and improve search results.

View File

@ -272,6 +272,8 @@ static bool isFirstAccess = YES;
[[PNObjectConfig sharedInstance] refreshTokenForUserWithEmail:email password:password withBlockSuccess:^(BOOL refreshSuccess) { [[PNObjectConfig sharedInstance] refreshTokenForUserWithEmail:email password:password withBlockSuccess:^(BOOL refreshSuccess) {
if (refreshSuccess) { if (refreshSuccess) {
PNUser *user = [[self class] new]; PNUser *user = [[self class] new];
PNObjcPassword *objectPassword = [PNObjcPassword new]; PNObjcPassword *objectPassword = [PNObjcPassword new];
@ -353,7 +355,7 @@ static bool isFirstAccess = YES;
} }
+ (NSString *)objectClassName { + (NSString *)objectClassName {
return @"User"; return @"PNUser";
} }
+ (NSString *) objectEndPoint { + (NSString *) objectEndPoint {

View File

@ -41,7 +41,7 @@ extern NSString* _Nonnull const Client_Secret;
/** /**
* Oauth is NO by default * Oauth is NO by default
* *
* @param clientIdsForEnvironments * @param endpointUrlsForEnvironments
* For example, * For example,
* @{ PNObjectConfigDevelopment : @"https://development.it/api/v1", * @{ PNObjectConfigDevelopment : @"https://development.it/api/v1",
* PNObjectConfigEnvStage : @"ttps://stage.it/api/v1", * PNObjectConfigEnvStage : @"ttps://stage.it/api/v1",
@ -52,10 +52,25 @@ extern NSString* _Nonnull const Client_Secret;
*/ */
+ (instancetype _Nonnull) initSharedInstanceForEnvironments:(NSDictionary * _Nonnull) endpointUrlsForEnvironments; + (instancetype _Nonnull) initSharedInstanceForEnvironments:(NSDictionary * _Nonnull) endpointUrlsForEnvironments;
/**
* <#Description#>
*
* @param endpointUrlsForEnvironments
* For example,
* @{ PNObjectConfigDevelopment : @"https://development.it/api/v1",
* PNObjectConfigEnvStage : @"ttps://stage.it/api/v1",
* PNObjectConfigEnvProduction : @"ttps://production.it/api/v1"
* }
* @param userSubClass <#userSubClass description#>
*
* @return <#return value description#>
*/
+ (instancetype _Nonnull) initSharedInstanceForEnvironments:(NSDictionary * _Nonnull) endpointUrlsForEnvironments andUserSubclass:(Class _Nonnull) userSubClass;
/** /**
* *
* *
* @param clientIdsForEnvironments * @param endpointUrlsForEnvironments
* For example, * For example,
* @{ PNObjectConfigDevelopment : @"https://development.it/api/v1", * @{ PNObjectConfigDevelopment : @"https://development.it/api/v1",
* PNObjectConfigEnvStage : @"ttps://stage.it/api/v1", * PNObjectConfigEnvStage : @"ttps://stage.it/api/v1",
@ -67,6 +82,21 @@ extern NSString* _Nonnull const Client_Secret;
*/ */
+ (instancetype _Nonnull) initSharedInstanceForEnvironments:(NSDictionary * _Nonnull) endpointUrlsForEnvironments withOauth:(BOOL) oauthEnabled; + (instancetype _Nonnull) initSharedInstanceForEnvironments:(NSDictionary * _Nonnull) endpointUrlsForEnvironments withOauth:(BOOL) oauthEnabled;
/**
* <#Description#>
*
* @param endpointUrlsForEnvironments
* For example,
* @{ PNObjectConfigDevelopment : @"https://development.it/api/v1",
* PNObjectConfigEnvStage : @"ttps://stage.it/api/v1",
* PNObjectConfigEnvProduction : @"ttps://production.it/api/v1"
* }
* @param userSubClass <#userSubClass description#>
* @param oauthEnabled <#oauthEnabled description#>
*
* @return <#return value description#>
*/
+ (instancetype _Nonnull) initSharedInstanceForEnvironments:(NSDictionary * _Nonnull) endpointUrlsForEnvironments userSubclass:(Class _Nonnull) userSubClass withOauth:(BOOL) oauthEnabled;
/** /**
* <#Description#> * <#Description#>
* *

View File

@ -47,6 +47,7 @@ NSString* const Client_Secret = @"client_secret";
@property (nonatomic, strong) NSString *currentOAuthClientID; @property (nonatomic, strong) NSString *currentOAuthClientID;
@property (nonatomic, strong) NSString *currentOAuthClientSecret; @property (nonatomic, strong) NSString *currentOAuthClientSecret;
//@property (nonatomic, strong) NSMutableDictionary *environments; //@property (nonatomic, strong) NSMutableDictionary *environments;
@property (nonatomic) Class userSubClass;
@end @end
@ -74,14 +75,24 @@ static bool isFirstAccess = YES;
#pragma mark - Life Cycle #pragma mark - Life Cycle
+ (instancetype) initSharedInstanceForEnvironments:(NSDictionary *) endpointUrlsForEnvironments { + (instancetype) initSharedInstanceForEnvironments:(NSDictionary *) endpointUrlsForEnvironments {
return [self initSharedInstanceForEnvironments:endpointUrlsForEnvironments withOauth:NO]; return [self initSharedInstanceForEnvironments:endpointUrlsForEnvironments userSubclass:[PNUser class] withOauth:NO];
} }
+ (instancetype) initSharedInstanceForEnvironments:(NSDictionary *)endpointUrlsForEnvironments andUserSubclass:(Class)userSubClass {
return [self initSharedInstanceForEnvironments:endpointUrlsForEnvironments userSubclass:userSubClass withOauth:NO];
}
+ (instancetype) initSharedInstanceForEnvironments:(NSDictionary *) endpointUrlsForEnvironments withOauth:(BOOL) oauthEnabled { + (instancetype) initSharedInstanceForEnvironments:(NSDictionary *) endpointUrlsForEnvironments withOauth:(BOOL) oauthEnabled {
return [self initSharedInstanceForEnvironments:endpointUrlsForEnvironments userSubclass:[PNUser class] withOauth:oauthEnabled];
}
+ (instancetype _Nonnull) initSharedInstanceForEnvironments:(NSDictionary * _Nonnull) endpointUrlsForEnvironments userSubclass:(Class _Nonnull) userSubClass withOauth:(BOOL) oauthEnabled {
SINGLETON = [self sharedInstance]; SINGLETON = [self sharedInstance];
if (SINGLETON) { if (SINGLETON) {
SINGLETON.oauthEnabled = oauthEnabled; SINGLETON.oauthEnabled = oauthEnabled;
SINGLETON.userSubClass = userSubClass;
for (NSString *key in [endpointUrlsForEnvironments allKeys]) { for (NSString *key in [endpointUrlsForEnvironments allKeys]) {
NSURL * endpointUrl = [NSURL URLWithString:[endpointUrlsForEnvironments objectForKey:key]]; NSURL * endpointUrl = [NSURL URLWithString:[endpointUrlsForEnvironments objectForKey:key]];
@ -232,7 +243,9 @@ static bool isFirstAccess = YES;
} }
- (void) refreshToken { - (void) refreshToken {
if([PNUser currentUser] && [[PNUser currentUser] hasValidEmailAndPasswordData]) {
if([SINGLETON.userSubClass currentUser] && [[SINGLETON.userSubClass currentUser] hasValidEmailAndPasswordData]) {
[self refreshTokenForUser]; [self refreshTokenForUser];
} }
else { else {
@ -248,7 +261,7 @@ static bool isFirstAccess = YES;
- (void) refreshTokenForUserWithBlockSuccess:(nullable void (^)(BOOL refreshSuccess))success - (void) refreshTokenForUserWithBlockSuccess:(nullable void (^)(BOOL refreshSuccess))success
failure:(nullable void (^)(NSError * _Nonnull error))failure { failure:(nullable void (^)(NSError * _Nonnull error))failure {
if([PNUser currentUser] && [[PNUser currentUser] hasValidEmailAndPasswordData]) { if([SINGLETON.userSubClass currentUser] && [[SINGLETON.userSubClass currentUser] hasValidEmailAndPasswordData]) {
[_manager authenticateUsingOAuthWithURLString:[_currentEndPointBaseUrl stringByAppendingString:@"oauth-token"] username:[[PNUser currentUser] email] password:[[[PNUser currentUser] password] password] scope:nil success:^(AFOAuthCredential * _Nonnull credential) { [_manager authenticateUsingOAuthWithURLString:[_currentEndPointBaseUrl stringByAppendingString:@"oauth-token"] username:[[PNUser currentUser] email] password:[[[PNUser currentUser] password] password] scope:nil success:^(AFOAuthCredential * _Nonnull credential) {
_currentOauthCredential = credential; _currentOauthCredential = credential;