- Add DELETE Method in PNObject+PNObjectConnection

- Fix POST|GET Methods in PNObject+PNObjectConnection
This commit is contained in:
Giuseppe Nucifora 2016-04-05 16:43:07 +02:00
parent 7752bf3e18
commit 9c70842820
9 changed files with 40 additions and 13 deletions

View File

@ -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

View File

@ -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"

View File

@ -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

View File

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

View File

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

View File

@ -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.

View File

@ -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

View File

@ -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,30 @@
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) {
failure(nil,error);
}
}];
}
}
+ (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) {
@ -148,7 +171,6 @@
PNObjectResponse = resposeArray;
}
}
return PNObjectResponse;
}

View File

@ -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) {