Module: Aircana::Contexts::ConfluenceHttp
- Included in:
- Confluence
- Defined in:
- lib/aircana/contexts/confluence_http.rb
Instance Method Summary collapse
- #get_next_page_url(response) ⇒ Object
- #get_page_content(page_id) ⇒ Object
- #get_pages_for_label(label_id) ⇒ Object
- #validate_response(response) ⇒ Object
Instance Method Details
#get_next_page_url(response) ⇒ Object
36 37 38 |
# File 'lib/aircana/contexts/confluence_http.rb', line 36 def get_next_page_url(response) response.dig("_links", "next") end |
#get_page_content(page_id) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/aircana/contexts/confluence_http.rb', line 18 def get_page_content(page_id) path = "/rest/api/content/#{page_id}" query_params = { expand: "body.storage" } log_request("GET", path, query_params) response = self.class.get(path, { query: query_params }) log_response(response, "Page content") validate_response(response) response end |
#get_pages_for_label(label_id) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/aircana/contexts/confluence_http.rb', line 6 def get_pages_for_label(label_id) path = "/wiki/api/v2/labels/#{label_id}/pages" query_params = { "body-format" => "storage", limit: 100 } log_request("GET", path, query_params) response = self.class.get(path, { query: query_params }) log_response(response, "Pages for label") validate_response(response) response end |
#validate_response(response) ⇒ Object
30 31 32 33 34 |
# File 'lib/aircana/contexts/confluence_http.rb', line 30 def validate_response(response) return if response.success? raise Error, "HTTP #{response.code}: #{response.}" end |