Module: Tumblr::Post

Included in:
Client
Defined in:
lib/tumblr/post.rb

Constant Summary collapse

STANDARD_POST_OPTIONS =
[:state, :tags, :tweet, :date, :markdown, :slug, :format]

Instance Method Summary collapse

Instance Method Details

#audio(blog_name, options = {}) ⇒ Object



64
65
66
67
68
69
70
71
72
# File 'lib/tumblr/post.rb', line 64

def audio(blog_name, options = {})
  valid_opts = STANDARD_POST_OPTIONS + [:data, :caption, :external_url]
  validate_options(valid_opts, options)
  validate_no_collision options, [:data, :external_url]

  options[:type] = 'audio'
  extract_data!(options)
  post(post_path(blog_name), options)
end

#chat(blog_name, options = {}) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/tumblr/post.rb', line 56

def chat(blog_name, options = {})
  valid_opts = STANDARD_POST_OPTIONS + [:title, :conversation]
  validate_options(valid_opts, options)

  options[:type] = 'chat'
  post(post_path(blog_name), options)
end

#delete(blog_name, id) ⇒ Object



17
18
19
# File 'lib/tumblr/post.rb', line 17

def delete(blog_name, id)
  post(blog_path(blog_name, 'post/delete'), :id => id)
end

#edit(blog_name, options = {}) ⇒ Object



8
9
10
11
# File 'lib/tumblr/post.rb', line 8

def edit(blog_name, options = {})
  convert_source_array :source, options
  post(blog_path(blog_name, 'post/edit'), options)
end


48
49
50
51
52
53
54
# File 'lib/tumblr/post.rb', line 48

def link(blog_name, options = {})
  valid_opts = STANDARD_POST_OPTIONS + [:title, :url, :description]
  validate_options(valid_opts, options)

  options[:type] = 'link'
  post(post_path(blog_name), options)
end

#photo(blog_name, options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/tumblr/post.rb', line 21

def photo(blog_name, options = {})
  valid_opts = STANDARD_POST_OPTIONS + [:caption, :link, :data, :source, :photoset_layout]
  validate_options(valid_opts, options)
  validate_no_collision options, [:data, :source]
  convert_source_array :source, options

  options[:type] = 'photo'
  extract_data!(options)
  post(post_path(blog_name), options)
end

#quote(blog_name, options = {}) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/tumblr/post.rb', line 32

def quote(blog_name, options = {})
  valid_opts = STANDARD_POST_OPTIONS + [:quote, :source]
  validate_options(valid_opts, options)

  options[:type] = 'quote'
  post(post_path(blog_name), options)
end

#reblog(blog_name, options = {}) ⇒ Object



13
14
15
# File 'lib/tumblr/post.rb', line 13

def reblog(blog_name, options = {})
  post(blog_path(blog_name, 'post/reblog'), options)
end

#text(blog_name, options = {}) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/tumblr/post.rb', line 40

def text(blog_name, options = {})
  valid_opts = STANDARD_POST_OPTIONS + [:title, :body]
  validate_options(valid_opts, options)

  options[:type] = 'text'
  post(post_path(blog_name), options)
end

#video(blog_name, options = {}) ⇒ Object



74
75
76
77
78
79
80
81
82
# File 'lib/tumblr/post.rb', line 74

def video(blog_name, options = {})
  valid_opts = STANDARD_POST_OPTIONS + [:data, :embed, :caption]
  validate_options(valid_opts, options)
  validate_no_collision options, [:data, :embed]

  options[:type] = 'video'
  extract_data!(options)
  post(post_path(blog_name), options)
end