|
|
|
@ -47,6 +47,31 @@ public struct UserApiManager: UserDataManager {
|
|
|
|
|
fatalError("Not implemented yet")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public func getGifts(completion : @escaping (Int, Int)-> ()) {
|
|
|
|
|
let url = URL(string: allInApi + "users/gift")!
|
|
|
|
|
|
|
|
|
|
var request = URLRequest(url: url)
|
|
|
|
|
request.httpMethod = "GET"
|
|
|
|
|
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
|
|
|
request.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
|
|
|
|
|
|
|
|
|
|
URLSession.shared.dataTask(with: request) { data, response, error in
|
|
|
|
|
if let data = data {
|
|
|
|
|
print ("ALLIN : get gifts of the day")
|
|
|
|
|
if let httpResponse = response as? HTTPURLResponse {
|
|
|
|
|
if httpResponse.statusCode == 200 {
|
|
|
|
|
if let stringValue = String(data: data, encoding: .utf8), let intValue = Int(stringValue) {
|
|
|
|
|
completion(httpResponse.statusCode, intValue)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
completion(httpResponse.statusCode, 0)
|
|
|
|
|
}
|
|
|
|
|
print(httpResponse.statusCode)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}.resume()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public func getOldBets(withIndex index: Int, withCount count: Int, completion: @escaping ([Bet]) -> Void) {
|
|
|
|
|
fatalError("Not implemented yet")
|
|
|
|
|
}
|
|
|
|
|