Class: Moogle::Commands::PushBlogEntry

Inherits:
Object
  • Object
show all
Includes:
Serf::Command
Defined in:
lib/moogle/commands/push_blog_entry.rb

Overview

Posts an entry to a target blog.

Instance Method Summary collapse

Instance Method Details

#callObject



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
49
50
# File 'lib/moogle/commands/push_blog_entry.rb', line 19

def call
  # Xml-Rpc server
  server = XMLRPC::Client.new request.host, request.path, request.port

  # Makes the metaWeblog new post API call
  post_ref = server.call(
    'metaWeblog.newPost',
    request.blog_id,
    request.username,
    request.password,
    {
      'title' => request.subject,
      'link' => request.blog_uri,
      'description' => request.html_body,
      'categories' => request.categories
    },
    request.publish_immediately)

  # Return an event representing this action.
  event_class = opts :event_class, Moogle::Events::BlogEntryPushed
  return event_class.new(
    request.create_child_uuids.merge(
      message_origin: request.message_origin,
      target_id: request.target_id,
      post_ref: post_ref))
rescue XMLRPC::FaultException => e
  e.extend Moogle::Error
  raise e
rescue => e
  e.extend Moogle::Error
  raise e
end