Class: Posterous::User

Inherits:
Object
  • Object
show all
Includes:
Connection, OldAPI
Defined in:
lib/posterous_api/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OldAPI

#get_all_sites_uri, #get_tags_uri, #new_post_uri, #read_posts_uri, #update_post_uri

Methods included from BaseURI

#base_uri

Methods included from Connection

#delete, #get, #post, #put

Constructor Details

#initialize(email, password) ⇒ User

Initialize of a Client with email and password



11
12
13
14
# File 'lib/posterous_api/user.rb', line 11

def initialize(email, password)
  @email = email
  @password = password
end

Instance Attribute Details

#emailObject

Returns the value of attribute email.



3
4
5
# File 'lib/posterous_api/user.rb', line 3

def email
  @email
end

#passwordObject

Returns the value of attribute password.



3
4
5
# File 'lib/posterous_api/user.rb', line 3

def password
  @password
end

Instance Method Details

#blogsObject

Return all the sites for that user

user.blogs



28
29
30
# File 'lib/posterous_api/user.rb', line 28

def blogs
  get(get_all_sites_uri)
end

#create_post_for(options) ⇒ Object

Create a new post in a blog

user.create_post_for :blog => ‘123456’, :title => ‘My title’, :body => ‘Body’



53
54
55
56
57
58
# File 'lib/posterous_api/user.rb', line 53

def create_post_for(options)
  site_id = options[:blog]
  options.delete(:blog)
  options[:site_id] = site_id
  post(new_post_uri, options)
end

#credentialsObject

Return the credentials to use with the old API

user.credentials



20
21
22
# File 'lib/posterous_api/user.rb', line 20

def credentials
  { :username => @email, :password => @password }
end

#posts_from(options = {}) ⇒ Object Also known as: posts

Return all the posts from a blog

user.posts_from :blog => ‘123456’



36
37
38
# File 'lib/posterous_api/user.rb', line 36

def posts_from(options={})
  get(read_posts_uri, { :site_id => options[:blog]})
end

#tags_from(options = {}) ⇒ Object

Return all the tags from a blog

user.tags_from :blog => ‘123456’



45
46
47
# File 'lib/posterous_api/user.rb', line 45

def tags_from(options={})
  get(get_tags_uri, { :site_id => options[:blog]})
end