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.

46 lines
1.3 KiB

  1. //
  2. // ReciepientListService.swift
  3. //
  4. //
  5. // Created by ccr on 26/08/2018.
  6. //
  7. import Foundation
  8. import Alamofire
  9. protocol FetchRecipientList: ApiServiceType {
  10. func fetchReciepientList(success: @escaping ([Recipient]) -> (), failure: @escaping (Error) -> ())
  11. }
  12. extension FetchRecipientList {
  13. func fetchReciepientList(success: @escaping ([Recipient]) -> (), failure: @escaping (Error) -> ()) {
  14. let url = "recipients"
  15. let params = ["userId": "sisir@mailinator.com"]
  16. auth.request(method: .get, url: baseUrl + url, params: params, encoding: URLEncoding.default, success: { (response: RecipientContainer) in
  17. let model = response.data
  18. success(model)
  19. }) { (error) in
  20. failure(error)
  21. }
  22. }
  23. }
  24. protocol DeleteRecipientService: ApiServiceType {
  25. func deleteRecipient(reciepient: Recipient, success: @escaping (Recipient) -> (), failure: @escaping (Error) -> ())
  26. }
  27. extension DeleteRecipientService {
  28. func deleteRecipient(reciepient: Recipient, success: @escaping (Recipient) -> (), failure: @escaping (Error) -> ()) {
  29. let url = "recipients/" + (reciepient.recipientId ?? "")
  30. let params = ["userId": "sisir@mailinator.com"]
  31. auth.request(method: .delete, url: baseUrl + url, params: params, encoding: URLEncoding.default, success: success, failure: failure)
  32. }
  33. }