aboutsummaryrefslogtreecommitdiffstats
path: root/actionwebservice/examples/metaWeblog/apis/meta_weblog_service.rb
blob: 9c66558f1b9828829fd54fa128cd77a7a23eb1eb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require 'meta_weblog_api'

class MetaWeblogService < ActionWebService::Base
  web_service_api MetaWeblogAPI

  def initialize
    @postid = 0
  end

  def newPost(id, user, pw, struct, publish)
    $stderr.puts "id=#{id} user=#{user} pw=#{pw}, struct=#{struct.inspect} [#{publish}]"
    (@postid += 1).to_s
  end

  def editPost(post_id, user, pw, struct, publish)
    $stderr.puts "id=#{post_id} user=#{user} pw=#{pw} struct=#{struct.inspect} [#{publish}]"
    true
  end

  def getPost(post_id, user, pw)
    $stderr.puts "get post #{post_id}"
    Blog::Post.new(:title => 'hello world', :description => 'first post!')
  end

  def getCategories(id, user, pw)
    $stderr.puts "categories for #{user}"
    cat = Blog::Category.new(
      :description => 'Tech',
      :htmlUrl     => 'http://blog/tech',
      :rssUrl      => 'http://blog/tech.rss')
    [cat]
  end

  def getRecentPosts(id, user, pw, num)
    $stderr.puts "recent #{num} posts for #{user} on blog #{id}"
    post1 = Blog::Post.new(
      :title => 'first post!',
      :link => 'http://blog.xeraph.org/testOne.html',
      :description => 'this is the first post'
    )
    post2 = Blog::Post.new(
      :title => 'second post!',
      :link => 'http://blog.xeraph.org/testTwo.html',
      :description => 'this is the second post'
    )
    [post1, post2]
  end
end