Class: ConfluenceSoap

Inherits:
Object
  • Object
show all
Defined in:
lib/confluence-soap.rb

Defined Under Namespace

Modules: Error Classes: Page

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, user, password, opts = {}) ⇒ ConfluenceSoap

Returns a new instance of ConfluenceSoap.



27
28
29
30
31
32
33
34
35
# File 'lib/confluence-soap.rb', line 27

def initialize(url, user, password, opts = {})
  opts = opts.merge(wsdl: url)
  @user = user
  @password = password
  @client = Savon.client(opts) do
    convert_request_keys_to :lower_camelcase
  end
  @token = 
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



6
7
8
# File 'lib/confluence-soap.rb', line 6

def client
  @client
end

#tokenObject (readonly)

Returns the value of attribute token.



6
7
8
# File 'lib/confluence-soap.rb', line 6

def token
  @token
end

#userObject (readonly)

Returns the value of attribute user.



6
7
8
# File 'lib/confluence-soap.rb', line 6

def user
  @user
end

Instance Method Details

#add_label_by_name(label, page_id) ⇒ Object



109
110
111
112
113
114
115
# File 'lib/confluence-soap.rb', line 109

def add_label_by_name(label, page_id)
  response = execute do
    client.call(:add_label_by_name, auth_message({in1: label, in2: page_id}))
  end

  parse_response(:add_label_by_name, response)
end

#get_children(page_id) ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/confluence-soap.rb', line 63

def get_children(page_id)
  response = execute do
    client.call(:get_children, auth_message({in1: page_id}))
  end

  pages = parse_array_response(:get_children, response)
  pages.map { |page| Page.from_hash(page) }
end

#get_page(page_id) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/confluence-soap.rb', line 55

def get_page(page_id)
  response = execute do
    client.call(:get_page, auth_message({in1: page_id}))
  end

  Page.from_hash(parse_response(:get_page, response))
end

#get_pages(space) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/confluence-soap.rb', line 46

def get_pages(space)
  response = execute do
    client.call(:get_pages, auth_message({in1: space}))
  end

  pages = parse_array_response(:get_pages, response)
  pages.map { |page| Page.from_hash(page) }
end

#has_user?(user) ⇒ Boolean

Returns:

  • (Boolean)


126
127
128
129
130
131
132
# File 'lib/confluence-soap.rb', line 126

def has_user?(user)
  response = execute do
    client.call(:has_user, auth_message({in1: user}))
  end

  parse_response(:has_user, response)
end

#loginObject



37
38
39
40
# File 'lib/confluence-soap.rb', line 37

def 
  response = client.call(:login, message: {in0: @user, in1: @password})
  @token = parse_response(:login, response)
end

#logoutObject



42
43
44
# File 'lib/confluence-soap.rb', line 42

def logout
  client.call(:logout, message: {in0: @token}) if @token
end

#remove_label_by_name(label, page_id) ⇒ Object



117
118
119
120
121
122
123
124
# File 'lib/confluence-soap.rb', line 117

def remove_label_by_name(label, page_id)
  response = execute do
    client.call(:remove_label_by_name,
                auth_message({in1: label, in2: page_id}))
  end

  parse_response(:remove_label_by_name, response)
end

#remove_page(page_id) ⇒ Object



89
90
91
92
93
94
95
# File 'lib/confluence-soap.rb', line 89

def remove_page(page_id)
  response = execute do
    client.call(:remove_page, auth_message({in1: page_id}))
  end

  parse_response(:remove_page, response)
end

#search(term, criteria = {}) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
# File 'lib/confluence-soap.rb', line 97

def search(term, criteria = {})
  limit    = criteria.delete(:limit) || 20
  criteria = criteria.map { |k, v| {key: k, value: v} }
  response = execute do
    client.call(:search,
                auth_message({in1: term, in2: {item: criteria}, in3: limit}))
  end

  pages = parse_array_response(:search, response)
  pages.map { |page| Page.from_hash(page) }
end

#store_page(page) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/confluence-soap.rb', line 72

def store_page(page)
  response = execute do
    client.call(:store_page, auth_message({in1: page.to_soap}))
  end

  Page.from_hash(parse_response(:store_page, response))
end

#update_page(page) ⇒ Object



80
81
82
83
84
85
86
87
# File 'lib/confluence-soap.rb', line 80

def update_page(page)
  response = execute do
    client.call(:update_page,
                auth_message({in1: page.to_soap, in2: {minorEdit: true} }))
  end

  Page.from_hash(parse_response(:update_page, response))
end