From 609d4afde0cf902b6b5daa47fa95131cf2943990 Mon Sep 17 00:00:00 2001 From: gme_2 Date: Tue, 11 Sep 2018 15:12:48 +0900 Subject: [PATCH] password reset service added --- .../Interactor/ForgotPasswordInteractor.swift | 4 ++- .../ForgotPasswordInteractorIO.swift | 2 +- .../Service/ForgotPasswordServiceType.swift | 29 ++++++++++++++++++- .../Presenter/ForgotPasswordPresenter.swift | 2 +- .../View/ForgotPasswordViewController.swift | 2 +- 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/GMERemittance/Module/ForgotPassword/Application Logic/Interactor/ForgotPasswordInteractor.swift b/GMERemittance/Module/ForgotPassword/Application Logic/Interactor/ForgotPasswordInteractor.swift index 689a2b4e..2faa6fa3 100644 --- a/GMERemittance/Module/ForgotPassword/Application Logic/Interactor/ForgotPasswordInteractor.swift +++ b/GMERemittance/Module/ForgotPassword/Application Logic/Interactor/ForgotPasswordInteractor.swift @@ -27,5 +27,7 @@ class ForgotPasswordInteractor { // MARK: ForgotPassword interactor input interface extension ForgotPasswordInteractor: ForgotPasswordInteractorInput { - + func reset(username: String, dob: String) { + + } } diff --git a/GMERemittance/Module/ForgotPassword/Application Logic/Interactor/ForgotPasswordInteractorIO.swift b/GMERemittance/Module/ForgotPassword/Application Logic/Interactor/ForgotPasswordInteractorIO.swift index 04e7e6c7..fffe2361 100644 --- a/GMERemittance/Module/ForgotPassword/Application Logic/Interactor/ForgotPasswordInteractorIO.swift +++ b/GMERemittance/Module/ForgotPassword/Application Logic/Interactor/ForgotPasswordInteractorIO.swift @@ -7,7 +7,7 @@ // protocol ForgotPasswordInteractorInput: class { - + func reset(username: String, dob: String) } protocol ForgotPasswordInteractorOutput: class { diff --git a/GMERemittance/Module/ForgotPassword/Application Logic/Service/ForgotPasswordServiceType.swift b/GMERemittance/Module/ForgotPassword/Application Logic/Service/ForgotPasswordServiceType.swift index 23fb66f7..4f0c64da 100644 --- a/GMERemittance/Module/ForgotPassword/Application Logic/Service/ForgotPasswordServiceType.swift +++ b/GMERemittance/Module/ForgotPassword/Application Logic/Service/ForgotPasswordServiceType.swift @@ -8,6 +8,33 @@ import Foundation -protocol ForgotPasswordServiceType: class { + +protocol ForgotPasswordServiceType: class, PasswordResetService { } + + +protocol PasswordResetService: ApiServiceType { + func reset(username: String, dob: String, success: @escaping (String) -> (), failure: @escaping (Error) -> ()) +} + +extension PasswordResetService { + func reset(username: String, dob: String, success: @escaping (String) -> (), failure: @escaping (Error) -> ()) { + let url = baseUrl + "mobile/passwordReset" + let params = ["UserId": username,"Dob": dob] + auth.request(method: .post, url: url, params: params, success: { (response: ResponseMessage) in + if (response.errorCode ?? "") == "1" { + let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""]) + failure(error) + }else { + let model = response.message ?? "" + success(model) + } + }) { (error) in + failure(error) + } + } +} + + + diff --git a/GMERemittance/Module/ForgotPassword/User Interface/Presenter/ForgotPasswordPresenter.swift b/GMERemittance/Module/ForgotPassword/User Interface/Presenter/ForgotPasswordPresenter.swift index 53807b1c..dba103a1 100644 --- a/GMERemittance/Module/ForgotPassword/User Interface/Presenter/ForgotPasswordPresenter.swift +++ b/GMERemittance/Module/ForgotPassword/User Interface/Presenter/ForgotPasswordPresenter.swift @@ -23,7 +23,7 @@ class ForgotPasswordPresenter { extension ForgotPasswordPresenter: ForgotPasswordModuleInterface { func reset(username: String, dob: String) { - + self.interactor?.reset(username: username, dob: dob) } func cancel() { diff --git a/GMERemittance/Module/ForgotPassword/User Interface/View/ForgotPasswordViewController.swift b/GMERemittance/Module/ForgotPassword/User Interface/View/ForgotPasswordViewController.swift index 1bd3694a..1dd1aef5 100644 --- a/GMERemittance/Module/ForgotPassword/User Interface/View/ForgotPasswordViewController.swift +++ b/GMERemittance/Module/ForgotPassword/User Interface/View/ForgotPasswordViewController.swift @@ -56,7 +56,7 @@ class ForgotPasswordViewController: UIViewController { @objc private func handleDatePicker(sender: UIDatePicker) { let dateFormatter = DateFormatter() - dateFormatter.dateFormat = "dd/MM/yyyy" + dateFormatter.dateFormat = "yyyy-MM-dd" self.dobTextField.text = dateFormatter.string(from: sender.date) } }