Last active
August 20, 2021 07:48
-
-
Save Rashidium/ba7be4f74b3d5121221aa9a570efba74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Alamofire | |
... | |
private func getCoupon() { | |
let urlStr = "\(serverUrl)\(EndpointTails.group_last_coupon_one.rawValue)" | |
AF.request(urlStr, method: .get).responseDecodable { (response: DataResponse<PanpaResponse<Coupon>, AFError>) in | |
if let panpaResponse = response.value { | |
switch panpaResponse.status { | |
case .success: | |
guard let coupon: Coupon = panpaResponse.data else { return } | |
print(coupon.name) | |
case .failed: | |
print("API error with message: \(panpaResponse.message)") | |
} | |
} else { | |
let errorResponse = PanpaResponse<LoginBase>() | |
print("API error with message: \(errorResponse.message)") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment