Class: TentClient::Post
- Inherits:
-
Object
- Object
- TentClient::Post
- Defined in:
- lib/tent-client/post.rb
Constant Summary collapse
- MULTIPART_TYPE =
'multipart/form-data'.freeze
- MULTIPART_BOUNDARY =
"-----------TentAttachment".freeze
Instance Method Summary collapse
- #attachment ⇒ Object
- #count(params = {}) ⇒ Object
- #create(post, options = {}) ⇒ Object
- #delete(id) ⇒ Object
- #get(id) ⇒ Object
-
#initialize(client) ⇒ Post
constructor
A new instance of Post.
- #list(params = {}) ⇒ Object
Constructor Details
#initialize(client) ⇒ Post
Returns a new instance of Post.
6 7 8 |
# File 'lib/tent-client/post.rb', line 6 def initialize(client) @client = client end |
Instance Method Details
#attachment ⇒ Object
34 35 36 |
# File 'lib/tent-client/post.rb', line 34 def PostAttachment.new(@client) end |
#count(params = {}) ⇒ Object
10 11 12 |
# File 'lib/tent-client/post.rb', line 10 def count(params={}) @client.http.get('posts/count', params) end |
#create(post, options = {}) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/tent-client/post.rb', line 18 def create(post, ={}) if [:attachments] multipart_post(post, , .delete(:attachments)) else @client.http.post([:url] || 'posts', post) end end |
#delete(id) ⇒ Object
30 31 32 |
# File 'lib/tent-client/post.rb', line 30 def delete(id) @client.http.delete("posts/#{id}") end |
#get(id) ⇒ Object
26 27 28 |
# File 'lib/tent-client/post.rb', line 26 def get(id) @client.http.get("posts/#{id}") end |
#list(params = {}) ⇒ Object
14 15 16 |
# File 'lib/tent-client/post.rb', line 14 def list(params = {}) @client.http.get('posts', params) end |