FIRFADApiService.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Copyright 2020 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import <Foundation/Foundation.h>
  15. #import "FirebaseAppDistribution/Sources/Private/FIRAppDistributionRelease.h"
  16. #import "FirebaseInstallations/Source/Library/Private/FirebaseInstallationsInternal.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. /**
  19. * @related FIRFADApiError
  20. *
  21. * The completion handler invoked when the list releases request returns.
  22. * If the call fails we return the appropriate `error code`, described by
  23. * `AppDistributionApiError`.
  24. *
  25. * @param releases The releases that are available to be installed.
  26. * @param error The error describing why the new build request failed.
  27. */
  28. typedef void (^FIRFADFetchReleasesCompletion)(NSArray *_Nullable releases, NSError *_Nullable error)
  29. NS_SWIFT_NAME(AppDistributionFetchReleasesCompletion);
  30. /**
  31. * @related FIRFADApiError
  32. *
  33. * The completion handler invoked when the list releases request returns.
  34. * If the call fails we return the appropriate `error code`, described by
  35. * `AppDistributionApiError`.
  36. *
  37. * @param identifier The firebase installation identifier
  38. * @param authTokenResult The installation auth token result.
  39. * @param error The error describing why the new build request failed.
  40. */
  41. typedef void (^FIRFADGenerateAuthTokenCompletion)(
  42. NSString *_Nullable identifier,
  43. FIRInstallationsAuthTokenResult *_Nullable authTokenResult,
  44. NSError *_Nullable error) NS_SWIFT_NAME(AppDistributionGenerateAuthTokenCompletion);
  45. // Label exceptions from AppDistributionApi calls.
  46. FOUNDATION_EXPORT NSString *const kFIRFADApiErrorDomain;
  47. // A service encapsulating calls to the App Distribution Tester API
  48. @interface FIRFADApiService : NSObject
  49. // Fetch releases from the AppDistribution Tester API
  50. + (void)fetchReleasesWithCompletion:(FIRFADFetchReleasesCompletion)completion;
  51. // Generate an installation auth token and fetch the installation id
  52. + (void)generateAuthTokenWithCompletion:(FIRFADGenerateAuthTokenCompletion)completion;
  53. @end
  54. /**
  55. * @enum AppDistributionApiError
  56. */
  57. typedef NS_ENUM(NSUInteger, FIRFADApiError) {
  58. // Timeout error.
  59. FIRFADApiErrorTimeout = 0,
  60. // Token generation error
  61. FIRFADApiTokenGenerationFailure = 1,
  62. // Installation Identifier not found error
  63. FIRFADApiInstallationIdentifierError = 2,
  64. // Authentication failed
  65. FIRFADApiErrorUnauthenticated = 3,
  66. // Authorization failed
  67. FIRFADApiErrorUnauthorized = 4,
  68. // Releases or tester not found
  69. FIRFADApiErrorNotFound = 5,
  70. // Api request failure for unknown reason
  71. FIRApiErrorUnknownFailure = 6,
  72. // Failure to parse Api response
  73. FIRApiErrorParseFailure = 7,
  74. } NS_SWIFT_NAME(AppDistributionApiError);
  75. NS_ASSUME_NONNULL_END