FBSDKTournamentFetcher.swift 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  3. *
  4. * You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
  5. * copy, modify, and distribute this software in source code or binary form for use
  6. * in connection with the web services and APIs provided by Facebook.
  7. *
  8. * As with any software that integrates with the Facebook platform, your use of
  9. * this software is subject to the Facebook Developer Principles and Policies
  10. * [http://developers.facebook.com/policy/]. This copyright notice shall be
  11. * included in all copies or substantial portions of the software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  15. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  16. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  17. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  18. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19. */
  20. import FBSDKCoreKit
  21. import FBSDKGamingServicesKit
  22. import Foundation
  23. /// An internal class for fetching tournament objects.
  24. @objcMembers
  25. public final class FBSDKTournamentFetcher: NSObject {
  26. public override init() {
  27. super.init()
  28. }
  29. /**
  30. Attempts to fetch all the tournaments where the current logged in user is a participant ;
  31. - Parameter completionHandler: The caller's completion handler to invoke once the graph request is complete
  32. */
  33. public func fetchTournaments(completionHandler: @escaping ([FBSDKTournament]?, Error?) -> Void) {
  34. TournamentFetcher()
  35. .fetchTournaments { result in
  36. switch result {
  37. case let .success(tournaments):
  38. completionHandler(tournaments.map(FBSDKTournament.init), nil)
  39. case let .failure(error):
  40. completionHandler(nil, error)
  41. }
  42. }
  43. }
  44. }