123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- //
- // Copyright 2014-2016 Amazon.com,
- // Inc. or its affiliates. All Rights Reserved.
- //
- // Licensed under the Amazon Software License (the "License").
- // You may not use this file except in compliance with the
- // License. A copy of the License is located at
- //
- // http://aws.amazon.com/asl/
- //
- // or in the "license" file accompanying this file. This file is
- // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
- // CONDITIONS OF ANY KIND, express or implied. See the License
- // for the specific language governing permissions and
- // limitations under the License.
- //
-
- #import <Foundation/Foundation.h>
-
- typedef NS_ENUM(NSInteger, AWSCognitoRecordValueType) {
- AWSCognitoRecordValueTypeUnknown,
- AWSCognitoRecordValueTypeString,
- AWSCognitoRecordValueTypeDeleted,
- };
-
- /**
- An object that encapsulates the record value.
- */
- @interface AWSCognitoRecordValue : NSObject
-
-
- /**
- The type of the record value.
-
- The record value datatypes.
- <ul>
- <li>AWSCognitoRecordValueTypeUnknown - Unknown type.</li>
- <li>AWSCognitoRecordValueTypeString - The string value.</li>
- <li>AWSCognitoRecordValueTypeDeleted - A deleted value.</li>
- </ul>
- */
- @property (nonatomic, readonly) AWSCognitoRecordValueType type;
-
- /**
- Initializes a AWSCognitoRecordValue with the given string value.
- The type property is automatically set to AWSCognitoRecordValueTypeString.
-
- @param value The string value of the AWSCognitoRecordValue.
-
- @return The initialized instance
- */
- - (instancetype)initWithString:(NSString *)value;
-
- /**
- Returns the string value.
-
- @return The string value stored by the record value object.
- */
- - (NSString *)string;
-
- @end
-
- @interface AWSCognitoRecordMetadata : NSObject
-
- /**
- Record ID or name.
- */
- @property (nonatomic, readonly) NSString *recordId;
-
- /**
- The last date the record was modified.
- */
- @property (nonatomic, readonly) NSDate *lastModified;
-
- /**
- The ID of the client that last modified the record. Set in AWSCognitoConfig under the clientID property.
- */
- @property (nonatomic, strong) NSString *lastModifiedBy;
-
- /**
- Boolean indicating whether or not the record has updates/deletes that need to be synced with the server.
- */
- @property (nonatomic, readonly, getter = isDirty) BOOL dirty;
-
- /**
- Integer value indicating how many times the record has been written since the last sync.
- The value is 0 if the record has not been modified. The value is incremented by 1 each time the record is updated.
- The value is set to -1 when the record is marked as deleted from the local database.
- */
- @property (nonatomic, assign) int64_t dirtyCount;
-
- /**
- Integer value of the server sync count of the record.
- */
- @property (nonatomic, assign) int64_t syncCount;
-
- - (instancetype)initWithId:(NSString *)recordId;
-
- /**
- Checks if the metadata matches.
-
- @param object The object to be compared to the receiver.
- May be nil, in which case this method returns NO.
- @return YES if the receiver and object have equal metadata, otherwise NO.
- */
- - (BOOL)isEqualMetadata:(id)object;
-
- @end
-
- @interface AWSCognitoRecord : AWSCognitoRecordMetadata
-
- /**
- The data for the record.
- */
- @property (nonatomic, strong) AWSCognitoRecordValue *data;
-
- /**
- Initializes a AWSCognitoRecord with the given recordID, given data, and a dirtyCount and recordVersion of 0.
-
- @param recordId The record ID of the AWSCognitoRecord
- @param data the initial data that the AWSCognitoRecord will contain
- */
- - (instancetype)initWithId:(NSString *)recordId
- data:(AWSCognitoRecordValue *)data;
-
- /**
- Returns true if this record has been deleted
-
- @return YES if the record is deleted, NO otherwise
- */
- - (BOOL)isDeleted;
-
- @end
|