using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Web;
using System.IO;
using System.Net.Mail;

using EQNetwork.Objects;
using EQNetwork.Utility;

namespace EQNetwork.Interfaces
{
    public partial interface IEQApiService
    {
        IDisposable IDisposable { get; } // calls CancelAll

        void CancelAll();

        // blocking versions

        HttpWebResponse MakeApi2Request(string page, Parameters parms);

        Session Session_Create(string username, string password);
        Session Session_CreateFromFacebook(string fbAccessToken, DateTime fbExpirationDate, string email);
        Session Session_CreateFromFacebook(string code, string redirect_Url, string email);
        Session Session_CreateFromTwitter(string twUserId, string twScreenName, string twOAuthToken, string twOAuthTokenSecret, string email);
        Session Session_Check(Guid guid);

        User User_Get(int userId);
        User User_Get(string username);
        User User_Get();

        void User_Create(ref User user);

        User User_AcceptEmailConfirmation(out Guid sessionGuid, Guid confirmationGuid);

        void User_Update(ref User user);
        User User_UpdateFacebook(bool? isLinked, string accessToken, DateTime? expirationDate);
        User User_UpdateTwitter(bool? isLinked, string twitterUserId, string screenName, string oAuthToken, string oAuthTokenSecret);

        void User_Delete();
        void User_Delete(User user);
        void User_Delete(int userId);

        string User_EmailAccounts(string email);

        List<Collection> User_ListCollections(
            ListCollectionsContext listCollectionsContext,
            PagingParameters pagingParameters);
        List<Collection> User_ListCollections(int? userId,
            ListCollectionsContext listCollectionsContext,
            PagingParameters pagingParameters);

        List<User> User_Search(string search, PagingParameters pagingParameters);
        List<User> User_ListUser(ListUsersContext listUsersContext, PagingParameters pagingParameters);
        List<ContentFile> User_ListFavoritedContentFiles(
            ListContentFilesContext listContentFilesContext,
            PagingParameters pagingParameters);

        void User_RequestPasswordReset(string username);
        void User_ResendConfirmationEmail();
        void User_ResetPassword(Guid passwordResetGuid, string password);

        PurchaseTransaction User_Purchase(PurchaseContext purchaseContext);

        List<Friend> User_FacebookFindFriends(string search, Db.SocialSearchType socialSearchType, PagingParameters pagingParameters);
        List<Friend> User_TwitterFindFriends(string search, Db.SocialSearchType socialSearchType, PagingParameters pagingParameters);

        User User_UpdateSocial(bool isSocialOn, int fbBits, int twitterBits);

        void User_SocialAdd(string action, int? collectionId, int? contentFileId, bool force);
        void User_SocialRemove(string action, int? collectionId, int? contentFileId, bool force);

        Collection Collection_Get(int collectionId);
        Collection Collection_Get(Guid collectionGuid);

        void Collection_Create(ref Collection collection);
        void Collection_Update(ref Collection collection);

        void Collection_Delete(Collection collection);
        void Collection_Delete(int collectionId);

        List<ContentFile> Collection_ListContentFiles(int collectionId,
            ListContentFilesContext listContentFilesContext,
            PagingParameters pagingParameters);

        void Collection_AddRelationship(int collectionId, Db.User_CollectionType user_CollectionType);
        void Collection_AddRelationship(int collectionId, Db.User_CollectionType user_CollectionType,
            int? collectionTriggerId, bool? silent);

        void Collection_SocialAdd(int collectionId, string action, Db.SocialService? exclude, bool? force);
        void Collection_SocialRemove(int collectionId, string action, bool? force);

        void Collection_Viewed(int collectionId);

        ContentFile ContentFile_Get(int contentFileId);
        ContentFile ContentFile_Get(string filename);

        void ContentFile_Create(ref ContentFile contentFile);
        void ContentFile_CreateFromUrl(ref ContentFile contentFile, string url);
        void ContentFile_Update(ref ContentFile contentFile);

        void ContentFile_UpdateSortBy(int contentFileId, float? sortBy);

        void ContentFile_Delete(ContentFile contentFile);
        void ContentFile_Delete(int contentFileId);

        void ContentFile_ChangeCollection(int contentFileId, int old_CollectionId, int new_CollectionId);
        void ContentFile_FlagAsInappropriate(int contentFileId);

        List<Post> ContentFile_ListPosts(string filename, PagingParameters pagingParameters);

        void ContentFile_SocialAdd(int contentFileId, string action, Db.SocialService? exclude, bool? force);
        void ContentFile_SocialRemove(int contentFileId, string action, bool? force);

        void ContentFile_Viewed(int contentFileId);

        void Activity_Create(string activity, string secondary);

        List<ContentMenu> ContentMenu_List(ref DateTime? modifiedSince);

        Post Post_Get(int postId);

        void Post_Create(ref Post post);
        void Post_Update(ref Post post);

        void Post_Delete(Post post);
        void Post_Delete(int postId);

        void Invitation_Accept(Guid invitationGuid);
        void Invitation_Confirm(Guid invitationGuid);
        List<InvitationMessage> Invitation_Create(InvitationContext invitationContext);
        void Invitation_Decline(Guid invitationGuid);
        void Invitation_Delete(Guid invitationGuid);
        List<Invitation> Invitation_ListInvitationsForCollection(int collectionId);
        List<Invitation> Invitation_ListInvitationsForCollection(Guid collectionGuid);
        List<Invitation> Invitation_ListInvitationsForUser(int userId);
        List<Invitation> Invitation_ListInvitationsToMe(List<Db.InvitationType> invitationTypes, bool? all);
        void Invitation_Resend(Guid invitationGuid);
        void Invitation_Update(Guid invitationGuid);

        void Request_Accept(Guid requestGuid);
        void Request_Confirm(Guid requestGuid);
        RequestMessage Request_Create(RequestContext requestContext);
        void Request_Decline(Guid requestGuid);
        void Request_Delete(Guid requestGuid);
        List<Request> Request_ListRequestsForCollection(int collectionId);
        List<Request> Request_ListRequestsForCollection(Guid collectionGuid);
        List<Request> Request_ListRequestsForUser(int userId);
        List<Request> Request_ListRequestsToMe(List<Db.RequestType> requestTypes, bool? all);
        Guid Request_GetCollectionRequestGuid(int collectionId);
        void Request_Update(Guid requestGuid);

        List<Collection> Search_CollectionAndContentFiles(SearchFilters searchFilters, PagingParameters pagingParameters);
        List<ContentFile> Search_ContentFiles(SearchFilters searchFilters, PagingParameters pagingParameters);
        ContentFile Search_ContentFiles(string filename);

        List<Hashtag> Hashtag_Search(string search, PagingParameters pagingParameters);
        List<Hashtag> Hashtag_Trending(PagingParameters pagingParameters);
        List<Category> Category_ListAll();

        Upload Upload_Begin(UploadContext uploadContext);
        Upload Upload_Complete(UploadContext uploadContext);
        List<Upload> Upload_ListUploads(int preferredChunkSize, int numberOfChunks);
        Upload Upload_ListUpload(UploadContext uploadContext);
        long Upload_Chunk(out long total, UploadContext uploadContext, long chunkOffset, long chunkSize, FileUploadSpec chunk);
        Upload Upload_CancelUpload(UploadContext uploadContext);
        void Upload_CreateContentFile(ref ContentFile contentFile, UploadContext uploadContext);
    }
}
