// GetPost チ-ム名と記事番号を指定して記事を取得する
1602
func (p *PostService) GetPost(teamName string, postNumber int) (*PostResponse, error) {
	var postRes PostResponse

	postNumberStr := strconv.Itoa(postNumber)

	postURL := PostURL + "/" + teamName + "/posts" + "/" + postNumberStr
	res, err := p.client.get(postURL, url.Values{}, &postRes)
	if err != nil {
		return nil, err
	}

	defer res.Body.Close()

	return &postRes, nil
}
132896
func (p *PushEventCommit) GetURL() string {
	if p == nil || p.URL == nil {
		return ""
	}
	return *p.URL
}
1099071
func DeletePost() echo.HandlerFunc {

	// swagger:route DELETE /projects/{id}/posts/{pid} project post DeleteProjectPost
	//
	// Delete the post on the specified project board
	//
	// Consumes:
	// - application/json
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: project_messages:write
	//
	//	Responses:
	//		default: apiResponse

	return func(c echo.Context) error {
		if !rest.IsGranted("project_messages:write", c) {
			return rest.InvalidScopeResponse("project_messages:write", c)
		}

		post := c.Get("post").(*nerdz.ProjectPost)
		me := c.Get("me").(*nerdz.User)
		if err := me.Delete(post); err != nil {
			return err
		}

		errstr := "Success"
		c.JSON(http.StatusOK, &rest.Response{
			Data:         nil,
			HumanMessage: errstr,
			Message:      errstr,
			Status:       http.StatusOK,
			Success:      true,
		})
		return nil
	}
}
781788
func (c *Client) Get(endpoint string) (tumblr.Response, error) {
	return c.GetWithParams(endpoint, url.Values{})
}
541139
func PostComments() echo.HandlerFunc {

	// swagger:route GET /users/{id}/posts/{pid}/comments users post comments GetUserPostComments
	//
	// List comments on specified post, filtered by some parameters.
	//
	// This will show the last posts on the user board by default.
	// You can personalize the request via query string parameters
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: profile_comments:read
	//
	//	Responses:
	//		default: UsersIdPostsPidComments

	return func(c echo.Context) error {
		if !rest.IsGranted("profile_comments:read", c) {
			return rest.InvalidScopeResponse("profile_comments:read", c)
		}
		comments := c.Get("post").(*nerdz.UserPost).Comments(*(c.Get("commentlistOptions").(*nerdz.CommentlistOptions)))
		if comments == nil {
			errstr := "Unable to fetch comment list for the specified post"
			c.JSON(http.StatusBadRequest, &rest.Response{
				HumanMessage: errstr,
				Message:      "UserPost.Comments(options) error",
				Status:       http.StatusBadRequest,
				Success:      false,
			})
			return errors.New(errstr)
		}

		var commentsAPI []*nerdz.UserPostCommentTO
		me := c.Get("me").(*nerdz.User)
		for _, p := range *comments {
			// comments contains ExistingPost elements
			// we need to convert back to a UserPostComment in order to get a correct UserPostCommentTO
			if userPostComment := p.(*nerdz.UserPostComment); userPostComment != nil {
				commentsAPI = append(commentsAPI, userPostComment.GetTO(me))
			}
		}
		return rest.SelectFields(commentsAPI, c)
	}
}
689761
func (s *Service) Post(ctx context.Context, v interface{}, path string, body interface{}) error {
	return s.Do(ctx, v, "POST", path, body, nil, nil)
}
1076604
func PostURL(source, post string) ([]byte, error) {
	resp, err := http.Post(source, "application/octet-stream", strings.NewReader(post))
	if err != nil {
		return nil, fmt.Errorf("http post %s: %v", source, err)
	}
	if resp.StatusCode != http.StatusOK {
		return nil, fmt.Errorf("server response: %s", resp.Status)
	}
	defer resp.Body.Close()
	return ioutil.ReadAll(resp.Body)
}
1090238
func (t *TeamDiscussion) GetCommentsURL() string {
	if t == nil || t.CommentsURL == nil {
		return ""
	}
	return *t.CommentsURL
}
459609
func DeletePost(client ClientInterface, name string, postId uint64) error {
	_, err := client.PostWithParams(blogPath("/blog/%s/post/delete", name), setPostId(postId, url.Values{}))
	return err
}
718794
func (p *Message) GetTO(users ...*User) *PostTO {
	if p.Type == UserPostID {
		return p.Post.UserPost().GetTO(users...)
	}
	return p.Post.ProjectPost().GetTO(users...)
}
37011
func (p *PostService) GetPosts(teamName string, query url.Values) (*PostsResponse, error) {
	var postsRes PostsResponse
	queries := createQuery(query)

	postsURL := PostURL + "/" + teamName + "/posts"
	res, err := p.client.get(postsURL, queries, &postsRes)
	if err != nil {
		return nil, err
	}

	defer res.Body.Close()

	return &postsRes, nil

}
674463
func GetAction(uuid string) (Action, error) {

	url := ""
	if string(uuid[0]) == "/" {
		url = uuid[8:]
	} else {
		url = "action/" + uuid + "/"
	}

	request := "GET"
	//Empty Body Request
	body := []byte(`{}`)
	var response Action

	data, err := TutumCall(url, request, body)
	if err != nil {
		return response, err
	}

	err = json.Unmarshal(data, &response)
	if err != nil {
		return response, err
	}

	return response, nil
}
1143145
func PostComment() echo.HandlerFunc {

	// swagger:route GET /users/{id}/posts/{pid}/comments/{cid} users post comment GetUserPostComment
	//
	// Shows selected comment on specified post, filtered by some parameters.
	//
	// You can personalize the request via query string parameters
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: profile_comments:read
	//
	//	Responses:
	//		default: UsersIdPostsPidCommentsCid

	return func(c echo.Context) error {
		if !rest.IsGranted("profile_comments:read", c) {
			return rest.InvalidScopeResponse("profile_comments:read", c)
		}
		comment := c.Get("comment").(*nerdz.UserPostComment)
		me := c.Get("me").(*nerdz.User)
		return rest.SelectFields(comment.GetTO(me), c)
	}
}
155598
func LikePost(client ClientInterface, postId uint64, reblogKey string) error {
	return doLike(client, "/user/like", postId, reblogKey)
}
594385
func POST(ctx log.Interface, server string, strategy auth.Strategy, URI string, headers map[string]string, body, res interface{}) error {
	return performRequest(ctx, server, strategy, "POST", URI, headers, body, res, MaxRedirects)
}
1096083
func doPost(client ClientInterface, path, blogName string, params url.Values) (*PostRef, error) {
	if blogName == "" {
		return nil, errors.New("No blog name provided")
	}
	response, err := client.PostWithParams(blogPath(path, blogName), params)
	if err != nil {
		return nil, err
	}
	post := struct {
		Response struct {
			Id uint64 `json:"id"`
		} `json:"response"`
	}{}
	if err = json.Unmarshal(response.body, &post); err == nil {
		ref := NewPostRefById(client, post.Response.Id)
		ref.BlogName = blogName
		return ref, nil
	}
	return nil, err
}
558808
func (c *Consumer) PostForm(url string, userParams map[string]string, token *AccessToken) (resp *http.Response, err error) {
	return c.PostWithBody(url, "", userParams, token)
}