Created
March 31, 2021 05:44
-
-
Save MickaelCruzDB/5d02905b94b3a2fdbefc428b29c758f5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
static | |
func badge(_ completion: @escaping (Result<(HTTPURLResponse, Int?), Error>) -> Void) { | |
struct Payload: Decodable { | |
var value: Int | |
} | |
GalaxyRouter | |
.request(.myBadge) | |
.build(headers: ["Authorization": "Bearer \(getUserInfos()?.value(forKeyPath: "token") as! String)", ]) | |
.build(parameters: [ | |
"device": UIDevice.current.identifierForVendor?.uuidString, | |
]) | |
.completion(Payload.self) { result in | |
print("result : fonction badge : \(result)") ---> retourne 400 | |
switch result { | |
case .success((let response, let payload)): | |
if payload != nil { | |
if let payload = payload { | |
// setUserInfos(badge: 9000001) | |
// completion(.success((response, 9000001))) | |
setUserInfos(badge: payload.value) | |
print("BADGE ==> \(payload.value)") | |
completion(.success((response, payload.value))) | |
} else { completion(.success((response, nil))) } | |
} | |
case .failure(let error): | |
completion(.failure(error)) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment