FIRIAMClearcutHttpRequestSender.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright 2018 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. @class FIRIAMClearcutLogRecord;
  18. @protocol FIRIAMTimeFetcher;
  19. NS_ASSUME_NONNULL_BEGIN
  20. // class for sending requests to clearcut over its http API
  21. @interface FIRIAMClearcutHttpRequestSender : NSObject
  22. /**
  23. * Create an FIRIAMClearcutHttpRequestSender instance with specified clearcut server.
  24. *
  25. * @param serverHost API server host.
  26. * @param osMajorVersion detected iOS major version of the current device
  27. */
  28. - (instancetype)initWithClearcutHost:(NSString *)serverHost
  29. usingTimeFetcher:(id<FIRIAMTimeFetcher>)timeFetcher
  30. withOSMajorVersion:(NSString *)osMajorVersion;
  31. /**
  32. * Sends a batch of FIRIAMClearcutLogRecord records to clearcut server.
  33. * @param logs an array of log records to be sent.
  34. * @param completion is the handler to triggered upon completion. 'success' is a bool
  35. * to indicate if the sending is successful. 'shouldRetryLogs' indicates if these
  36. * logs need to be retried later on. On success case, waitTimeInMills is the value
  37. * returned from clearcut server to indicate the minimal wait time before another
  38. * send request can be attempted.
  39. */
  40. - (void)sendClearcutHttpRequestForLogs:(NSArray<FIRIAMClearcutLogRecord *> *)logs
  41. withCompletion:(void (^)(BOOL success,
  42. BOOL shouldRetryLogs,
  43. int64_t waitTimeInMills))completion;
  44. @end
  45. NS_ASSUME_NONNULL_END