FIRFunctions+Internal.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Copyright 2017 Google
  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 FirebaseFunctions;
  16. @protocol FIRAppCheckInterop;
  17. @protocol FIRAuthInterop;
  18. @protocol FIRMessagingInterop;
  19. @class FIRHTTPSCallableResult;
  20. @class GTMSessionFetcherService;
  21. NS_ASSUME_NONNULL_BEGIN
  22. @interface FIRFunctions (Internal)
  23. /**
  24. * Calls an http trigger endpoint.
  25. * @param name The name of the http trigger.
  26. * @param data Parameters to pass to the function. Can be anything encodable as JSON.
  27. * @param completion The block to call when the request is complete.
  28. */
  29. - (void)callFunction:(NSString *)name
  30. withObject:(nullable id)data
  31. timeout:(NSTimeInterval)timeout
  32. completion:(void (^)(FIRHTTPSCallableResult *_Nullable result,
  33. NSError *_Nullable error))completion;
  34. /**
  35. * Constructs the url for an http trigger. This is exposed only for testing.
  36. * @param name The name of the endpoint.
  37. */
  38. - (NSString *)URLWithName:(NSString *)name;
  39. /**
  40. * Sets the functions client to send requests to localhost instead of Firebase.
  41. * For testing only.
  42. */
  43. - (void)useLocalhost;
  44. // Expose internal init function to objc tests.
  45. /**
  46. * Internal initializer for the Cloud Functions client.
  47. * @param projectID The project ID for the Firebase project.
  48. * @param region The region for the http trigger, such as "us-central1".
  49. * @param customDomain A custom domain for the http trigger, such as "https://mydomain.com".
  50. * @param auth The auth provider to use (optional).
  51. * @param messaging The messaging interop to use (optional).
  52. */
  53. - (instancetype)initWithProjectID:(NSString *)projectID
  54. region:(NSString *)region
  55. customDomain:(nullable NSString *)customDomain
  56. auth:(nullable id<FIRAuthInterop>)auth
  57. messaging:(nullable id<FIRMessagingInterop>)messaging
  58. appCheck:(nullable id<FIRAppCheckInterop>)appCheck
  59. fetcherService:(GTMSessionFetcherService *)fetcherService;
  60. @end
  61. // The error domain for codes in the FIRFunctionsErrorCode enum.
  62. FOUNDATION_EXPORT NSString *const FIRFunctionsErrorDomainInternal;
  63. // The key for finding error details in the NSError userInfo.
  64. FOUNDATION_EXPORT NSString *const FIRFunctionsErrorDetailsKeyInternal;
  65. NS_ASSUME_NONNULL_END