Class: TentClient::Post

Inherits:
Object
  • Object
show all
Defined in:
lib/tent-client/post.rb

Constant Summary collapse

MULTIPART_TYPE =
'multipart/form-data'.freeze
MULTIPART_BOUNDARY =
"-----------TentAttachment".freeze

Instance Method Summary collapse

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

#attachmentObject



34
35
36
# File 'lib/tent-client/post.rb', line 34

def attachment
  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, options={})
  if options[:attachments]
    multipart_post(post, options, options.delete(:attachments))
  else
    @client.http.post(options[: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