// clang-format off
/** @file FIRStorageMetadata.h
    @brief Firebase SDK
    @copyright Copyright 2016 Google Inc.
    @remarks Use of this SDK is subject to the Google APIs Terms of Service:
    https://developers.google.com/terms/
 */
// clang-format on

#import <Foundation/Foundation.h>

@class FIRStorageReference;

NS_ASSUME_NONNULL_BEGIN

/**
 * Class which represents the metadata on an object in Firebase Storage. This metadata is
 * returned on successful operations, and can be used to retrieve download URLs, content types,
 * and a FIRStorage reference to the object in question. Full documentation can be found at the GCS
 * Objects#resource docs.
 * @see https://cloud.google.com/storage/docs/json_api/v1/objects#resource
 */
@interface FIRStorageMetadata : NSObject<NSCopying>

/**
 * The name of the bucket containing this object.
 */
@property(copy, nonatomic, readonly) NSString *bucket;

/**
 * Cache-Control directive for the object data.
 */
@property(copy, nonatomic, nullable) NSString *cacheControl;

/**
 * Content-Disposition of the object data.
 */
@property(copy, nonatomic, nullable) NSString *contentDisposition;

/**
 * Content-Encoding of the object data.
 */
@property(copy, nonatomic, nullable) NSString *contentEncoding;

/**
 * Content-Language of the object data.
 */
@property(copy, nonatomic, nullable) NSString *contentLanguage;

/**
 * Content-Type of the object data.
 */
@property(copy, nonatomic, nullable) NSString *contentType;

/**
 * The content generation of this object. Used for object versioning.
 */
@property(readonly) int64_t generation;

/**
 * User-provided metadata, in key/value pairs.
 */
@property(copy, nonatomic, nullable) NSDictionary<NSString *, NSString *> *customMetadata;

/**
 * The version of the metadata for this object at this generation. Used
 * for preconditions and for detecting changes in metadata. A metageneration number is only
 * meaningful in the context of a particular generation of a particular object.
 */
@property(readonly) int64_t metageneration;

/**
 * The name of this object, in gs://bucket/path/to/object.txt, this is object.txt.
 */
@property(copy, nonatomic, readonly, nullable) NSString *name;

/**
 * The full path of this object, in gs://bucket/path/to/object.txt, this is path/to/object.txt.
 */
@property(copy, nonatomic, readonly, nullable) NSString *path;

/**
 * Content-Length of the data in bytes.
 */
@property(readonly) int64_t size;

/**
 * The creation time of the object in RFC 3339 format.
 */
@property(copy, nonatomic, readonly, nullable) NSDate *timeCreated;

/**
 * The modification time of the object metadata in RFC 3339 format.
 */
@property(copy, nonatomic, readonly, nullable) NSDate *updated;

/**
 * A reference to the object in Firebase Storage.
 */
@property(strong, nonatomic, readonly, nullable) FIRStorageReference *storageReference;

/**
 * An array containing all download URLs available for the object.
 */
@property(strong, nonatomic, readonly, nullable) NSArray<NSURL *> *downloadURLs;

/**
 * Creates an instanece of FIRStorageMetadata from the contents of a dictionary.
 * @return An instance of FIRStorageMetadata that represents the contents of a dictionary.
 */
- (nullable instancetype)initWithDictionary:(NSDictionary *)dictionary NS_DESIGNATED_INITIALIZER;

/**
 * Creates an NSDictionary from the contents of the metadata.
 * @return An NSDictionary that represents the contents of the metadata.
 */
- (NSDictionary *)dictionaryRepresentation;

/**
 * Determines if the current metadata represents a "file".
 */
@property(readonly, getter=isFile) BOOL file;

/**
 * Determines if the current metadata represents a "folder".
 */
@property(readonly, getter=isFolder) BOOL folder;

/**
 * Retrieves a download URL for the given object, or nil if none exist.
 * Note that if there are many valid download tokens, this will always return the first
 * valid token created.
 */
- (nullable NSURL *)downloadURL;

@end

NS_ASSUME_NONNULL_END
