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.

58 lines
1.3 KiB

5 years ago
5 years ago
3 years ago
5 years ago
5 years ago
3 years ago
5 years ago
3 years ago
5 years ago
  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 accessCode(
  16. userId: String,
  17. password: String,
  18. firebaseToken: String,
  19. success: @escaping (User?) -> Void,
  20. failure: @escaping (Error) -> Void
  21. )
  22. }
  23. extension LoginApiService {
  24. func accessCode(
  25. userId: String,
  26. password: String,
  27. firebaseToken: String,
  28. success: @escaping (User?) -> Void,
  29. failure: @escaping (Error) -> Void
  30. ) {
  31. APIRouter
  32. .accesscode(username: userId, password: password, firebasToken: firebaseToken)
  33. .request(
  34. needsAuthorization: false,
  35. success: {(response: UserContainer ) in
  36. if (response.errorCode ?? "") == "1" {
  37. let error = NSError.init(
  38. domain: "Network",
  39. code: 0,
  40. userInfo: [NSLocalizedDescriptionKey : response.message ?? ""]
  41. )
  42. failure(error)
  43. } else {
  44. let model = response.data
  45. success(model)
  46. }
  47. },
  48. failure: {failure($0)}
  49. )
  50. }
  51. }