FIRFunctions+Testing.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. // This file is a copy of Functions/Internal/FIRFunctions+Internal.h except for the modular import
  15. // of FirebaseFunctions.
  16. #import <Foundation/Foundation.h>
  17. @import FirebaseFunctions;
  18. @protocol FIRAppCheckInterop;
  19. @protocol FIRAuthInterop;
  20. @protocol FIRMessagingInterop;
  21. @class FIRHTTPSCallableResult;
  22. NS_ASSUME_NONNULL_BEGIN
  23. @interface FIRFunctions (Testing)
  24. /**
  25. * Calls an http trigger endpoint.
  26. * @param name The name of the http trigger.
  27. * @param data Parameters to pass to the function. Can be anything encodable as JSON.
  28. * @param completion The block to call when the request is complete.
  29. */
  30. - (void)callFunction:(NSString *)name
  31. withObject:(nullable id)data
  32. timeout:(NSTimeInterval)timeout
  33. completion:(void (^)(FIRHTTPSCallableResult *_Nullable result,
  34. NSError *_Nullable error))completion;
  35. /**
  36. * Constructs the url for an http trigger. This is exposed only for testing.
  37. * @param name The name of the endpoint.
  38. */
  39. - (NSString *)URLWithName:(NSString *)name;
  40. /**
  41. * Sets the functions client to send requests to localhost instead of Firebase.
  42. * For testing only.
  43. */
  44. - (void)useLocalhost;
  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. @end
  60. NS_ASSUME_NONNULL_END