Class: Postly::Post

Inherits:
Connection show all
Defined in:
lib/postly/post.rb

Class Method Summary collapse

Methods inherited from Connection

array_or_hash, class_name, conform, defaults, #initialize, many, #singularized_class_name

Constructor Details

This class inherits a constructor from Postly::Connection

Class Method Details

.add_download_class(html) ⇒ Object

there is probably a better way nodes for the body but this works for now.



40
41
42
43
44
# File 'lib/postly/post.rb', line 40

def self.add_download_class html
  doc = Nokogiri::HTML(html)
  doc.css( "img" ).each { |img| img["class"] = "posterous_download_image" }.to_s
  doc.css("body").children.first.to_s
end

.create(params = {}) ⇒ Object

URL posterous.com/api/newpost Fields “site_id” - Optional. Id of the site to post to. If not supplied, posts to the user’s default site “media” - Optional. File data for single file. “media[]” - Optional. File data for multiple file upload. Can be specified multiple times. “title” - Optional. Title of post “body” - Optional. Body of post “autopost” - Optional. 0 or 1. “private” - Optional. 0 or 1. “date” - Optional. In GMT. Any parsable format. Cannot be in the future. “tags” - Optional. Comma separate tags “source” - Optional. The name of your application or website “sourceLink” - Optional. Link to your application or website



20
21
22
23
# File 'lib/postly/post.rb', line 20

def self.create params={}
  params[:body] = add_download_class params[:body]
  conform post "/newpost", defaults.merge( :query => params )
end

.update(post_id, params = {}) ⇒ Object

URL postly.com/api/updatepost Fields “post_id” - Id of the post to update. “media” - Optional. File data for single file. Will append to post. “media[]” - Optional. File data for multiple file upload. Can be specified multiple times. Will append to post. “title” - Optional. Title of post. Will update post if present. “body” - Optional. Body of post. Will update post if present.



33
34
35
36
# File 'lib/postly/post.rb', line 33

def self.update post_id, params={}
  params[:post_id] = post_id
  conform post "/updatepost", defaults.merge( :query => params )
end