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.

41 lines
1.2 KiB

  1. //
  2. // LoginService.swift
  3. // GMERemittance
  4. //
  5. // Created by gme_2 on 07/09/2018.
  6. //Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import Foundation
  9. class LoginService: LoginServiceType {
  10. // MARK: Properties
  11. // MARK: Initialization
  12. // MARK: Data management
  13. }
  14. protocol LoginApiService: ApiServiceType {
  15. func _login(userId: String, password: String ,success: @escaping (User?) -> (), failure: @escaping (Error) -> ())
  16. }
  17. extension LoginApiService {
  18. func _login(userId: String, password: String, success: @escaping (User?) -> (), failure: @escaping (Error) -> ()) {
  19. let params = [ "userId": userId, "password": password ]
  20. let url = oldBaseUrl + "users/access-code"
  21. auth.request(method: .post, url: url, params: params,needsAuthorization: false, success: { (response: UserContainer ) in
  22. if (response.errorCode ?? "") == "1" {
  23. let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""])
  24. failure(error)
  25. }else {
  26. let model = response.data
  27. success(model)
  28. }
  29. }) { (error) in
  30. failure(error)
  31. }
  32. }
  33. }