diff --git a/GMERemittance/Model/Reciepient.swift b/GMERemittance/Model/Reciepient.swift index c731797c..0ad23d5f 100644 --- a/GMERemittance/Model/Reciepient.swift +++ b/GMERemittance/Model/Reciepient.swift @@ -97,8 +97,8 @@ struct Recipient: Codable, Mappable { reasonId <- map["reasonId"] countryId <- map["countryId"] countryCode <- map["countryCode"] - idNumber <- map["IdNumber"] - idType <- map["IdType"] + idNumber <- map["idNumber"] + idType <- map["idType"] } diff --git a/GMERemittance/Model/SendMoneyCountryModel.swift b/GMERemittance/Model/SendMoneyCountryModel.swift index f5e87409..28d9d34d 100644 --- a/GMERemittance/Model/SendMoneyCountryModel.swift +++ b/GMERemittance/Model/SendMoneyCountryModel.swift @@ -11,121 +11,138 @@ import ObjectMapper class District: Mappable { - var id: String? - var name: String? - - required init?(map: Map) { - - } - - func mapping(map: Map) { - id <- map["id"] - name <- map["text"] - } - + var id: String? + var name: String? + + required init?(map: Map) { + + } + + func mapping(map: Map) { + id <- map["id"] + name <- map["text"] + } + } class Provience: Mappable { - var id: String? - var name: String? - var districts: [District]? - - required init?(map: Map) { - - } - - func mapping(map: Map) { - id <- map["id"] - name <- map["text"] - districts <- map["District"] - } + var id: String? + var name: String? + var districts: [District]? + + required init?(map: Map) { + + } + + func mapping(map: Map) { + id <- map["id"] + name <- map["text"] + districts <- map["District"] + } } class CountryModel: Mappable { - var name: String? - var id: String? - var provienceRequired: String? - var code: String? - var proviences: [Provience]? - - required init?(map: Map) { - - } - - func mapping(map: Map) { - name <- map["Name"] - id <- map["Id"] - provienceRequired <- map["IsProvienceReq"] - code <- map["Code"] - proviences <- map["Provinces"] - } - + var name: String? + var id: String? + var provienceRequired: String? + var code: String? + var proviences: [Provience]? + + required init?(map: Map) { + + } + + func mapping(map: Map) { + name <- map["Name"] + id <- map["Id"] + provienceRequired <- map["IsProvienceReq"] + code <- map["Code"] + proviences <- map["Provinces"] + } + } class TransferReason: Mappable { - var id: String? - var title: String? - - required init?(map: Map) { - - } - - func mapping(map: Map) { - id <- map["id"] - title <- map["text"] - } + var id: String? + var title: String? + + required init?(map: Map) { + + } + + func mapping(map: Map) { + id <- map["id"] + title <- map["text"] + } } class Relation: Mappable { - var id: String? - var title: String? - - required init?(map: Map) { - - } - - func mapping(map: Map) { - id <- map["id"] - title <- map["text"] - } + var id: String? + var title: String? + + required init?(map: Map) { + + } + + func mapping(map: Map) { + id <- map["id"] + title <- map["text"] + } } class SendMoneyModel: Mappable { - - var countries: [CountryModel]? - var transferReasons: [TransferReason]? - var relations: [Relation]? - - required init?(map: Map) { - - } - - func mapping(map: Map) { - countries <- map["Country"] - transferReasons <- map["TransferReasons"] - relations <- map["Relations"] - } + + var countries: [CountryModel]? + var transferReasons: [TransferReason]? + var relations: [Relation]? + +// var idTypes: [[String: String]]? + // TODO: check IDTYPES + var receiverIDTypes: [ReceiverIdType]? + + + required init?(map: Map) { + + } + + func mapping(map: Map) { + countries <- map["Country"] + transferReasons <- map["TransferReasons"] + relations <- map["Relations"] + receiverIDTypes <- map["ReceiverIdType"] + } } class SendMoneyInformationContainer: Mappable { - var errorCode: String? - var message: String? - var id: String? - var data: SendMoneyModel? - required init?(map: Map) { - - } - - func mapping(map: Map) { - errorCode <- map["ErrorCode"] - message <- map["Msg"] - id <- map["Id"] - data <- map["Data"] - } + var errorCode: String? + var message: String? + var id: String? + var data: SendMoneyModel? + required init?(map: Map) { + + } + + func mapping(map: Map) { + errorCode <- map["ErrorCode"] + message <- map["Msg"] + id <- map["Id"] + data <- map["Data"] + } } - - +class ReceiverIdType: Mappable { + var id: String? + var text: String? + var dependent: String? + + required init?(map: Map) {} + + func mapping(map: Map) { + id <- map["id"] + text <- map["text"] + dependent <- map["dependent"] + } +} diff --git a/GMERemittance/Module/SendMoneyModules/Recipient/AddReciepient/User Interface/Presenter/AddReciepientPresenter.swift b/GMERemittance/Module/SendMoneyModules/Recipient/AddReciepient/User Interface/Presenter/AddReciepientPresenter.swift index 1d93231c..b28227e8 100644 --- a/GMERemittance/Module/SendMoneyModules/Recipient/AddReciepient/User Interface/Presenter/AddReciepientPresenter.swift +++ b/GMERemittance/Module/SendMoneyModules/Recipient/AddReciepient/User Interface/Presenter/AddReciepientPresenter.swift @@ -9,128 +9,135 @@ import Foundation class AddReciepientPresenter { + + // MARK: Properties + + var transferReasons: [TransferReason] = [] + var relations: [Relation] = [] + var countries: [CountryModel] = [] + + weak var view: AddReciepientViewInterface? + var interactor: AddReciepientInteractorInput? + var wireframe: AddReciepientWireframeInput? + + // MARK: Converting entities + + func convert(models: [CountryModel]) { + let viewmodels: [SendMoneyCountryViewModel] = models.map({ + let viewmodel = SendMoneyCountryViewModel() + viewmodel.name = $0.name + viewmodel.code = $0.code + viewmodel.id = $0.id + viewmodel.proviencesRequired = $0.provienceRequired + viewmodel.proviences = self.convert(models: $0.proviences ?? []) + return viewmodel + }) + self.view?.show(countries: viewmodels) + } + + func convert(models: [Provience]) -> [SendMoneyProvienceViewModel] { + return models.map({ + var viewmodel = SendMoneyProvienceViewModel() + viewmodel.name = $0.name + viewmodel.id = $0.id + viewmodel.districts = self.convert(models: $0.districts ?? []) + return viewmodel + }) + } + + func convert(models: [District]) -> [SendMoneyDistrictViewModel] { + let viewmodels: [SendMoneyDistrictViewModel] = models.map({ + let viewmodel = SendMoneyDistrictViewModel() + viewmodel.name = $0.name + viewmodel.id = $0.id + return viewmodel + }) + return viewmodels + } + + func convert(models: [TransferReason]) { + let viewmodels: [SendMoneyTransferReasonViewModel] = models.map({ + var viewmodel = SendMoneyTransferReasonViewModel() + viewmodel.title = $0.title + viewmodel.id = $0.id + return viewmodel + }) - // MARK: Properties - - var transferReasons: [TransferReason] = [] - var relations: [Relation] = [] - var countries: [CountryModel] = [] - - weak var view: AddReciepientViewInterface? - var interactor: AddReciepientInteractorInput? - var wireframe: AddReciepientWireframeInput? - - // MARK: Converting entities - - func convert(models: [CountryModel]) { - let viewmodels: [SendMoneyCountryViewModel] = models.map({ - let viewmodel = SendMoneyCountryViewModel() - viewmodel.name = $0.name - viewmodel.code = $0.code - viewmodel.id = $0.id - viewmodel.proviencesRequired = $0.provienceRequired - viewmodel.proviences = self.convert(models: $0.proviences ?? []) - return viewmodel - }) - self.view?.show(countries: viewmodels) - } - - func convert(models: [Provience]) -> [SendMoneyProvienceViewModel] { - return models.map({ - var viewmodel = SendMoneyProvienceViewModel() - viewmodel.name = $0.name - viewmodel.id = $0.id - viewmodel.districts = self.convert(models: $0.districts ?? []) - return viewmodel - }) - } - - func convert(models: [District]) -> [SendMoneyDistrictViewModel] { - let viewmodels: [SendMoneyDistrictViewModel] = models.map({ - let viewmodel = SendMoneyDistrictViewModel() - viewmodel.name = $0.name - viewmodel.id = $0.id - return viewmodel - }) - return viewmodels - } - - func convert(models: [TransferReason]) { - let viewmodels: [SendMoneyTransferReasonViewModel] = models.map({ - var viewmodel = SendMoneyTransferReasonViewModel() - viewmodel.title = $0.title - viewmodel.id = $0.id - return viewmodel - }) - - self.view?.show(transferReasons: viewmodels) - } - - func convert(models: [Relation]) { - let viewmodels: [SendMoneyRelationViewModel] = models.map({ - var viemodel = SendMoneyRelationViewModel() - viemodel.title = $0.title - viemodel.id = $0.id - return viemodel - }) - self.view?.show(relations: viewmodels) - } - - func convert(model: ReceipientViewModel) { - var reciepient = Recipient() - reciepient.firstName = model.firstName - reciepient.middleName = model.middleName - reciepient.lastName = model.lastName - reciepient.countryId = model.countryId - reciepient.stateId = model.stateId - reciepient.districtId = model.districtId - reciepient.city = model.city - reciepient.address = model.address - reciepient.relationId = model.relationId - reciepient.reasonId = model.reasonId - reciepient.mobileNumber = model.mobileNumber - reciepient.email = model.email - self.interactor?.save(reciepient: reciepient) - } + self.view?.show(transferReasons: viewmodels) + } + + func convert(models: [Relation]) { + let viewmodels: [SendMoneyRelationViewModel] = models.map({ + var viemodel = SendMoneyRelationViewModel() + viemodel.title = $0.title + viemodel.id = $0.id + return viemodel + }) + self.view?.show(relations: viewmodels) + } + + func convert(model: ReceipientViewModel) { + var reciepient = Recipient() + reciepient.firstName = model.firstName + reciepient.middleName = model.middleName + reciepient.lastName = model.lastName + reciepient.countryId = model.countryId + reciepient.stateId = model.stateId + reciepient.districtId = model.districtId + reciepient.city = model.city + reciepient.address = model.address + reciepient.relationId = model.relationId + reciepient.reasonId = model.reasonId + reciepient.mobileNumber = model.mobileNumber + reciepient.email = model.email + reciepient.idType = model.idType + reciepient.idNumber = model.idNumber + self.interactor?.save(reciepient: reciepient) + } + } - // MARK: AddReciepient module interface +// MARK: AddReciepient module interface extension AddReciepientPresenter: AddReciepientModuleInterface { - func viewIsReady() { - self.view?.showLoading() - self.interactor?.viewIsReady() - } - - func save(model: ReceipientViewModel) { - self.convert(model: model) - } + func viewIsReady() { + self.view?.showLoading() + self.interactor?.viewIsReady() + } + + func save(model: ReceipientViewModel) { + self.convert(model: model) + } } // MARK: AddReciepient interactor output interface extension AddReciepientPresenter: AddReciepientInteractorOutput { - - func show(model: SendMoneyModel?) { - self.transferReasons = model?.transferReasons ?? [] - self.relations = model?.relations ?? [] - self.countries = model?.countries ?? [] - self.view?.hideLoading() - - self.convert(models: self.countries) - self.convert(models: self.transferReasons) - self.convert(models: self.relations) - - } + + func show(model: SendMoneyModel?) { + self.transferReasons = model?.transferReasons ?? [] + self.relations = model?.relations ?? [] + self.countries = model?.countries ?? [] + + //TODO: set IDTYPES + self.view?.setReceiverIDTypes(with: model?.receiverIDTypes) + + self.view?.hideLoading() - func show(error: Error) { - self.view?.hideLoading() - self.view?.show(error: error.localizedDescription) - } + self.convert(models: self.countries) + self.convert(models: self.transferReasons) + self.convert(models: self.relations) - func success() { - print("successfully added") - self.wireframe?.dismiss() - } + } + + func show(error: Error) { + self.view?.hideLoading() + self.view?.show(error: error.localizedDescription) + } + + func success() { + print("successfully added") + self.wireframe?.dismiss() + } } diff --git a/GMERemittance/Module/SendMoneyModules/Recipient/AddReciepient/User Interface/View/AddReciepient.storyboard b/GMERemittance/Module/SendMoneyModules/Recipient/AddReciepient/User Interface/View/AddReciepient.storyboard index 3c107bbd..25d63657 100644 --- a/GMERemittance/Module/SendMoneyModules/Recipient/AddReciepient/User Interface/View/AddReciepient.storyboard +++ b/GMERemittance/Module/SendMoneyModules/Recipient/AddReciepient/User Interface/View/AddReciepient.storyboard @@ -1,6 +1,10 @@ + + + + @@ -23,16 +27,16 @@ - + - + - + - + @@ -50,19 +54,19 @@ - + - + - + @@ -73,16 +77,16 @@ - + - + @@ -93,16 +97,16 @@ - + - + @@ -113,16 +117,16 @@ - + - + @@ -133,16 +137,16 @@ - + - + @@ -153,16 +157,16 @@ - + - + @@ -173,16 +177,16 @@ - + - + @@ -193,16 +197,16 @@ - + - + @@ -213,16 +217,16 @@ - + - + @@ -233,16 +237,16 @@ - + - + @@ -253,7 +257,7 @@ - + - + @@ -293,16 +297,17 @@ - + - + + @@ -313,22 +318,22 @@ - + - - + + - + @@ -337,7 +342,7 @@