Class: ConfluenceSoap
- Inherits:
-
Object
- Object
- ConfluenceSoap
- Defined in:
- lib/confluence-soap.rb
Defined Under Namespace
Classes: Page
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #add_label_by_name(label, page_id) ⇒ Object
- #execute(&block) ⇒ Object
- #get_children(page_id) ⇒ Object
- #get_page(page_id) ⇒ Object
- #get_pages(space) ⇒ Object
- #has_user(user) ⇒ Object
-
#initialize(url, user, password) ⇒ ConfluenceSoap
constructor
A new instance of ConfluenceSoap.
- #login(user, password) ⇒ Object
- #logout ⇒ Object
- #remove_label_by_name(label, page_id) ⇒ Object
- #remove_page(page_id) ⇒ Object
- #search(term, criteria = {}) ⇒ Object
- #store_page(page) ⇒ Object
- #update_page(page) ⇒ Object
Constructor Details
#initialize(url, user, password) ⇒ ConfluenceSoap
Returns a new instance of ConfluenceSoap.
19 20 21 22 23 24 25 26 |
# File 'lib/confluence-soap.rb', line 19 def initialize url, user, password @user = user @password = password @client = Savon.client(wsdl: url) do convert_request_keys_to :lower_camelcase end @token = login(user, password) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'lib/confluence-soap.rb', line 4 def client @client end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
4 5 6 |
# File 'lib/confluence-soap.rb', line 4 def token @token end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
4 5 6 |
# File 'lib/confluence-soap.rb', line 4 def user @user end |
Instance Method Details
#add_label_by_name(label, page_id) ⇒ Object
81 82 83 84 85 86 |
# File 'lib/confluence-soap.rb', line 81 def add_label_by_name(label, page_id) response = @client.call(:add_label_by_name, ({in1: label, in2: page_id})) parse_response(:add_label_by_name, response) end |
#execute(&block) ⇒ Object
101 102 103 104 105 106 107 108 109 110 |
# File 'lib/confluence-soap.rb', line 101 def execute &block yield self rescue Savon::SOAPFault => e if e.to_hash[:fault][:faultstring] =~ /InvalidSessionException/ reconnect yield e else raise e end end |
#get_children(page_id) ⇒ Object
48 49 50 51 52 |
# File 'lib/confluence-soap.rb', line 48 def get_children page_id response = @client.call :get_children, ({in1: page_id}) pages = parse_array_response :get_children, response pages.map { |page| Page.from_hash(page) } end |
#get_page(page_id) ⇒ Object
43 44 45 46 |
# File 'lib/confluence-soap.rb', line 43 def get_page page_id response = @client.call :get_page, ({in1: page_id}) Page.from_hash parse_response :get_page, response end |
#get_pages(space) ⇒ Object
37 38 39 40 41 |
# File 'lib/confluence-soap.rb', line 37 def get_pages space response = @client.call :get_pages, ({in1: space}) pages = parse_array_response :get_pages, response pages.map { |page| Page.from_hash(page) } end |
#has_user(user) ⇒ Object
96 97 98 99 |
# File 'lib/confluence-soap.rb', line 96 def has_user user response = @client.call(:has_user, ({in1: user})) parse_response(:has_user, response) end |
#login(user, password) ⇒ Object
28 29 30 31 |
# File 'lib/confluence-soap.rb', line 28 def login user, password response = @client.call :login, message: {in0: user, in1: password} @token = response.body[:login_response][:login_return] end |
#logout ⇒ Object
33 34 35 |
# File 'lib/confluence-soap.rb', line 33 def logout @client.call :logout, message: {in0: @token} if @token end |
#remove_label_by_name(label, page_id) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/confluence-soap.rb', line 88 def remove_label_by_name(label, page_id) response = @client.call(:remove_label_by_name, ({in1: label, in2: page_id})) parse_response(:remove_label_by_name, response) end |
#remove_page(page_id) ⇒ Object
66 67 68 69 |
# File 'lib/confluence-soap.rb', line 66 def remove_page page_id response = @client.call :remove_page, ({in1: page_id}) Page.from_hash parse_response :remove_page, response end |
#search(term, criteria = {}) ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/confluence-soap.rb', line 71 def search(term, criteria = {}) limit = criteria.delete(:limit) || 20 criteria = criteria.map { |k, v| {key: k, value: v} } response = @client.call(:search, ({in1: term, in2: {item: criteria}, in3: limit})) pages = parse_array_response :search, response pages.map { |page| Page.from_hash(page) } end |
#store_page(page) ⇒ Object
54 55 56 57 |
# File 'lib/confluence-soap.rb', line 54 def store_page page response = @client.call :store_page, ({in1: page.to_soap}) Page.from_hash parse_response :store_page, response end |
#update_page(page) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/confluence-soap.rb', line 59 def update_page page response = @client.call(:update_page, ({in1: page.to_soap, in2: {minorEdit: true} })) Page.from_hash parse_response :update_page, response end |