Пример #1
0
 /// <summary>
 /// <inheritdoc />
 /// </summary>
 /// <returns></returns>
 public PostBuilder InitializeWithDefaultValues()
 {
     CommandStatus = CommentStatusValue.Open;
     PingStatus    = PingStatusValue.Open;
     Format        = PostFormat.Standard;
     Status        = PostStatus.Pending;
     return(this);
 }
        private void listPicker_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Post post = (Post)App.MasterViewModel.CurrentPost;

            if (sender == postFormatsPicker)
            {
                int newIndex = postFormatsPicker.SelectedIndex;
                if (!(newIndex >= 0) || newIndex >= App.MasterViewModel.CurrentBlog.PostFormats.Count)
                {
                    return;
                }
                PostFormat newPostFormat = App.MasterViewModel.CurrentBlog.PostFormats[newIndex];
                post.PostFormat = newPostFormat.Key;
            }
        }
Пример #3
0
        /*
        public void GetBlogQueue(string blogHostName)
        {
            if (String.IsNullOrEmpty(blogHostName))
                throw new ArgumentException("invalid blog host name");

            var client = GetRestClient();

            var resource = string.Format("/blog/{0}/posts/queue", blogHostName);

            var request = new RestRequest(resource, Method.GET);

            var response = client.Execute(request);

            Console.WriteLine(response.StatusCode);
        }*/
        //TODO: Write some overloads for this
        public List<TumblrPost> GetBlogPosts(string blogHostName, PostFormat format = PostFormat.Html, string filteredTag = "", bool includeReblogs = false, bool includeNotes = false, int offset = 0, int limit = 20, PostType postType = PostType.All )
        {
            if (String.IsNullOrEmpty(blogHostName))
                throw new ArgumentException("invalid blog host name");

            var client = GetUnAuthenticatedRestClient();

            string typeUrl = "";

            switch (postType)
            {
                    case PostType.Text:
                        typeUrl = "/text";
                        break;
                    case PostType.Quote:
                        typeUrl = "/quote";
                        break;
                    case PostType.Link:
                        typeUrl = "/link";
                        break;
                    case PostType.Audio:
                        typeUrl = "/audio";
                        break;
                    case PostType.Video:
                        typeUrl = "/video";
                        break;
                    case PostType.Answer:
                        typeUrl = "/answer";
                        break;
                    case PostType.Photo:
                        typeUrl = "/photo";
                        break;
                    default:
                        typeUrl = "";
                        break;

            }

            //post type on end of url for this one
            var resource = string.Format("/blog/{0}/posts{1}", blogHostName, typeUrl);

            var request = new RestRequest(resource);

            request.AddParameter(new Parameter() { Name = "api_key", Type = ParameterType.GetOrPost, Value = ConsumerKey });
            request.AddParameter("limit", limit);
            request.AddParameter("offset", offset);

            if(filteredTag != "")
                request.AddParameter("tag", filteredTag);

            request.AddParameter("reblog_info", includeReblogs);
            request.AddParameter("notes_info", includeNotes);

            var response = client.Execute<TumblrResponse<TumblrPostsResponse>>(request);

            return ConvertPosts(response.Data.Response.Posts);
        }
Пример #4
0
 /// <summary>
 /// Sets the post format
 /// </summary>
 /// <param name="format"></param>
 /// <returns></returns>
 public PostBuilder WithFormat(PostFormat format)
 {
     Format = format;
     return(this);
 }