Class: Preposterous::Base

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/preposterous/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Base

Returns a new instance of Base.



8
9
10
# File 'lib/preposterous/base.rb', line 8

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



6
7
8
# File 'lib/preposterous/base.rb', line 6

def client
  @client
end

Instance Method Details

#getsitesObject



12
13
14
15
16
17
# File 'lib/preposterous/base.rb', line 12

def getsites
  response = perform_get("/api/getsites")
  # parse out sites? not sure how I want the API to look
  # for this. I have a couple of competing ideas...
  response["site"] if not response.nil?
end

#gettagsObject



51
52
53
54
# File 'lib/preposterous/base.rb', line 51

def gettags
  response = perform_get("/api/gettags")
  response["tag"] if not response.nil?
end

#newcomment(fields = {}) ⇒ Object

for some reason posterous does not recognize the post_id i think there maybe something wrong with their API at least I hope it isn’t me



46
47
48
49
# File 'lib/preposterous/base.rb', line 46

def newcomment(fields={})
  response = perform_post("/api/newcomment", :fields => fields)
  response["comment"] if not response.nil?
end

#newpost(fields = {}, *files) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/preposterous/base.rb', line 19

def newpost(fields={}, *files)
  # create options hash
  options = generate_post_options(fields, *files)
  response = perform_post("/api/newpost", options)
  # return post attrs
  response["post"] if not response.nil?
end

#readposts(fields = {}) ⇒ Object

this is BROKEN for some reason the XML will not parse the CDATA fields are throwing off the parser



38
39
40
41
# File 'lib/preposterous/base.rb', line 38

def readposts(fields={})
  response = perform_get("/api/readposts", :fields => fields)
  response["post"] if not response.nil?
end

#updatepost(fields = {}, *files) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/preposterous/base.rb', line 27

def updatepost(fields={}, *files)
  # create options hash
  options = generate_post_options(fields, *files)
  response = perform_post("/api/updatepost", options)
  # return post attrs
  response["post"] if not response.nil?
end