import
{
    AttributeResponseDTO,
    AttributeDTO,
    ResponseContainerDTO,
    ItemContainerDTO,
    LocationNameIdentityDTO,
    IdLocationNameIdentityDTO,
    ResponseDetailsType,
    IdLocationNameEntityIdentityResponseDTO,
    IdLocationNameIdentityResponseDTO,
    ExistingItemIdentityDTO,
    ObjectTypeIdentityDTO,
    WSAttributeFlags,
    NewItemIdentityDTO,
    ItemResponseContainerDTO
} from "./Windream.WebService";

import { IndexingDetailsResponseDTO } from './Windream.WebService.Indexing';


export interface IDocumentsController
{
    Create(parameter: CreateDocumentDTO): DocumentResponseContainerDTO;
    CreateBulk(parameters: CreateDocumentDTO[]): DocumentResponseContainerDTO[];
    Delete(parameter: DeleteDocumentDTO): DocumentResponseContainerDTO;
    DeleteBulk(parameters: DeleteDocumentDTO[]): DocumentResponseContainerDTO[];
    Update(parameter: UpdateDocumentDTO): DocumentResponseContainerDTO;
    UpdateBulk(parameters: UpdateDocumentDTO[]): DocumentResponseContainerDTO[];
    GetDetails(id: Number): DocumentResponseContainerDTO;
    GetDetails(parameter: GetDocumentDetailsDTO): DocumentResponseContainerDTO;
    GetDetailsBulk(parameters: GetDocumentDetailsDTO[]): DocumentResponseContainerDTO[];
    GetHistory(parameters: GetDocumentDetailsDTO): HistoryResponseContainerDTO[];
    Move(parameter: MoveDocumentDTO): DocumentResponseContainerDTO;
    MoveBulk(parameters: MoveDocumentDTO[]): DocumentResponseContainerDTO[];
    Copy(parameter: CopyDocumentDTO): DocumentResponseContainerDTO;
    CopyBulk(parameters: CopyDocumentDTO[]): DocumentResponseContainerDTO[];
    UndoCheckOut(parameter: DocumentItemContainerDTO): DocumentResponseContainerDTO;
    UndoCheckOutBulk(parameters: DocumentItemContainerDTO[]): DocumentResponseContainerDTO[];
    Archive(parameter: DocumentItemContainerDTO): DocumentResponseContainerDTO;
    ArchiveBulk(parameters: DocumentItemContainerDTO[]): DocumentResponseContainerDTO[];
    HtmlPreview(parameter: HtmlPreviewDTO): HtmlPreviewResponseContainerDTO;
    Download(parameter: DownloadDocumentDTO): ResponseContainerDTO;
    Upload(parameter: UploadDocumentDTO): DocumentResponseContainerDTO;
    GetBinarySize(parameter: DocumentItemContainerDTO): DocumentResponseContainerDTO;
}

export const enum CopyDocumentFlags
{
    DocumentOnly = 0,
    WithPreVersions = 1
}

export const enum DeleteDocumentFlags
{
    IncludePreVersions = 2
}

export const enum DownloadFlags
{
    Checkout = 1
}

export const enum UploadFlags
{
    CreateObject = 1,
    CheckIn = 2,
    CreateNewVersion = 4,
    UseDefaultLocation = 8
}

export interface DownloadDocumentDTO
{
    Flags: DownloadFlags;
    Item: IdLocationNameIdentityDTO;
}

export interface DownloadIDocumentResponseContainerDTO extends ItemResponseContainerDTO
{
    ContentLength: number;
    Stream: any;
}

export interface UploadDocumentDTO
{
    Flags: UploadFlags;
    Item: IdLocationNameIdentityDTO;
    Stream: any;
}

export interface UploadDocumentResponseContainerDTO extends DocumentResponseContainerDTO
{
    IndexingDetails: IndexingDetailsResponseDTO;
}

export interface CopyDocumentDTO
{
    Flags: CopyDocumentFlags;
    Item: IdLocationNameIdentityDTO;
    ResponseDetails: ResponseDetailsType;
    Target: LocationNameIdentityDTO;
}

export interface CreateDocumentDTO
{
    CreateFolder: boolean;
    Item: NewDocumentDTO;
    ResponseDetails: ResponseDetailsType;
}

export interface DeleteDocumentDTO
{
    Flags: DeleteDocumentFlags;
    Item: IdLocationNameIdentityDTO;
    ResponseDetails: ResponseDetailsType;
}

export interface DocumentItemContainerDTO extends ItemContainerDTO
{
}

export interface DocumentResponseContainerDTO extends ResponseContainerDTO
{
    Item: DocumentResponseDTO;
}

export interface DocumentResponseDTO extends IdLocationNameEntityIdentityResponseDTO
{
    Attributes: AttributeResponseDTO[];
    ObjectType: ObjectTypeIdentityDTO;
    ParentWindreamObject: IdLocationNameIdentityResponseDTO;
}

export interface ExistingDocumentDTO extends ExistingItemIdentityDTO
{
    Attributes: AttributeDTO[];
    ObjectType: ObjectTypeIdentityDTO;
}

export interface GetDocumentDetailsDTO
{
    AttributeFlags: WSAttributeFlags;
    Item: IdLocationNameIdentityDTO;
    Values: string[];
}

export interface MoveDocumentDTO
{
    IncludePreVersions: boolean;
    Item: IdLocationNameIdentityDTO;
    ResponseDetails: ResponseDetailsType;
    Target: LocationNameIdentityDTO;
}

export interface NewDocumentDTO extends NewItemIdentityDTO
{
    Attributes: AttributeDTO[];
    ObjectType: ObjectTypeIdentityDTO;
}

export interface UpdateDocumentDTO
{
    CreateNewVersion: boolean;
    Item: ExistingDocumentDTO;
    ResponseDetails: ResponseDetailsType;
}

export interface HistoryResponseContainerDTO extends DocumentResponseContainerDTO
{
    History: HistoryItemResponseDTO[];
    CanAddNewEntries: boolean;
}

export interface HistoryItemResponseDTO
{
    HistoryDate: string;
    HistoryCreatorName: string;
    HistoryAction: string;
    HistoryComment: string;
}

export interface HistoryItemContainerDTO
{
    HistoryComment: string;
    Item: IdLocationNameIdentityDTO;
}

export interface HtmlPreviewDTO
{
    AbsoluteCacheDir: string;
    AbsoluteTemplatePath: string;
    FontDpi: number;
    GraphicType: GraphicType;
    HttpUrlPrefix: string;
    Item: IdLocationNameIdentityDTO;
    JpegQuality: number;
    NumberOfPages: number;
    Resolution: ResolutionDTO;
}

export interface HtmlPreviewResponseContainerDTO extends ItemResponseContainerDTO
{
    PreviewUrl: string;
}

export interface ResolutionDTO
{
    Height: number;
    Width: number;
}

export const enum GraphicType
{
    Undefined = 0,
    Jpeg = 1,
    Gif = 2,
    Png = 3
}

export const enum LifecyclePeriodNorms {
    None = 131072,
    MonthFirst = 262144,
    MonthLast = 524288,
    QuarterFirst = 1048576,
    QuarterLast = 2097152,
    YearFirst = 4194304,
    YearLast = 8388608
}

export const enum LifecyclePeriodUnits {
    Day = 16777216,
    Week = 33554432,
    Month = 67108864,
    Year = 134217728
}

export const enum LifecyclePeriodBases {
    EndEditPeriod = 1,
    Created = 16384,
    Updated = 32768,
    EndPreviousPeriod = 65536
}

export interface LifecycleParameterDTO {
    Start: string,
    End: string,
    Norm: LifecyclePeriodNorms;
    Unit: LifecyclePeriodUnits;
    Period: number;
    PeriodBase: LifecyclePeriodBases;
    IsLifeCycleRuleChanged: boolean;
    IsManualChanged: boolean;
    IsManualEdit: boolean;
    IsManualMove: boolean;
    IsNoAutoMove: boolean;
    IsNoSelfContained: boolean;
}

export interface LifecycleResponseContainerDTO extends ResponseContainerDTO {
    Document: LifecycleResponseDTO;
    ObjectType: LifecycleResponseDTO;
}

export interface LifecycleResponseDTO {
    Editable: LifecycleParameterDTO;
    Archived: LifecycleParameterDTO;
}