Sha256: f4e18264ca5c5c355d26b6d520f4d7ebcfd7b8f5dda6deeeda11717f445b3c73

Contents?: true

Size: 1.47 KB

Versions: 4

Compression:

Stored size: 1.47 KB

Contents

module HackerOne
  module Client
    module ResourceHelper
      def self.included(base)
        base.extend(self)
      end

      def parse_response(response, extract_data: true)
        HackerOne::Client::Api.parse_response(
          response,
          extract_data: extract_data
        )
      end

      def make_put_request(url, request_body:, extract_data: true)
        response = HackerOne::Client::Api.hackerone_api_connection.put do |req|
          req.headers['Content-Type'] = 'application/json'
          req.url url
          req.body = { data: request_body }.to_json
        end

        parse_response(response, extract_data: extract_data)
      end

      def make_post_request(url, request_body:, extract_data: true)
        response = HackerOne::Client::Api.hackerone_api_connection.post do |req|
          req.headers['Content-Type'] = 'application/json'
          req.url url
          req.body = { data: request_body }.to_json
        end

        parse_response(response, extract_data: extract_data)
      end

      def make_get_request(url, params: {}, extract_data: true)
        response = HackerOne::Client::Api.hackerone_api_connection.get do |req|
          req.headers['Content-Type'] = 'application/json'
          req.url url
          req.params = params
        end

        parse_response(response, extract_data: extract_data)
      end

      private

      def api_connection
        HackerOne::Client::Api.hackerone_api_connection
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hackerone-client-0.15.0 lib/hackerone/client/resource_helper.rb
hackerone-client-0.14.2 lib/hackerone/client/resource_helper.rb
hackerone-client-0.14.1 lib/hackerone/client/resource_helper.rb
hackerone-client-0.14.0 lib/hackerone/client/resource_helper.rb