Skip to content

Instantly share code, notes, and snippets.

@Rashidium
Last active August 20, 2021 07:48
Show Gist options
  • Save Rashidium/ba7be4f74b3d5121221aa9a570efba74 to your computer and use it in GitHub Desktop.
Save Rashidium/ba7be4f74b3d5121221aa9a570efba74 to your computer and use it in GitHub Desktop.
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