Sha256: f98ccb9ccf1b859c66be1042d032176597792dc42cf76a9196a2ef422d55d7aa

Contents?: true

Size: 978 Bytes

Versions: 3

Compression:

Stored size: 978 Bytes

Contents

module Woodpecker
  module Utils
    module Request
      module_function

      def get(endpoint, params = {})
        request = Typhoeus::Request.get("https://api.woodpecker.co/rest/v1/#{endpoint}",
                                        userpwd: "#{Woodpecker.configuration.api_key}:#{Woodpecker.configuration.dummy_password}",
                                        params: params)
        data = JSON.parse(request.response_body, symbolize_names: true)
        data
      end

      def post(endpoint, params = {}, body = {})
        request = Typhoeus::Request.post("https://api.woodpecker.co/rest/v1/#{endpoint}",
                                         userpwd: "#{Woodpecker.configuration.api_key}:#{Woodpecker.configuration.dummy_password}",
                                         params: params,
                                         body: body)
        data = JSON.parse(request.response_body, symbolize_names: true)
        data
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
woodpecker-0.1.2 lib/woodpecker/utils/request.rb
woodpecker-0.1.1 lib/woodpecker/utils/request.rb
woodpecker-0.1.0 lib/woodpecker/utils/request.rb