No Description

AWSCognitoRecord.h 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. //
  2. // Copyright 2014-2016 Amazon.com,
  3. // Inc. or its affiliates. All Rights Reserved.
  4. //
  5. // Licensed under the Amazon Software License (the "License").
  6. // You may not use this file except in compliance with the
  7. // License. A copy of the License is located at
  8. //
  9. // http://aws.amazon.com/asl/
  10. //
  11. // or in the "license" file accompanying this file. This file is
  12. // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  13. // CONDITIONS OF ANY KIND, express or implied. See the License
  14. // for the specific language governing permissions and
  15. // limitations under the License.
  16. //
  17. #import <Foundation/Foundation.h>
  18. typedef NS_ENUM(NSInteger, AWSCognitoRecordValueType) {
  19. AWSCognitoRecordValueTypeUnknown,
  20. AWSCognitoRecordValueTypeString,
  21. AWSCognitoRecordValueTypeDeleted,
  22. };
  23. /**
  24. An object that encapsulates the record value.
  25. */
  26. @interface AWSCognitoRecordValue : NSObject
  27. /**
  28. The type of the record value.
  29. The record value datatypes.
  30. <ul>
  31. <li>AWSCognitoRecordValueTypeUnknown - Unknown type.</li>
  32. <li>AWSCognitoRecordValueTypeString - The string value.</li>
  33. <li>AWSCognitoRecordValueTypeDeleted - A deleted value.</li>
  34. </ul>
  35. */
  36. @property (nonatomic, readonly) AWSCognitoRecordValueType type;
  37. /**
  38. Initializes a AWSCognitoRecordValue with the given string value.
  39. The type property is automatically set to AWSCognitoRecordValueTypeString.
  40. @param value The string value of the AWSCognitoRecordValue.
  41. @return The initialized instance
  42. */
  43. - (instancetype)initWithString:(NSString *)value;
  44. /**
  45. Returns the string value.
  46. @return The string value stored by the record value object.
  47. */
  48. - (NSString *)string;
  49. @end
  50. @interface AWSCognitoRecordMetadata : NSObject
  51. /**
  52. Record ID or name.
  53. */
  54. @property (nonatomic, readonly) NSString *recordId;
  55. /**
  56. The last date the record was modified.
  57. */
  58. @property (nonatomic, readonly) NSDate *lastModified;
  59. /**
  60. The ID of the client that last modified the record. Set in AWSCognitoConfig under the clientID property.
  61. */
  62. @property (nonatomic, strong) NSString *lastModifiedBy;
  63. /**
  64. Boolean indicating whether or not the record has updates/deletes that need to be synced with the server.
  65. */
  66. @property (nonatomic, readonly, getter = isDirty) BOOL dirty;
  67. /**
  68. Integer value indicating how many times the record has been written since the last sync.
  69. The value is 0 if the record has not been modified. The value is incremented by 1 each time the record is updated.
  70. The value is set to -1 when the record is marked as deleted from the local database.
  71. */
  72. @property (nonatomic, assign) int64_t dirtyCount;
  73. /**
  74. Integer value of the server sync count of the record.
  75. */
  76. @property (nonatomic, assign) int64_t syncCount;
  77. - (instancetype)initWithId:(NSString *)recordId;
  78. /**
  79. Checks if the metadata matches.
  80. @param object The object to be compared to the receiver.
  81. May be nil, in which case this method returns NO.
  82. @return YES if the receiver and object have equal metadata, otherwise NO.
  83. */
  84. - (BOOL)isEqualMetadata:(id)object;
  85. @end
  86. @interface AWSCognitoRecord : AWSCognitoRecordMetadata
  87. /**
  88. The data for the record.
  89. */
  90. @property (nonatomic, strong) AWSCognitoRecordValue *data;
  91. /**
  92. Initializes a AWSCognitoRecord with the given recordID, given data, and a dirtyCount and recordVersion of 0.
  93. @param recordId The record ID of the AWSCognitoRecord
  94. @param data the initial data that the AWSCognitoRecord will contain
  95. */
  96. - (instancetype)initWithId:(NSString *)recordId
  97. data:(AWSCognitoRecordValue *)data;
  98. /**
  99. Returns true if this record has been deleted
  100. @return YES if the record is deleted, NO otherwise
  101. */
  102. - (BOOL)isDeleted;
  103. @end