Beispiel #1
0
        /// <summary>
        /// Fetching a user's notifications
        /// </summary>
        /// <param name="options">Define the first and last items to get</param>
        /// <param name="excludeTypes">Types to exclude</param>
        /// <returns>Returns a list of Notifications for the authenticated user</returns>
        public Task <MastodonList <Notification> > GetNotifications(ArrayOptions options, NotificationType excludeTypes = NotificationType.None)
        {
            var url         = "/api/v1/notifications";
            var queryParams = "";

            if (options != null)
            {
                queryParams += "?" + options.ToQueryString();
            }
            if ((excludeTypes & NotificationType.Follow) == NotificationType.Follow)
            {
                queryParams += (queryParams != "" ? "&" : "?") + "exclude_types[]=follow";
            }
            if ((excludeTypes & NotificationType.Favourite) == NotificationType.Favourite)
            {
                queryParams += (queryParams != "" ? "&" : "?") + "exclude_types[]=favourite";
            }
            if ((excludeTypes & NotificationType.Reblog) == NotificationType.Reblog)
            {
                queryParams += (queryParams != "" ? "&" : "?") + "exclude_types[]=reblog";
            }
            if ((excludeTypes & NotificationType.Mention) == NotificationType.Mention)
            {
                queryParams += (queryParams != "" ? "&" : "?") + "exclude_types[]=mention";
            }
            if ((excludeTypes & NotificationType.Poll) == NotificationType.Poll)
            {
                queryParams += (queryParams != "" ? "&" : "?") + "exclude_types[]=poll";
            }
            return(GetMastodonList <Notification>(url + queryParams));
        }
Beispiel #2
0
        /// <summary>
        /// Accounts that are in a given list.
        /// </summary>
        /// <param name="listId"></param>
        /// <param name="options">Define the first and last items to get</param>
        /// <returns>Returns array of Account</returns>
        public Task <MastodonList <Account> > GetListAccounts(string listId, ArrayOptions options)
        {
            var url = $"/api/v1/lists/{listId}/accounts";

            if (options != null)
            {
                url += "?" + options.ToQueryString();
            }
            return(GetMastodonList <Account>(url));
        }
Beispiel #3
0
        /// <summary>
        /// Fetching a user's reports
        /// </summary>
        /// <param name="options">Define the first and last items to get</param>
        /// <returns>Returns a list of Reports made by the authenticated user</returns>
        public Task <MastodonList <Report> > GetReports(ArrayOptions options)
        {
            var url = "/api/v1/reports";

            if (options != null)
            {
                url += "?" + options.ToQueryString();
            }
            return(GetMastodonList <Report>(url));
        }
        /// <summary>
        /// Fetching a user's blocks
        /// </summary>
        /// <param name="options">Define the first and last items to get</param>
        /// <returns>Returns an array of Accounts blocked by the authenticated user</returns>
        public Task <MastodonList <Account> > GetBlocks(ArrayOptions options)
        {
            var url = "/api/v1/blocks";

            if (options != null)
            {
                url += "?" + options.ToQueryString();
            }
            return(GetMastodonList <Account>(url));
        }
        /// <summary>
        /// Getting who reblogged a status
        /// </summary>
        /// <param name="statusId"></param>
        /// <param name="options">Define the first and last items to get</param>
        /// <returns>Returns an array of Accounts</returns>
        public Task <MastodonList <Account> > GetRebloggedBy(string statusId, ArrayOptions options)
        {
            var url = $"/api/v1/statuses/{statusId}/reblogged_by";

            if (options != null)
            {
                url += "?" + options.ToQueryString();
            }
            return(GetMastodonList <Account>(url));
        }
Beispiel #6
0
        /// <summary>
        /// Fetching a user's favourites
        /// </summary>
        /// <param name="options">Define the first and last items to get</param>
        /// <returns>Returns an array of Statuses favourited by the authenticated user</returns>
        public Task <MastodonList <Status> > GetFavourites(ArrayOptions options)
        {
            var url = "/api/v1/favourites";

            if (options != null)
            {
                url += "?" + options.ToQueryString();
            }
            return(GetMastodonList <Status>(url));
        }
        /// <summary>
        /// Fetching a user's blocked domains
        /// </summary>
        /// <param name="options">Define the first and last items to get</param>
        /// <returns>Returns an array of strings</returns>
        public Task <MastodonList <string> > GetDomainBlocks(ArrayOptions options)
        {
            var url = "/api/v1/domain_blocks";

            if (options != null)
            {
                url += "?" + options.ToQueryString();
            }
            return(GetMastodonList <string>(url));
        }
Beispiel #8
0
        /// <summary>
        /// Getting who account is following
        /// </summary>
        /// <param name="accountId"></param>
        /// <param name="options">Define the first and last items to get</param>
        /// <returns>Returns an array of Accounts</returns>
        public Task <MastodonList <Account> > GetAccountFollowing(string accountId, ArrayOptions options)
        {
            var url = $"/api/v1/accounts/{accountId}/following";

            if (options != null)
            {
                url += "?" + options.ToQueryString();
            }
            return(GetMastodonList <Account>(url));
        }
Beispiel #9
0
        /// <summary>
        /// Fetching a list of follow requests
        /// </summary>
        /// <param name="options">Define the first and last items to get</param>
        /// <returns>Returns an array of Accounts which have requested to follow the authenticated user</returns>
        public Task <MastodonList <Account> > GetFollowRequests(ArrayOptions options)
        {
            var url = "/api/v1/follow_requests";

            if (options != null)
            {
                url += "?" + options.ToQueryString();
            }
            return(this.GetMastodonList <Account>(url));
        }
Beispiel #10
0
        /// <summary>
        /// Conversations (direct messages) for an account
        /// </summary>
        /// <param name="options">Define the first and last items to get</param>
        /// <returns>Returns array of Conversation</returns>
        public Task <MastodonList <Conversation> > GetConversations(ArrayOptions options)
        {
            string url = "/api/v1/conversations";

            if (options != null)
            {
                url += "?" + options.ToQueryString();
            }
            return(GetMastodonList <Conversation>(url));
        }
Beispiel #11
0
        /// <summary>
        /// Retrieving Home timeline
        /// </summary>
        /// <param name="options">Define the first and last items to get</param>
        /// <returns>Returns an array of Statuses, most recent ones first</returns>
        public Task <MastodonList <Status> > GetHomeTimeline(ArrayOptions options)
        {
            string url = "/api/v1/timelines/home";

            if (options != null)
            {
                url += "?" + options.ToQueryString();
            }
            return(GetMastodonList <Status>(url));
        }
Beispiel #12
0
        /// <summary>
        /// Retrieving List timeline
        /// </summary>
        /// <param name="listId"></param>
        /// <param name="options">Define the first and last items to get</param>
        /// <returns>Returns an array of Statuses, most recent ones first</returns>
        public Task <MastodonList <Status> > GetListTimeline(string listId, ArrayOptions options)
        {
            string url = "/api/v1/timelines/list/" + listId;

            if (options != null)
            {
                url += "?" + options.ToQueryString();
            }

            return(GetMastodonList <Status>(url));
        }
Beispiel #13
0
        /// <summary>
        /// Retrieving Public timeline
        /// </summary>
        /// <param name="options">Define the first and last items to get</param>
        /// <param name="local">Only return statuses originating from this instance</param>
        /// <param name="onlyMedia">Only statuses with media attachments</param>
        /// <returns>Returns an array of Statuses, most recent ones first</returns>
        public Task <MastodonList <Status> > GetPublicTimeline(ArrayOptions options, bool local = false, bool onlyMedia = false)
        {
            string url = "/api/v1/timelines/public";

            var queryParams = "";

            if (local)
            {
                queryParams += "?local=true";
            }
            if (onlyMedia)
            {
                queryParams += (queryParams != "" ? "&" : "?") + "only_media=true";
            }
            if (options != null)
            {
                queryParams += (queryParams != "" ? "&" : "?") + options.ToQueryString();
            }

            return(GetMastodonList <Status>(url + queryParams));
        }
Beispiel #14
0
 public Task <List <Account> > SearchAccounts(string q, ArrayOptions options)
 {
     return(SearchAccounts(q, options?.Limit));
 }
Beispiel #15
0
        /// <summary>
        /// Getting an account's statuses
        /// </summary>
        /// <param name="accountId"></param>
        /// <param name="onlyMedia">Only return statuses that have media attachments</param>
        /// <param name="excludeReplies">Skip statuses that reply to other statuses</param>
        /// <param name="pinned">Only return statuses that have been pinned</param>
        /// <param name="excludeReblogs">Skip statuses that are reblogs of other statuses</param>
        /// <param name="options">Define the first and last items to get</param>
        /// <returns>Returns an array of Statuses</returns>
        public Task <MastodonList <Status> > GetAccountStatuses(string accountId, ArrayOptions options, bool onlyMedia = false, bool excludeReplies = false, bool pinned = false, bool excludeReblogs = false)
        {
            var url = $"/api/v1/accounts/{accountId}/statuses";

            string queryParams = "";

            if (onlyMedia)
            {
                queryParams = "?only_media=true";
            }
            if (pinned)
            {
                if (queryParams != "")
                {
                    queryParams += "&";
                }
                else
                {
                    queryParams += "?";
                }
                queryParams += "pinned=true";
            }
            if (excludeReplies)
            {
                if (queryParams != "")
                {
                    queryParams += "&";
                }
                else
                {
                    queryParams += "?";
                }
                queryParams += "exclude_replies=true";
            }
            if (excludeReblogs)
            {
                if (queryParams != "")
                {
                    queryParams += "&";
                }
                else
                {
                    queryParams += "?";
                }
                queryParams += "exclude_reblogs=true";
            }
            if (options != null)
            {
                if (queryParams != "")
                {
                    queryParams += "&";
                }
                else
                {
                    queryParams += "?";
                }
                queryParams += options.ToQueryString();
            }

            return(GetMastodonList <Status>(url + queryParams));
        }