示例#1
0
        public IEnumerable<Publication> GetPublications(string userId, Token token)
        {
            var request = Helper.GetRequestWithToken(
                BaseUrl + $"/users/{userId}/publications",
                System.Net.Http.HttpMethod.Get,
                token);

            return request.GetResponseJson<IEnumerable<Publication>>();
        }
示例#2
0
        public User GetCurrentUser(Token token)
        {
            var request = Helper.GetRequestWithToken(
                BaseUrl + "/me",
                System.Net.Http.HttpMethod.Get,
                token);

            return request.GetResponseJson<User>();
        }
示例#3
0
        public IEnumerable<Contributor> GetContributors(string publicationId, Token token)
        {
            var request = Helper.GetRequestWithToken(
                BaseUrl + $"/publications/{publicationId}/contributors",
                System.Net.Http.HttpMethod.Get,
                token);

            return request.GetResponseJson<IEnumerable<Contributor>>();
        }
示例#4
0
        public Image UploadImage(UploadImageRequestBody uploadImageRequestBody, Token token)
        {
            var request = Helper.
                GetRequestWithToken(
                    BaseUrl + "/images",
                    System.Net.Http.HttpMethod.Post,
                    token).
                SetRequestMultipartFormData(
                    uploadImageRequestBody.ContentType,
                    uploadImageRequestBody.ContentBytes);

            return request.GetResponseJson<Image>();
        }
示例#5
0
        private Post CreatePostInternal(string endpointUrl, CreatePostRequestBody createPostRequestBody, Token token)
        {
            var request = Helper.
                GetRequestWithToken(
                    BaseUrl + endpointUrl,
                    System.Net.Http.HttpMethod.Post,
                    token).
                SetRequestJson(new
                {
                    title = createPostRequestBody.Title,
                    contentFormat = createPostRequestBody.ContentFormat.ToString().ToLowerInvariant(),
                    content = createPostRequestBody.Content,
                    tags = createPostRequestBody.Tags,
                    canonicalUrl = createPostRequestBody.CanonicalUrl,
                    publishStatus = createPostRequestBody.PublishStatus.ToString().ToLowerInvariant(),
                    license = createPostRequestBody.License.ToString().CamelCaseToSpinalCase(),
                    publishedAt = createPostRequestBody.PublishedAt,
                    notifyFollowers = createPostRequestBody.NotifyFollowers,
                });

            return request.GetResponseJson<Post>();
        }
示例#6
0
 public Post CreatePostUnderPublication(string publicationId, CreatePostRequestBody createPostRequestBody, Token token)
 {
     return CreatePostInternal($"/publications/{publicationId}/posts", createPostRequestBody, token);
 }
示例#7
0
 public Post CreatePost(string authorId, CreatePostRequestBody createPostRequestBody, Token token)
 {
     return CreatePostInternal($"/users/{authorId}/posts", createPostRequestBody, token);
 }