Skip to content

Commit

Permalink
Actualizado libreria.
Browse files Browse the repository at this point in the history
  • Loading branch information
matiascamiletti committed Aug 10, 2018
1 parent d95f7fb commit 4d7a3e1
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 7 deletions.
4 changes: 2 additions & 2 deletions MobileiaAuthenticationCore.podspec
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "MobileiaAuthenticationCore"
s.version = "0.0.1"
s.version = "0.0.2"
s.summary = "Libreria Authentication Core para MobileIA"

# This description is used to generate tags and improve search results.
Expand Down Expand Up @@ -81,7 +81,7 @@ Esta la base para la creacion de servicios de autenticacion y librerias que son
# Supports git, hg, bzr, svn and HTTP.
#

s.source = { :git => "https://github.com/MobileIA/mia-authentication-ios.git", :tag => "0.0.1" }
s.source = { :git => "https://github.com/MobileIA/mia-authentication-ios.git", :tag => "0.0.2" }


# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
Expand Down
12 changes: 10 additions & 2 deletions MobileiaAuthenticationCore/Entity/MIAUser.swift
Expand Up @@ -41,8 +41,16 @@ open class MIAUser : Object, Decodable {
open required convenience init(from decoder: Decoder) throws {
self.init();
let container = try decoder.container(keyedBy: MIAUserEnum.self);
id = try container.decode(Int.self, forKey: .id)
app_id = try container.decode(Int.self, forKey: .app_id)
do{
id = try container.decode(Int.self, forKey: .id)
}catch{
id = Int(try container.decode(String.self, forKey: .id))!;
}
do{
app_id = try container.decode(Int.self, forKey: .app_id)
}catch{
app_id = Int(try container.decode(String.self, forKey: .app_id))!;
}
email = try container.decode(String.self, forKey: .email)
firstname = try container.decode(String.self, forKey: .firstname)
lastname = try container.decode(String.self, forKey: .lastname)
Expand Down
6 changes: 6 additions & 0 deletions MobileiaAuthenticationCore/Realm/MIAAuthRealm.swift
Expand Up @@ -29,6 +29,12 @@ open class MIAAuthRealm : MIABaseRealm {
return users.first;
}

open func deleteAllUsers(){
let realm = getRealm();
let users = realm.objects(MIAUser.self);
realm.delete(users);
}

open override func getNameFile() -> String {
return "mobileia_authentication_" + String(Mobileia.getInstance().appId);
}
Expand Down
16 changes: 14 additions & 2 deletions MobileiaAuthenticationCore/Rest/MIAAuthRest.swift
Expand Up @@ -19,13 +19,25 @@ open class MIAAuthRest : MIABaseRest {
execute("api/oauth", method: .post, parameters: parameters, callback: callback, callbackError: callbackError);
}

open func register(parameters : Parameters, callback: @escaping (_ object: Int) -> Void, callbackError: @escaping (_ error: MIAErrorRest) -> Void) -> Void{
open func register(parameters : Parameters, callback: @escaping (_ object: MIAUser) -> Void, callbackError: @escaping (_ error: MIAErrorRest) -> Void) -> Void{
// Procesamos los parametros
let parameters = processParameters(parameters: parameters);
// Ejecutamos llamada
execute("api/register", method: .post, parameters: parameters, callback: callback, callbackError: callbackError);
}

open func update(accessToken : String, user: MIAUser, callback: @escaping (_ object: MIAUser) -> Void, callbackError: @escaping (_ error: MIAErrorRest) -> Void) -> Void{
// Procesamos los parametros
var parameters = processParameters(parameters: [:]);
parameters["access_token"] = accessToken;
parameters["firstname"] = user.firstname;
parameters["lastname"] = user.lastname;
parameters["photo"] = user.photo;
parameters["phone"] = user.phone;
// Ejecutamos llamada
execute("api/update", method: .post, parameters: parameters, callback: callback, callbackError: callbackError);
}

open func me(accessToken : String, callback: @escaping (_ object: MIAUser) -> Void, callbackError: @escaping (_ error: MIAErrorRest) -> Void) -> Void{
// Procesamos los parametros
var parameters = processParameters(parameters: [:]);
Expand Down Expand Up @@ -54,6 +66,6 @@ open class MIAAuthRest : MIABaseRest {
}

open override func getBaseUrl() -> String {
return "http://authentication.mobileia.com/";
return "https://authentication.mobileia.com/";
}
}
Expand Up @@ -18,7 +18,7 @@ open class MIAAuthBaseService : NSObject {
open var callbackAccessTokenSuccess : ((_ object: MIAAccessToken) -> Void)?;
open var callbackAccessTokenError : ((_ error: MIAErrorRest) -> Void)?;

open var callbackNewAccountSuccess : ((_ object: Int) -> Void)?;
open var callbackNewAccountSuccess : ((_ object: MIAUser) -> Void)?;

open required override init() {
super.init();
Expand Down

0 comments on commit 4d7a3e1

Please sign in to comment.