summaryrefslogtreecommitdiff
path: root/qa/qa/support/api.rb
blob: 1107d43161efdefb705264641a9eb06d81a4ac42 (plain)
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
module QA
  module Support
    module Api
      def post(url, payload)
        RestClient::Request.execute(
          method: :post,
          url: url,
          payload: payload,
          verify_ssl: false)
      rescue RestClient::ExceptionWithResponse => e
        e.response
      end

      def get(url)
        RestClient::Request.execute(
          method: :get,
          url: url,
          verify_ssl: false)
      rescue RestClient::ExceptionWithResponse => e
        e.response
      end

      def parse_body(response)
        JSON.parse(response.body, symbolize_names: true)
      end
    end
  end
end