diff --git a/Example/Podfile.lock b/Example/Podfile.lock index a8e5d89..01ca967 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -48,7 +48,7 @@ PODS: - CocoaSecurity (~> 1.2.2) - nv-ios-http-status (0.0.1) - PEAR-FileManager-iOS (1.3.1) - - PNObject (0.5.3): + - PNObject (0.5.5): - AFNetworking - CodFis-Helper - DJLocalization @@ -110,7 +110,7 @@ SPEC CHECKSUMS: NSUserDefaults-AESEncryptor: da02cfef056f1e18ebe2748767915f08b274c9c5 nv-ios-http-status: b6c2b5fc8656cc19e0d3000dadce2080b99d0e2f PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3 - PNObject: 15473d09103b41094279caeddc8a979aaa43fe95 + PNObject: 341c3e6e8d2a200fc9dd726a13979160b48c9466 PureLayout: f35f5384c9c4e4479df041dbe33ad7577b71ddfb Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2 StrongestPasswordValidator: 921e42615bdf353513c6f925bffd4fc29865dbd7 diff --git a/Example/Pods/Local Podspecs/PNObject.podspec.json b/Example/Pods/Local Podspecs/PNObject.podspec.json index 20658ee..6dd6078 100644 --- a/Example/Pods/Local Podspecs/PNObject.podspec.json +++ b/Example/Pods/Local Podspecs/PNObject.podspec.json @@ -1,6 +1,6 @@ { "name": "PNObject", - "version": "0.5.3", + "version": "0.5.5", "summary": "PNObject is a simple replica of the more complex ParseObject", "homepage": "https://github.com/giuseppenucifora/PNObject", "license": "MIT", @@ -9,7 +9,7 @@ }, "source": { "git": "https://github.com/giuseppenucifora/PNObject.git", - "tag": "0.5.3" + "tag": "0.5.5" }, "platforms": { "ios": "8.0" diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock index a8e5d89..01ca967 100644 --- a/Example/Pods/Manifest.lock +++ b/Example/Pods/Manifest.lock @@ -48,7 +48,7 @@ PODS: - CocoaSecurity (~> 1.2.2) - nv-ios-http-status (0.0.1) - PEAR-FileManager-iOS (1.3.1) - - PNObject (0.5.3): + - PNObject (0.5.5): - AFNetworking - CodFis-Helper - DJLocalization @@ -110,7 +110,7 @@ SPEC CHECKSUMS: NSUserDefaults-AESEncryptor: da02cfef056f1e18ebe2748767915f08b274c9c5 nv-ios-http-status: b6c2b5fc8656cc19e0d3000dadce2080b99d0e2f PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3 - PNObject: 15473d09103b41094279caeddc8a979aaa43fe95 + PNObject: 341c3e6e8d2a200fc9dd726a13979160b48c9466 PureLayout: f35f5384c9c4e4479df041dbe33ad7577b71ddfb Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2 StrongestPasswordValidator: 921e42615bdf353513c6f925bffd4fc29865dbd7 diff --git a/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/PNObject.xcscheme b/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/PNObject.xcscheme index ed33a64..a5fde49 100644 --- a/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/PNObject.xcscheme +++ b/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/PNObject.xcscheme @@ -14,7 +14,7 @@ buildForArchiving = "YES"> diff --git a/Example/Pods/Target Support Files/PNObject/Info.plist b/Example/Pods/Target Support Files/PNObject/Info.plist index 839d6e5..00f6684 100644 --- a/Example/Pods/Target Support Files/PNObject/Info.plist +++ b/Example/Pods/Target Support Files/PNObject/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.5.3 + 0.5.5 CFBundleSignature ???? CFBundleVersion diff --git a/PNObject.podspec b/PNObject.podspec index 200d13f..d674b87 100644 --- a/PNObject.podspec +++ b/PNObject.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "PNObject" -s.version = "0.5.3" +s.version = "0.5.5" s.summary = "PNObject is a simple replica of the more complex ParseObject" # This description is used to generate tags and improve search results. diff --git a/Pod/Classes/PNObject+PNObjectConnection.h b/Pod/Classes/PNObject+PNObjectConnection.h index 11e6852..3eb2806 100644 --- a/Pod/Classes/PNObject+PNObjectConnection.h +++ b/Pod/Classes/PNObject+PNObjectConnection.h @@ -36,6 +36,12 @@ success:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSDictionary * _Nullable responseObject))success failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure; ++ (void) DELETEWithEndpointAction:(NSString * _Nonnull) endPoint + parameters:(NSDictionary * _Nullable) parameters + progress:(nullable void (^)(NSProgress * _Nonnull uploadProgress)) uploadProgress + success:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSDictionary * _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure; + + (id _Nonnull) parseObjectFromResponse:(id _Nullable) response; @end diff --git a/Pod/Classes/PNObject+PNObjectConnection.m b/Pod/Classes/PNObject+PNObjectConnection.m index a204496..efbfd27 100644 --- a/Pod/Classes/PNObject+PNObjectConnection.m +++ b/Pod/Classes/PNObject+PNObjectConnection.m @@ -47,7 +47,7 @@ else { [[PNObjectConfig sharedInstance] refreshTokenForClientCredentialWithBlockSuccess:^(BOOL refreshSuccess) { - [self GETWithEndpointAction:endPoint progress:downloadProgress success:success failure:failure]; + [self GETWithEndpointAction:endPoint parameters:parameters progress:downloadProgress success:success failure:failure]; } failure:^(NSError * _Nonnull error) { if (failure) { failure(nil,error); @@ -115,7 +115,7 @@ else { [[PNObjectConfig sharedInstance] refreshTokenForClientCredentialWithBlockSuccess:^(BOOL refreshSuccess) { - [self POSTWithEndpointAction:endPoint parameters:parameters progress:uploadProgress success:success failure:failure]; + [self POSTWithEndpointAction:endPoint formData:postFormData parameters:parameters progress:uploadProgress success:success failure:failure]; } failure:^(NSError * _Nonnull error) { if (failure) { @@ -125,6 +125,29 @@ } } ++ (void) DELETEWithEndpointAction:(NSString * _Nonnull) endPoint + parameters:(NSDictionary * _Nullable) parameters + progress:(nullable void (^)(NSProgress * _Nonnull uploadProgress)) uploadProgress + success:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSDictionary * _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure { + + if ([[PNObjectConfig sharedInstance] currentOauthCredential] && ![[[PNObjectConfig sharedInstance] currentOauthCredential] isExpired]) { + [[[PNObjectConfig sharedInstance] manager] DELETE:[[[PNObjectConfig sharedInstance] baseUrl] stringByAppendingFormat:@"%@",endPoint] parameters:parameters success:success failure:failure]; + + } + else { + [[PNObjectConfig sharedInstance] refreshTokenForClientCredentialWithBlockSuccess:^(BOOL refreshSuccess) { + + [self DELETEWithEndpointAction:endPoint parameters:parameters progress:uploadProgress success:success failure:failure]; + } failure:^(NSError * _Nonnull error) { + + if (failure) { + failure(nil,error); + } + }]; + } +} + #pragma mark Private Methods @@ -148,7 +171,6 @@ PNObjectResponse = resposeArray; } - } return PNObjectResponse; } diff --git a/Pod/Classes/PNObjectConfig.m b/Pod/Classes/PNObjectConfig.m index 7263f55..a3774d1 100644 --- a/Pod/Classes/PNObjectConfig.m +++ b/Pod/Classes/PNObjectConfig.m @@ -317,7 +317,6 @@ static bool isFirstAccess = YES; - (void) refreshTokenForUserWithBlockSuccess:(nullable void (^)(BOOL refreshSuccess))success failure:(nullable void (^)(NSError * _Nonnull error))failure { - if (_currentOauthCredential) { [_authManager authenticateUsingOAuthWithURLString:[_currentEndPointBaseUrl stringByAppendingString:@"oauth-token"] refreshToken:[_currentOauthCredential refreshToken] success:^(AFOAuthCredential * _Nonnull credential) {