forked from maxcutler/python-wordpress-xmlrpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomments.py
More file actions
108 lines (78 loc) · 2.92 KB
/
Copy pathcomments.py
File metadata and controls
108 lines (78 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
from wordpress_xmlrpc.base import *
from wordpress_xmlrpc.wordpress import WordPressComment
class GetComment(AuthenticatedMethod):
"""
Retrieve an individual comment.
Parameters:
`comment_id`: ID of the comment to retrieve.
Returns: `WordPressPost` instance.
"""
method_name = 'wp.getComment'
method_args = ('comment_id',)
results_class = WordPressComment
class NewComment(AuthenticatedMethod):
"""
Create a new comment on a post.
Parameters:
`post_id`: The id of the post to add a comment to.
`comment`: A `WordPressComment` instance with at least the `content` value set.
Returns: ID of the newly-created comment (an integer).
"""
method_name = 'wp.newComment'
method_args = ('post_id', 'comment',)
class EditComment(AuthenticatedMethod):
"""
Edit an existing comment.
Parameters:
`comment_id`: The idea of the comment to edit.
`comment`: A `WordPressComment` instance with at least the `content` value set.
Returns: `True` on successful edit.
"""
method_name = 'wp.editComment'
method_args = ('comment_id', 'comment',)
class DeleteComment(AuthenticatedMethod):
"""
Delete an existing comment.
Parameters:
`comment_id`: The id of the comment to be deleted.
Returns: `True` on successful deletion.
"""
method_name = 'wp.deleteComment'
method_args = ('comment_id',)
class GetCommentStatusList(AuthenticatedMethod):
"""
Retrieve the set of possible blog comment statuses (e.g., "approve," "hold," "spam").
Parameters:
None
Returns: `dict` of values and their pretty names.
Example:
>>> client.call(GetCommentStatusList())
{'hold': 'Unapproved', 'approve': 'Approved', 'spam': 'Spam'}
"""
method_name = 'wp.getCommentStatusList'
class GetCommentCount(AuthenticatedMethod):
"""
Retrieve comment count for a specific post.
Parameters:
`post_id`: The id of the post to retrieve comment count for.
Returns: `dict` of comment counts for the post divided by comment status.
Example:
>>> client.call(GetCommentCount(1))
{'awaiting_moderation': '2', 'total_comments': 23, 'approved': '18', 'spam': 3}
"""
method_name = 'wp.getCommentCount'
method_args = ('post_id',)
class GetComments(AuthenticatedMethod):
"""
Gets a set of comments for a post.
Parameters:
`struct`: a `dict` with the following values:
`post_id`: the id of the post to retrieve comments for
`status`: type of comments of comments to retrieve (optional, defaults to 'approve')
`number`: number of comments to retrieve (optional, defaults to 10)
`offset`: retrieval offset (optional, defaults to 0)
Returns: `list` of `WordPressComment` instances.
"""
method_name = 'wp.getComments'
method_args = ('struct',)
results_class = WordPressComment