You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.5 KiB
92 lines
2.5 KiB
//
|
|
// SetupRecipientService.swift
|
|
// GME Remit
|
|
//
|
|
// Created by InKwon James Kim on 09/08/2019.
|
|
//Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
class SetupRecipientService: SetupRecipientServiceType {
|
|
func fetchCountriesAndServiceTypes(
|
|
success: @escaping ([CountryAndServiceModel]) -> Void,
|
|
failure: @escaping (Error) -> Void
|
|
) {
|
|
let name = GMEDB.shared.user.string(.userId) ?? ""
|
|
APIRouter.fetchCountriesAndServiceTypes(username: name)
|
|
.json(success: success, failure: failure)
|
|
}
|
|
|
|
func fetchDynamicReceiverFields(
|
|
of countryID: String,
|
|
paymentModeID: String,
|
|
success: @escaping (DynamicFieldModel) -> Void,
|
|
failure: @escaping (Error) -> Void
|
|
) {
|
|
|
|
let username = GMEDB.shared.user.string(.userId) ?? ""
|
|
APIRouter.dynamicReceiver(
|
|
username: username,
|
|
countryID: countryID,
|
|
serviceTypeID: paymentModeID
|
|
).json(success: success, failure: failure)
|
|
}
|
|
|
|
func addRecipient(
|
|
at recipient: Recipient,
|
|
success: @escaping (ResponseContainerObject<Recipient>) -> Void,
|
|
failure: @escaping (Error) -> Void
|
|
) {
|
|
let id = GMEDB.shared.user.string(.senderId) ?? ""
|
|
|
|
APIRouter.addRecipient(senderID: id, recipient: recipient)
|
|
.request(
|
|
success: {(response: ResponseContainerObject<Recipient>) in
|
|
if response.errorCode != "0" {
|
|
let error = NSError(
|
|
domain: "Network",
|
|
code: 0,
|
|
message: response.message ?? "Failed Add Recipient"
|
|
)
|
|
failure(error)
|
|
}
|
|
success(response)
|
|
},
|
|
failure: failure
|
|
)
|
|
|
|
}
|
|
|
|
func editRecipient(
|
|
at recipient: Recipient,
|
|
success: @escaping (ResponseContainerObject<Recipient>) -> Void,
|
|
failure: @escaping (Error) -> Void
|
|
) {
|
|
let id = GMEDB.shared.user.string(.senderId) ?? ""
|
|
APIRouter.editRecipient(senderID: id, recipient: recipient)
|
|
.request(
|
|
success: {(response: ResponseContainerObject<Recipient>) in
|
|
if response.errorCode != "0" {
|
|
let error = NSError(
|
|
domain: "Network",
|
|
code: 0,
|
|
message: response.message ?? "Failed Edit Recipient"
|
|
)
|
|
failure(error)
|
|
}
|
|
success(response)
|
|
},
|
|
failure: failure
|
|
)
|
|
}
|
|
|
|
func validateAccount(
|
|
of model: ValidateAccountRequest,
|
|
success: @escaping () -> Void,
|
|
failure: @escaping (Error) -> Void
|
|
) {
|
|
APIRouter.validateAccount(validateModel: model)
|
|
.json(success: success, failure: failure)
|
|
}
|
|
}
|