package response

import shareddto "wucher/internal/transport/http/dto/shared"

type FileManagerFileResource struct {
	Type       string                              `json:"type" example:"file_manager_file"`
	ID         string                              `json:"id" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
	Attributes shareddto.FileManagerFileAttributes `json:"attributes"`
}

type FileManagerFileListResource struct {
	Type       string                                  `json:"type" example:"file_manager_file"`
	ID         string                                  `json:"id" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
	Attributes shareddto.FileManagerFileListAttributes `json:"attributes"`
}

type FileManagerFileResponse struct {
	Data struct {
		Type       string                              `json:"type" example:"file_manager_file"`
		ID         string                              `json:"id" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
		Attributes shareddto.FileManagerFileAttributes `json:"attributes"`
	} `json:"data"`
}

type FileManagerFileDetailResource struct {
	Type       string                                    `json:"type" example:"file_manager_file"`
	ID         string                                    `json:"id" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
	Attributes shareddto.FileManagerFileDetailAttributes `json:"attributes"`
}

type FileManagerFileDetailResponse struct {
	Data FileManagerFileDetailResource `json:"data"`
}

type FileManagerFileListResponse struct {
	Data []FileManagerFileListResource `json:"data"`
	Meta struct {
		PageNumber int   `json:"page_number" example:"1"`
		PageSize   int   `json:"page_size" example:"20"`
		Total      int64 `json:"total" example:"120"`
	} `json:"meta"`
}

type FileManagerFileDownloadURLResponse struct {
	Data struct {
		Type       string                                      `json:"type" example:"file_manager_file_download"`
		ID         string                                      `json:"id" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
		Attributes shareddto.FileManagerFileDownloadAttributes `json:"attributes"`
	} `json:"data"`
}

type FileManagerFileUploadIntentResponse struct {
	Data struct {
		Type       string                                          `json:"type" example:"file_manager_file_upload_intent"`
		ID         string                                          `json:"id" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
		Attributes shareddto.FileManagerFileUploadIntentAttributes `json:"attributes"`
	} `json:"data"`
}

type FileManagerFileUploadIntentResource struct {
	Type       string                                          `json:"type" example:"file_manager_file_upload_intent"`
	ID         string                                          `json:"id" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
	Attributes shareddto.FileManagerFileUploadIntentAttributes `json:"attributes"`
}

type FileManagerFileWOPISessionData struct {
	FileID          string `json:"file_id" example:"019f0386-0a00-7a4a-a2d8-30afc0e0c3ad"`
	CollaboraAction string `json:"collabora_action" example:"https://collabora.example.com/browser/123?WOPISrc=..."`
	AccessToken     string `json:"access_token" example:"eyJhbGciOiJIUzI1NiIs..."`
	// AccessTokenTTL is the access token's absolute expiry time, in epoch
	// milliseconds (equal to the JWT exp claim), as required by WOPI/Collabora.
	AccessTokenTTL  int64  `json:"access_token_ttl" example:"1782971996000"`
}

type FileManagerFileWOPISessionResponse struct {
	Data FileManagerFileWOPISessionData `json:"data"`
}

type FileManagerFileBulkError struct {
	Status    int    `json:"status" example:"422"`
	Code      string `json:"code,omitempty" example:"FILE_MANAGER_VALIDATION_FAILED"`
	ErrorCode string `json:"error_code,omitempty" example:"4222111"`
	Title     string `json:"title" example:"Validation error"`
	Detail    string `json:"detail" example:"duplicate name in target folder"`
}

type FileManagerFileBulkItem struct {
	Index    int                       `json:"index" example:"0"`
	Success  bool                      `json:"success" example:"true"`
	Message  string                    `json:"message,omitempty" example:"created"`
	Resource *FileManagerFileResource  `json:"resource,omitempty"`
	Error    *FileManagerFileBulkError `json:"error,omitempty"`
}

type FileManagerFileBulkResponse struct {
	Data []FileManagerFileBulkItem `json:"data"`
	Meta struct {
		Total          int  `json:"total" example:"3"`
		Success        int  `json:"success" example:"2"`
		Failed         int  `json:"failed" example:"1"`
		PartialSuccess bool `json:"partial_success" example:"true"`
	} `json:"meta"`
}

type FileManagerFileUploadIntentBulkItem struct {
	Index    int                                  `json:"index" example:"0"`
	Success  bool                                 `json:"success" example:"true"`
	Resource *FileManagerFileUploadIntentResource `json:"resource,omitempty"`
	Error    *FileManagerFileBulkError            `json:"error,omitempty"`
}

type FileManagerFileUploadIntentBulkResponse struct {
	Data []FileManagerFileUploadIntentBulkItem `json:"data"`
	Meta struct {
		Total          int  `json:"total" example:"3"`
		Success        int  `json:"success" example:"2"`
		Failed         int  `json:"failed" example:"1"`
		PartialSuccess bool `json:"partial_success" example:"true"`
	} `json:"meta"`
}

type FileManagerFileCancelUploadResource struct {
	Type       string `json:"type" example:"file_manager_file_cancel_upload_result"`
	ID         string `json:"id" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
	Attributes struct {
		Status string `json:"status" example:"canceled"`
	} `json:"attributes"`
}

type FileManagerFileCancelUploadBulkItem struct {
	Index    int                                  `json:"index" example:"0"`
	Success  bool                                 `json:"success" example:"true"`
	Resource *FileManagerFileCancelUploadResource `json:"resource,omitempty"`
	Error    *FileManagerFileBulkError            `json:"error,omitempty"`
}

type FileManagerFileCancelUploadBulkResponse struct {
	Data []FileManagerFileCancelUploadBulkItem `json:"data"`
	Meta struct {
		Total          int  `json:"total" example:"3"`
		Success        int  `json:"success" example:"2"`
		Failed         int  `json:"failed" example:"1"`
		PartialSuccess bool `json:"partial_success" example:"true"`
	} `json:"meta"`
}
