workhabitinc/drupal-ios-sdk — pull request #87 by iamZoltanVaradi (2013-06-24 12:25:37+00:00)
Title: Path & Extension for the DIOS library

Dear Kyle,

My name is Zoltan Varadi, a i wrote an e-mail to you a few weeks ago when i couldn't manage to update user fields from the library. That time i mentioned i wrote a few extra thing for the library and i also removed the 'release'-s from the existing code, so it works with ARC too. Now i think it's finished, that's why i'm sending you my pull request.

The things i changed in the library:

Added DIOSEntity.h & DIOSEntity.m:
Sometimes i must to work with entities that has Services endpoints, so i decided it's a good idea to create Entity classes. However i'm pretty sure for complex entities everyone will have to write their own, but for simple ones (like userpoints) it was working fine.

Changes DIOSUser.h & DIOSUser.m
For several apps now i had to work with multiple user logins. In most cases i don't care if we already have a user logged in, i just want to make sure that a specific user is logged in. That's why i added the userMakeSureUserIsLoggedInWithUserName function. It first checks if we have a user logged in. If not, then logs in the user with the given username and password. Else if we have someone logged in, we check if the usernames match, because then i have the one logged in who i wanted. If not, then log out and in the logout's success block, log the user in.
Same thing i did with the user logout. Regardless who logged in (if any) make sure the app's in a logged out state.

Username and e-mail validation for registration.
Whenever a user's going to be registered, the Drupal site's going to check if the username and password is in a valid format. If not, the request's going to fail, and in the failure block's error description developers can see the reason why. I checked the username field validation function's php code and ported it to Objective C. This way it's easier for developers to develop a registration function because by using the function userValidateUserName we can make sure the drupal site's going to accept the registration request. Same thing i did with email validation.

Nothing else has been changed.
I modified the documentation too, but i don't know how to update it with the pull request.

Please let me know what you think about it and if you feel it needs modifications.

Sincerely,

Zoltan Varadi - Pronovix