//
//  VivochaDataCollection.h
//  ios-sdk
//
//  Created by Michael Siddi on 28/10/13.
//  Copyright (c) 2013 Vivocha Inc. All rights reserved.
//

#import <Foundation/Foundation.h>

/// Represents the type for a `VivochaDataCollectionField` object.
typedef NS_ENUM(NSUInteger, VivochaDataCollectionFieldType) {
    /// Represents a string that contains a date in ISO8601 format (UTC)
    VivochaDataCollectionFieldTypeDate,
    
    /// Represents a string that contains an email address
    VivochaDataCollectionFieldTypeEmail,
    
    /// Represents a string that contains a link
    VivochaDataCollectionFieldTypeLink,
    
    /// Represents a string that contains user's nickname
    VivochaDataCollectionFieldTypeNickname,
    
    /// Represents a string that contains user's first name
    VivochaDataCollectionFieldTypeFirstName,
    
    /// Represents a string that contains user's last name
    VivochaDataCollectionFieldTypeLastName,
    
    /// Represents a string that contains a number
    VivochaDataCollectionFieldTypeNumber,
    
    /// Represents a string that contains a phone number
    VivochaDataCollectionFieldTypePhone,
    
    /// Represents a string
    VivochaDataCollectionFieldTypeText,
    
    /// Represents a string that contains a boolean value (true|false)
    VivochaDataCollectionFieldTypeCheckbox,
    
    /// Represents a string that contains a password
    VivochaDataCollectionFieldTypePassword,
    
    /// Represents a string that contains a rating value
    VivochaDataCollectionFieldTypeRating
    
};

/// Represents a field in the data collection
@interface VivochaDataCollectionField : NSObject

///The field name
@property (nonatomic, retain) NSString *name;

///The field description
@property (nonatomic, retain) NSString *desc;

///The field type
@property (nonatomic, assign) VivochaDataCollectionFieldType type;

///The field value
@property (nonatomic, retain) NSString *value;

///Defines if the field will be visible to the agent
@property (nonatomic, assign) BOOL visible;

///If the type is checkbox, defines if it should be represented as checked
@property (nonatomic, assign) BOOL checked;

///If the secure value is set to false, the server will not follow the encryption rules set on your Vivocha account but will leave the field unencrypted.
@property (nonatomic, assign) BOOL secure;

/**
 *  Factory method for a VivochaDataCollectionField object.
 *
 *  @param name     the field name
 *  @param type     the field type
 *  @param value    the field value
 *  @param desc     the field description
 *  @param visibile the field visibility
 *  @param checked  If the field type is a CheckBox, this parameter sets if the field is checked or not.
 *
 *  @return the field object.
 */
+ (VivochaDataCollectionField *) fieldWithName:(NSString *)name andType:(VivochaDataCollectionFieldType)type andValue:(NSString *)value andDescription:(NSString *)desc andIsVisibile:(BOOL)visibile andIsChecked:(BOOL)checked;

/**
 *  Initializes a VivochaDataCollectionField object.
 *
 *  @param name     the field name
 *  @param type     the field type
 *  @param value    the field value
 *  @param desc     the field description
 *  @param visibile the field visibility
 *  @param checked  If the field type is a CheckBox, this parameter sets if the field is checked or not.
 *
 *  @return the initializes field object.
 */
- (id) initWithName:(NSString *)name andType:(VivochaDataCollectionFieldType)type andValue:(NSString *)value andDescription:(NSString *)desc andIsVisibile:(BOOL)visibile andIsChecked:(BOOL)checked;

@end


/// Represents a form in the data collection
@interface VivochaDataCollectionForm : NSObject

/// The form name
@property (nonatomic, retain) NSString *name;

/// The form description
@property (nonatomic, retain) NSString *desc;

/// The collection of `VivochaDataCollectionField` objects inside the form
@property (nonatomic, retain) NSMutableArray *data;

/**
 *  Factory method for a VivochaDataCollectionForm object.
 *
 *  @param name        the form name
 *  @param description the form descriptrion
 *
 *  @return the form object.
 */
+ (VivochaDataCollectionForm *) dataCollectionFormWithName:(NSString *)name andDescription:(NSString *)description;

/**
 *  Initializes a VivochaDataCollectionForm object
 *
 *  @param name        the form name
 *  @param description the form description
 *
 *  @return the initialized form object.
 */
- (id) initWithName: (NSString *) name andDescription:(NSString *)description;

/**
 *  Adds a field in a form.
 *
 *  @param field the field that will be added to the form.
 */
- (void) addField: (VivochaDataCollectionField *)field;
@end

///Represent the data collection
@interface VivochaDataCollection : NSObject

/// The collection of `VivochaDataCollectionForm` objects inside the data collection
@property (nonatomic, retain) NSMutableArray *forms;

/**
 *  Factory method that returns a VivochaDataCollection object.
 *
 *  @param formsArray the forms that will be included in the data collection.
 *
 *  @return the data collection.
 */

+ (VivochaDataCollection *) dataCollectionWithForms:(NSArray *)formsArray;

/**
 *  Adds a form in a data collection
 *
 *  @param aForm the form that will be added to the data collection.
 */
- (void) addForm:(VivochaDataCollectionForm *) aForm;

@end



