GTLRBatchResult.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* Copyright (c) 2011 Google Inc.
  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. */
  15. #import "GTLRObject.h"
  16. #import "GTLRErrorObject.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. /**
  19. * A batch result includes a dictionary of successes, a dictionary of failures, and a dictionary of
  20. * HTTP response headers.
  21. *
  22. * Dictionary keys are request ID strings; dictionary values are @c GTLRObject for
  23. * successes, @c GTLRErrorObject for failures, @c NSDictionary for responseHeaders.
  24. *
  25. * For successes with no returned object (such as from delete operations),
  26. * the object for the dictionary entry is @c NSNull.
  27. *
  28. * The original query for each result is available from the service ticket, as shown in
  29. * the code snippet here.
  30. *
  31. * When the queries in the batch are unrelated, adding a @c completionBlock to each of
  32. * the queries may be a simpler way to handle the batch results.
  33. *
  34. * @code
  35. * NSDictionary *successes = batchResults.successes;
  36. * for (NSString *requestID in successes) {
  37. * GTLRObject *obj = successes[requestID];
  38. * GTLRQuery *query = [ticket queryForRequestID:requestID];
  39. * NSLog(@"Query %@ returned object %@", query, obj);
  40. * }
  41. *
  42. * NSDictionary *failures = batchResults.failures;
  43. * for (NSString *requestID in failures) {
  44. * GTLRErrorObject *errorObj = failures[requestID];
  45. * GTLRQuery *query = [ticket queryForRequestID:requestID];
  46. * NSLog(@"Query %@ failed with error %@", query, errorObj);
  47. * }
  48. * @endcode
  49. */
  50. @interface GTLRBatchResult : GTLRObject
  51. /**
  52. * Object results of successful queries in the batch, keyed by request ID.
  53. *
  54. * Queries which do not return an object when successful have a @c NSNull value.
  55. */
  56. @property(atomic, strong, nullable) NSDictionary<NSString *, __kindof GTLRObject *> *successes;
  57. /**
  58. * Object results of unsuccessful queries in the batch, keyed by request ID.
  59. */
  60. @property(atomic, strong, nullable) NSDictionary<NSString *, GTLRErrorObject *> *failures;
  61. /**
  62. * Any HTTP response headers that were returned for a query request. Headers are optional therefore
  63. * not all queries will have them. Query request with response headers are stored in a
  64. * dictionary and keyed by request ID.
  65. */
  66. @property(atomic, strong, nullable)
  67. NSDictionary<NSString *, NSDictionary *> *responseHeaders;
  68. @end
  69. NS_ASSUME_NONNULL_END