//
//  OMCLocationObject.h
//  OMCLocation
//
//  Copyright © 2016 Oracle. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "OMCCore/OMCCore.h"
@class OMCLocation;

NS_ASSUME_NONNULL_BEGIN

/**
 A location object is one of the major components of the Location
 service model. It can represent an asset, device, or place.
 */
@interface OMCLocationObject : NSObject

/**
 The location object's location service proxy.
 */
@property (readonly) OMCLocation* location;

/**
 The location object's raw properties (corresponding to the JSON payload).
 */
@property (readonly) NSDictionary<NSString*, id>* properties;

/**
 The location object's ID, a unique number generated by the Location service.
 */
@property (readonly) NSNumber* id_;

/**
 The location object's name.
 */
@property (readonly) NSString* name;

/**
 The location object's description.
 */
@property (readonly, nullable) NSString* description_;

/**
 The name of the user who created the location object.
 */
@property (readonly, nullable) NSString* createdBy;

/**
 The date the location object was created.
 */
@property (readonly, nullable) NSDate* createdOn;

/**
 The name of the user who last modified the location object.
 */
@property (readonly, nullable) NSString* modifiedBy;

/**
 The date the location object was last modified.
 */
@property (readonly, nullable) NSDate* modifiedOn;

/**
 A dictionary of user-defined string attributes.
 */
@property (readonly) NSDictionary<NSString*, NSString*>* attributes;

/**
 Returns the value of the specified attribute.
 @param key The attribute's user-defined key.
 */
- (nullable NSString*)attributeForKey:(NSString*)key;

/**
 Asynchronously refreshes the object's state from the Location service
 and invokes the specified completion handler when complete.
 @param completionHandler The block invoked when the request to the
    Location service is finished. The completion block will be invoked on the
    main dispatch queue.
 */
- (void)refreshWithCompletionHandler:(OMCErrorCompletionBlock)completionHandler;

@end


#pragma mark - Constants

/**
 The name of the location object ID JSON property (`id`).
 */
extern NSString* const OMCLocationObjectIDPropertyName;

/**
 The name of the location object name JSON property (`name`).
 */
extern NSString* const OMCLocationObjectNamePropertyName;

/**
 The name of the location object description JSON property (`description`).
 */
extern NSString* const OMCLocationObjectDescriptionPropertyName;

/**
 The name of the location object created-by JSON property (`createdBy`).
 */
extern NSString* const OMCLocationObjectCreatedByPropertyName;

/**
 The name of the location object created-on JSON property (`createdOn`).
 */
extern NSString* const OMCLocationObjectCreatedOnPropertyName;

/**
 The name of the location object modified-by JSON property (`modifiedBy`).
 */
extern NSString* const OMCLocationObjectModifiedByPropertyName;

/**
 The name of the location object modified-on JSON property (`modifiedOn`).
 */
extern NSString* const OMCLocationObjectModifiedOnPropertyName;

/**
 The name of the location object attributes JSON property (`attributes`).
 */
extern NSString* const OMCLocationObjectAttributesPropertyName;

NS_ASSUME_NONNULL_END
